forked from SeaQL/sea-orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuuid_fmt_tests.rs
36 lines (27 loc) · 891 Bytes
/
uuid_fmt_tests.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#![allow(unused_imports, dead_code)]
pub mod common;
pub use common::{features::*, setup::*, TestContext};
use pretty_assertions::assert_eq;
use sea_orm::{entity::prelude::*, entity::*, DatabaseConnection};
#[sea_orm_macros::test]
async fn main() -> Result<(), DbErr> {
let ctx = TestContext::new("uuid_fmt_tests").await;
create_tables(&ctx.db).await?;
insert_uuid_fmt(&ctx.db).await?;
ctx.delete().await;
Ok(())
}
pub async fn insert_uuid_fmt(db: &DatabaseConnection) -> Result<(), DbErr> {
let uuid = Uuid::new_v4();
let uuid_fmt = uuid_fmt::Model {
id: 1,
uuid,
uuid_braced: uuid.braced(),
uuid_hyphenated: uuid.hyphenated(),
uuid_simple: uuid.simple(),
uuid_urn: uuid.urn(),
};
let result = uuid_fmt.clone().into_active_model().insert(db).await?;
assert_eq!(result, uuid_fmt);
Ok(())
}