mirror of
https://github.com/Phundrak/georm.git
synced 2025-12-16 09:41:53 +01:00
feat: add foreign one_to_one relationships
This commit is contained in:
@@ -53,3 +53,24 @@ async fn books_are_found_despite_nonstandard_id_name(pool: sqlx::PgPool) -> sqlx
|
||||
assert_eq!(tolkien, book.get_author(&pool).await?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx::test(fixtures("simple_struct"))]
|
||||
async fn biographies_should_find_remote_o2o_author(pool: sqlx::PgPool) -> sqlx::Result<()> {
|
||||
let london = Author::find(&pool, &3).await?.unwrap();
|
||||
let london_biography = Biography::find(&pool, &1).await?.unwrap();
|
||||
let result = london_biography.get_author(&pool).await;
|
||||
assert!(result.is_ok());
|
||||
let result = result.unwrap();
|
||||
assert!(result.is_some());
|
||||
let result = result.unwrap();
|
||||
assert_eq!(london, result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[sqlx::test(fixtures("simple_struct"))]
|
||||
async fn biographies_may_not_have_corresponding_author(pool: sqlx::PgPool) -> sqlx::Result<()> {
|
||||
let biography = Biography::find(&pool, &3).await?.unwrap();
|
||||
let result = biography.get_author(&pool).await?;
|
||||
assert!(result.is_none());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user