Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sabotack committed Nov 29, 2023
1 parent 6a8972d commit e8c18fc
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/tests/database/model_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,43 +403,43 @@ async fn delete_non_existing_id_test() {
deleted_model.unwrap_err(),
DbErr::RecordNotFound(_)
));
}

#[tokio::test]
async fn get_model_info_by_uid_test() {
let (model_context, model, user) = seed_db().await;

let access = create_accesses(1, user.id, model.id)[0].clone();

let expected_model_info = vec![ModelInfo {
model_id: model.id,
model_name: model.name.clone(),
model_owner_id: model.owner_id,
user_role_on_model: access.role.clone(),
}];

model::Entity::insert(model.clone().into_active_model())
.exec(&model_context.db_context.get_connection())
.await
.unwrap();
access::Entity::insert(access.clone().into_active_model())
.exec(&model_context.db_context.get_connection())
.await
.unwrap();

let model_info = model_context
.get_models_info_by_uid(model.id)
.await
.unwrap();

assert_eq!(model_info, expected_model_info);
}
#[tokio::test]
async fn get_model_info_by_uid_test() {
let (model_context, model, user) = seed_db().await;

#[tokio::test]
async fn get_model_info_by_uid_non_existing_id_test() {
let (model_context, _, _) = seed_db().await;
let access = create_accesses(1, user.id, model.id)[0].clone();

let model_info = model_context.get_models_info_by_uid(1).await;
let expected_model_info = vec![ModelInfo {
model_id: model.id,
model_name: model.name.clone(),
model_owner_id: model.owner_id,
user_role_on_model: access.role.clone(),
}];

assert_eq!(model_info.unwrap().len(), 0);
}
model::Entity::insert(model.clone().into_active_model())
.exec(&model_context.db_context.get_connection())
.await
.unwrap();
access::Entity::insert(access.clone().into_active_model())
.exec(&model_context.db_context.get_connection())
.await
.unwrap();

let model_info = model_context
.get_models_info_by_uid(model.id)
.await
.unwrap();

assert_eq!(model_info, expected_model_info);
}

#[tokio::test]
async fn get_model_info_by_uid_non_existing_id_test() {
let (model_context, _, _) = seed_db().await;

let model_info = model_context.get_models_info_by_uid(1).await;

assert_eq!(model_info.unwrap().len(), 0);
}

0 comments on commit e8c18fc

Please sign in to comment.