chore: return Ctx and not ArcCtx

This commit is contained in:
Aravinth Manivannan 2023-09-27 19:34:21 +05:30
parent 10a5d91bd1
commit d2801adeca
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 10 additions and 5 deletions

View file

@ -39,17 +39,17 @@ pub struct Ctx {
} }
impl Ctx { impl Ctx {
pub async fn new(settings: Settings) -> Arc<Self> { pub async fn new(settings: Settings) -> Self {
let results = HashMap::default(); let results = HashMap::default();
let results = Arc::new(RwLock::new(results)); let results = Arc::new(RwLock::new(results));
let client = Client::default(); let client = Client::default();
let db = get_db(&settings).await; let db = get_db(&settings).await;
Arc::new(Self { Self {
settings, settings,
client, client,
db, db,
results, results,
docker: Arc::new(Docker::new()), docker: Arc::new(Docker::new()),
}) }
} }
} }

View file

@ -48,6 +48,8 @@ pub fn launch_init_containers(ctx: &AppCtx, target: &Target) -> Option<Vec<Archi
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::sync::Arc;
use url::Url; use url::Url;
use super::*; use super::*;
@ -59,11 +61,14 @@ mod tests {
#[actix_rt::test] #[actix_rt::test]
async fn launch_init_containers_works() { async fn launch_init_containers_works() {
let settings = Settings::new().unwrap(); let settings = Settings::new().unwrap();
let ctx = AppCtx::new(Ctx::new(settings.clone()).await); let ctx = AppCtx::new(Arc::new(Ctx::new(settings.clone()).await));
// let base_dir = Path::new(&ctx.settings.repository.base_dir); // let base_dir = Path::new(&ctx.settings.repository.base_dir);
// let control = base_dir.join("control"); // let control = base_dir.join("control");
let compose = DockerCompose::new("../ftest-control/targets/forgejo".into()); let compose = DockerCompose::new(
"../ftest-control/targets/forgejo".into(),
ctx.docker.clone(),
);
compose.up(); compose.up();
let mut env_vars: HashMap<String, String> = HashMap::new(); let mut env_vars: HashMap<String, String> = HashMap::new();