From 90d2af4daf7a725173bcb0cacc3bcedaa50621a8 Mon Sep 17 00:00:00 2001 From: AlexanderManich Date: Tue, 28 Nov 2023 12:30:11 +0100 Subject: [PATCH] more tests --- src/tests/api/model_logic.rs | 19 +------------------ src/tests/database/access_context.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/tests/api/model_logic.rs b/src/tests/api/model_logic.rs index 8710955..08331dc 100644 --- a/src/tests/api/model_logic.rs +++ b/src/tests/api/model_logic.rs @@ -1,9 +1,8 @@ use mockall::predicate; -use sea_orm::DbErr; use tonic::{Code, Request}; use crate::{ - api::server::server::{ecdar_api_server::EcdarApi, ComponentsInfo, GetModelRequest}, + api::server::server::{ecdar_api_server::EcdarApi, GetModelRequest}, entities::{access, in_use, model, query}, tests::api::helpers::{get_mock_concrete_ecdar_api, get_mock_services}, }; @@ -263,22 +262,6 @@ async fn get_model_model_has_no_queries_queries_are_empty() { latest_activity: Default::default(), }; - let query1 = query::Model { - id: 0, - model_id: 1, - string: "query".to_owned(), - result: None, - outdated: false, - }; - - let query2 = query::Model { - id: 1, - model_id: 1, - string: "query".to_owned(), - result: Some(serde_json::to_value("result").unwrap()), - outdated: false, - }; - let queries: Vec = vec![]; mock_services diff --git a/src/tests/database/access_context.rs b/src/tests/database/access_context.rs index 23207f1..c425844 100644 --- a/src/tests/database/access_context.rs +++ b/src/tests/database/access_context.rs @@ -1,5 +1,6 @@ #[cfg(test)] mod database_tests { + use crate::database::access_context::AccessContextTrait; use crate::tests::database::helpers::{ create_accesses, create_models, create_users, get_reset_database_context, }; @@ -345,4 +346,17 @@ mod database_tests { DbErr::RecordNotFound(_) )); } + + #[tokio::test] + async fn get_by_uid_and_model_id_test() { + let (access_context, expected_access, user, model) = seed_db().await; + + let access = access_context + .get_access_by_uid_and_model_id(user.id, model.id) + .await; + + dbg!(&expected_access, &access, user, model); + + assert!(access.unwrap().unwrap() == expected_access); + } }