Skip to content

Commit

Permalink
Add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Jan 18, 2023
1 parent 03207fb commit 6ec9337
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/string_primary_key_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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,
Expand All @@ -42,6 +42,13 @@ pub async fn insert_and_delete_repository(db: &DatabaseConnection) -> Result<(),
}
);

let err = Repository::insert(repository)
.on_conflict(OnConflict::new().do_nothing().to_owned())
.exec(db)
.await;

assert_eq!(err.err(), Some(DbErr::RecordNotInserted));

result.delete(db).await?;

assert_eq!(
Expand Down

0 comments on commit 6ec9337

Please sign in to comment.