Skip to content

Commit

Permalink
Try unique constraint failed
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Jan 30, 2023
1 parent 1af5191 commit 66cffd4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/enum_primary_key_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,28 @@ pub async fn insert_teas(db: &DatabaseConnection) -> Result<(), DbErr> {
.unwrap()
);

// UNIQUE constraint failed
assert!(ActiveModel {
id: Set(Tea::EverydayTea),
category: Set(Some(Category::Big)),
color: Set(Some(Color::Black)),
..Default::default()
}
.insert(db)
.await
.is_err());

// UNIQUE constraint failed
assert!(Entity::insert(ActiveModel {
id: Set(Tea::EverydayTea),
category: Set(Some(Category::Big)),
color: Set(Some(Color::Black)),
..Default::default()
})
.exec(db)
.await
.is_err());

let _ = ActiveModel {
category: Set(Some(Category::Big)),
color: Set(Some(Color::Black)),
Expand Down

0 comments on commit 66cffd4

Please sign in to comment.