Add unit tests for the services
This commit is contained in:
parent
926ac006e7
commit
3b20d12ba1
9 changed files with 231 additions and 12 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use std::{future::Future, sync::Arc};
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
@ -10,17 +12,19 @@ pub enum ServiceError {
|
|||
Forbidden,
|
||||
}
|
||||
|
||||
#[automock]
|
||||
pub trait HelloService {
|
||||
fn hello(&self) -> impl Future<Output = Result<Arc<str>, ServiceError>> + Send;
|
||||
}
|
||||
|
||||
#[automock]
|
||||
#[async_trait]
|
||||
pub trait PermissionService {
|
||||
fn check_permission(
|
||||
&self,
|
||||
privilege: &str,
|
||||
) -> impl Future<Output = Result<(), ServiceError>> + Send;
|
||||
async fn check_permission(&self, privilege: &str) -> Result<(), ServiceError>;
|
||||
}
|
||||
|
||||
#[automock]
|
||||
#[async_trait]
|
||||
pub trait UserService {
|
||||
fn current_user(&self) -> impl Future<Output = Result<Arc<str>, ServiceError>> + Send;
|
||||
async fn current_user(&self) -> Result<Arc<str>, ServiceError>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue