Add testcase
This commit is contained in:
parent
03207fbda9
commit
5cdcdbfc1c
@ -2,7 +2,7 @@ pub mod common;
|
||||
|
||||
pub use common::{features::*, setup::*, TestContext};
|
||||
use pretty_assertions::assert_eq;
|
||||
use sea_orm::{entity::prelude::*, entity::*, DatabaseConnection};
|
||||
use sea_orm::{entity::prelude::*, entity::*, sea_query::OnConflict, DatabaseConnection};
|
||||
use serde_json::json;
|
||||
|
||||
#[sea_orm_macros::test]
|
||||
@ -30,7 +30,7 @@ pub async fn insert_and_delete_repository(db: &DatabaseConnection) -> Result<(),
|
||||
}
|
||||
.into_active_model();
|
||||
|
||||
let result = repository.insert(db).await?;
|
||||
let result = repository.clone().insert(db).await?;
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
@ -42,6 +42,17 @@ pub async fn insert_and_delete_repository(db: &DatabaseConnection) -> Result<(),
|
||||
}
|
||||
);
|
||||
|
||||
#[cfg(any(feature = "sqlx-sqlite", feature = "sqlx-postgres"))]
|
||||
{
|
||||
let err = Repository::insert(repository)
|
||||
// MySQL does not support DO NOTHING, we might workaround that later
|
||||
.on_conflict(OnConflict::new().do_nothing().to_owned())
|
||||
.exec(db)
|
||||
.await;
|
||||
|
||||
assert_eq!(err.err(), Some(DbErr::RecordNotInserted));
|
||||
}
|
||||
|
||||
result.delete(db).await?;
|
||||
|
||||
assert_eq!(
|
||||
|
Loading…
x
Reference in New Issue
Block a user