Add test cases

This commit is contained in:
Billy Chan 2021-09-28 14:27:30 +08:00
parent 88776a28ed
commit 89806ef522
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7
5 changed files with 8 additions and 0 deletions

View File

@ -6,6 +6,7 @@ use crate::entity::prelude::*;
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
pub id: i32, pub id: i32,
#[sea_orm(column_name = "name", enum_name = "Name")]
pub name: String, pub name: String,
} }

View File

@ -5,6 +5,8 @@ use sea_orm::entity::prelude::*;
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub uuid: Uuid, pub uuid: Uuid,
#[sea_orm(column_name = "type", enum_name = "Type")]
pub ty: String,
pub key: String, pub key: String,
pub value: String, pub value: String,
pub bytes: Vec<u8>, pub bytes: Vec<u8>,

View File

@ -283,6 +283,7 @@ pub async fn create_metadata_table(db: &DbConn) -> Result<ExecResult, DbErr> {
.not_null() .not_null()
.primary_key(), .primary_key(),
) )
.col(ColumnDef::new(metadata::Column::Type).string().not_null())
.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()) .col(ColumnDef::new(metadata::Column::Bytes).binary().not_null())

View File

@ -22,18 +22,21 @@ pub async fn crud_in_parallel(db: &DatabaseConnection) -> Result<(), DbErr> {
let metadata = vec![ let metadata = vec![
metadata::Model { metadata::Model {
uuid: Uuid::new_v4(), uuid: Uuid::new_v4(),
ty: "Type".to_owned(),
key: "markup".to_owned(), key: "markup".to_owned(),
value: "1.18".to_owned(), value: "1.18".to_owned(),
bytes: vec![1, 2, 3], bytes: vec![1, 2, 3],
}, },
metadata::Model { metadata::Model {
uuid: Uuid::new_v4(), uuid: Uuid::new_v4(),
ty: "Type".to_owned(),
key: "exchange_rate".to_owned(), key: "exchange_rate".to_owned(),
value: "0.78".to_owned(), value: "0.78".to_owned(),
bytes: vec![1, 2, 3], bytes: vec![1, 2, 3],
}, },
metadata::Model { metadata::Model {
uuid: Uuid::new_v4(), uuid: Uuid::new_v4(),
ty: "Type".to_owned(),
key: "service_charge".to_owned(), key: "service_charge".to_owned(),
value: "1.1".to_owned(), value: "1.1".to_owned(),
bytes: vec![1, 2, 3], bytes: vec![1, 2, 3],

View File

@ -20,6 +20,7 @@ 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::Model { let metadata = metadata::Model {
uuid: Uuid::new_v4(), uuid: Uuid::new_v4(),
ty: "Type".to_owned(),
key: "markup".to_owned(), key: "markup".to_owned(),
value: "1.18".to_owned(), value: "1.18".to_owned(),
bytes: vec![1, 2, 3], bytes: vec![1, 2, 3],