ForgeFlux/src/auth/adapter/out/forge/forge_factory.rs
Aravinth Manivannan 63108e7341
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
feat+chore: factories to create forge adapters
2024-05-06 22:28:21 +05:30

32 lines
719 B
Rust

use std::sync::Arc;
use mockall::predicate::*;
use mockall::*;
use super::forgejo::Forgejo;
use crate::auth::application::port::out::forge::oauth_auth_req_uri::OAuthAuthReqUri;
#[automock]
pub trait ForgeAdapterFactoryInterface: Send + Sync {
fn get_oauth_auth_req_uri_adapter(&self) -> Arc<dyn OAuthAuthReqUri>;
}
#[derive(Clone)]
pub struct ForgeAdapterFactory {
forgejo: Arc<Forgejo>,
}
impl ForgeAdapterFactoryInterface for ForgeAdapterFactory {
fn get_oauth_auth_req_uri_adapter(&self) -> Arc<dyn OAuthAuthReqUri> {
self.forgejo.clone()
}
}
impl ForgeAdapterFactory {
pub fn new(forgejo: Forgejo) -> Self {
Self {
forgejo: Arc::new(forgejo),
}
}
}