diff --git a/Cargo.toml b/Cargo.toml index 493a45a..c12689d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ actix-rt = "2.9" [dev-dependencies] # Testing -assert2 = "0.3" +# assert2 = "0.3" test-log = "0.2" anyhow = "1.0" diff --git a/src/server/config.rs b/src/server/config.rs index 91444bf..0d825c5 100644 --- a/src/server/config.rs +++ b/src/server/config.rs @@ -77,13 +77,6 @@ pub struct Repo { branch: String, } impl Repo { - #[cfg(test)] - pub fn new(repo: &str, branch: &str) -> Self { - Self { - repo: repo.to_string(), - branch: branch.to_string(), - } - } #[allow(dead_code)] pub fn repo(&self) -> RepoPath { RepoPath(self.repo.clone()) @@ -227,7 +220,6 @@ impl Display for ForgeType { #[cfg(test)] mod tests { - use assert2::let_assert; use crate::filesystem::FileSystem; @@ -251,18 +243,33 @@ mod tests { ) .map_err(OneOf::new)?; let config = ServerConfig::load(&fs)?; - let_assert!(Some(default) = config.forge.get("default")); - assert_eq!(default.forge_type, ForgeType::ForgeJo); - assert_eq!(default.hostname, "git.example.net".to_string()); - assert_eq!(default.user, "Bob".to_string()); - assert_eq!( - default.repos.get("hello"), - Some(Repo::new("user/hello", "main").as_ref()) - ); - assert_eq!( - default.repos.get("world"), - Some(Repo::new("user/world", "master").as_ref()) - ); + let expected = ServerConfig { + forge: HashMap::from([( + "default".to_string(), + Forge { + forge_type: ForgeType::ForgeJo, + hostname: "git.example.net".to_string(), + user: "Bob".to_string(), + repos: HashMap::from([ + ( + "hello".to_string(), + Repo { + repo: "user/hello".to_string(), + branch: "main".to_string(), + }, + ), + ( + "world".to_string(), + Repo { + repo: "user/world".to_string(), + branch: "master".to_string(), + }, + ), + ]), + }, + )]), + }; + assert_eq!(config, expected); Ok(()) }