Add unit tests for the services
This commit is contained in:
parent
926ac006e7
commit
3b20d12ba1
9 changed files with 231 additions and 12 deletions
|
|
@ -3,6 +3,9 @@ name = "dao_impl"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.80"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies.sqlx]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use dao::DaoError;
|
||||
use sqlx::{query, SqlitePool};
|
||||
|
||||
|
|
@ -13,6 +14,7 @@ impl HelloDaoImpl {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl dao::HelloDao for HelloDaoImpl {
|
||||
async fn get_hello(&self) -> Result<Arc<str>, dao::DaoError> {
|
||||
let result = query!(r"SELECT 'Hello, world!' as message")
|
||||
|
|
@ -32,6 +34,7 @@ impl PermissionDaoImpl {
|
|||
Self { pool }
|
||||
}
|
||||
}
|
||||
#[async_trait]
|
||||
impl dao::PermissionDao for PermissionDaoImpl {
|
||||
async fn has_privilege(&self, user: &str, privilege: &str) -> Result<bool, dao::DaoError> {
|
||||
let result = query!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue