Skip to content

Commit

Permalink
Testing into_json for UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Mar 22, 2022
1 parent 5316a6f commit 0e99349
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/timestamp_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod common;
pub use common::{features::*, setup::*, TestContext};
use pretty_assertions::assert_eq;
use sea_orm::{entity::prelude::*, DatabaseConnection, IntoActiveModel};
use serde_json::json;

Expand Down
21 changes: 21 additions & 0 deletions tests/uuid_tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pub mod common;

pub use common::{features::*, setup::*, TestContext};
use pretty_assertions::assert_eq;
use sea_orm::{entity::prelude::*, entity::*, DatabaseConnection};
use serde_json::json;

#[sea_orm_macros::test]
#[cfg(any(
Expand Down Expand Up @@ -34,6 +36,25 @@ pub async fn insert_metadata(db: &DatabaseConnection) -> Result<(), DbErr> {

assert_eq!(result, metadata);

let json = metadata::Entity::find()
.filter(metadata::Column::Uuid.eq(metadata.uuid))
.into_json()
.one(db)
.await?;

assert_eq!(
json,
Some(json!({
"uuid": metadata.uuid,
"type": metadata.ty,
"key": metadata.key,
"value": metadata.value,
"bytes": metadata.bytes,
"date": metadata.date,
"time": metadata.time,
}))
);

Ok(())
}

Expand Down

0 comments on commit 0e99349

Please sign in to comment.