Testing Vec<u8>
This commit is contained in:
parent
c3084e425f
commit
cc5fde41bd
@ -8,6 +8,7 @@ pub struct Model {
|
|||||||
pub uuid: Uuid,
|
pub uuid: Uuid,
|
||||||
pub key: String,
|
pub key: String,
|
||||||
pub value: String,
|
pub value: String,
|
||||||
|
pub bytes: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter)]
|
#[derive(Copy, Clone, Debug, EnumIter)]
|
||||||
|
@ -281,6 +281,7 @@ pub async fn create_metadata_table(db: &DbConn) -> Result<ExecResult, DbErr> {
|
|||||||
)
|
)
|
||||||
.col(ColumnDef::new(metadata::Column::Key).string().not_null())
|
.col(ColumnDef::new(metadata::Column::Key).string().not_null())
|
||||||
.col(ColumnDef::new(metadata::Column::Value).string().not_null())
|
.col(ColumnDef::new(metadata::Column::Value).string().not_null())
|
||||||
|
.col(ColumnDef::new(metadata::Column::Bytes).binary().not_null())
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
create_table(db, &stmt, Metadata).await
|
create_table(db, &stmt, Metadata).await
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
|
|
||||||
pub use common::{bakery_chain::*, setup::*, TestContext};
|
pub use common::{bakery_chain::*, setup::*, TestContext};
|
||||||
use sea_orm::{entity::prelude::*, DatabaseConnection, Set};
|
use sea_orm::{entity::prelude::*, DatabaseConnection, IntoActiveModel, Set};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[sea_orm_macros::test]
|
#[sea_orm_macros::test]
|
||||||
@ -21,18 +21,23 @@ async fn main() -> Result<(), DbErr> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> {
|
pub async fn create_metadata(db: &DatabaseConnection) -> Result<(), DbErr> {
|
||||||
let metadata = metadata::ActiveModel {
|
let metadata = metadata::Model {
|
||||||
uuid: Set(Uuid::new_v4()),
|
uuid: Uuid::new_v4(),
|
||||||
key: Set("markup".to_owned()),
|
key: "markup".to_owned(),
|
||||||
value: Set("1.18".to_owned()),
|
value: "1.18".to_owned(),
|
||||||
|
bytes: vec![1, 2, 3],
|
||||||
};
|
};
|
||||||
|
|
||||||
let res = Metadata::insert(metadata.clone()).exec(db).await?;
|
let res = Metadata::insert(metadata.clone().into_active_model())
|
||||||
|
.exec(db)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
assert_eq!(Metadata::find().one(db).await?, Some(metadata.clone()));
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
res.last_insert_id,
|
res.last_insert_id,
|
||||||
if cfg!(feature = "sqlx-postgres") {
|
if cfg!(feature = "sqlx-postgres") {
|
||||||
metadata.uuid.unwrap()
|
metadata.uuid
|
||||||
} else {
|
} else {
|
||||||
Default::default()
|
Default::default()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user