mirror of
https://github.com/Phundrak/georm.git
synced 2026-07-29 04:19:18 +02:00
test: added tests for M2M relationships, it works
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
use georm::Georm;
|
||||
|
||||
mod models;
|
||||
use models::*;
|
||||
|
||||
#[sqlx::test(fixtures("simple_struct", "o2o", "m2m"))]
|
||||
async fn genres_should_be_able_to_access_all_books(pool: sqlx::PgPool) -> sqlx::Result<()> {
|
||||
let fantasy = Genre::find(&pool, &1).await?.unwrap();
|
||||
let books = fantasy.get_books(&pool).await?;
|
||||
assert_eq!(3, books.len());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx::test(fixtures("simple_struct", "o2o", "m2m"))]
|
||||
async fn books_should_be_able_to_access_their_genres(pool: sqlx::PgPool) -> sqlx::Result<()> {
|
||||
let to_build_a_fire = Book::find(&pool, &4).await?.unwrap();
|
||||
let genres = to_build_a_fire.get_genres(&pool).await?;
|
||||
assert_eq!(2, genres.len());
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user