From d5e9b14e3d6b0797179bc6f3fadbd90bfe396ccc Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 8 Apr 2024 08:31:45 +0100 Subject: [PATCH] refactor(config): rename Config as ServerConfig --- src/server/config.rs | 9 +++++---- src/server/mod.rs | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/server/config.rs b/src/server/config.rs index a7baccd..596c69a 100644 --- a/src/server/config.rs +++ b/src/server/config.rs @@ -7,11 +7,12 @@ use serde::Deserialize; use terrors::OneOf; use crate::filesystem::FileSystem; + #[derive(Debug, PartialEq, Eq, Deserialize)] -pub struct Config { +pub struct ServerConfig { forge: HashMap, } -impl Config { +impl ServerConfig { pub(crate) fn load(fs: &FileSystem) -> Result> { let str = fs.read_file("git-next-server.toml").map_err(OneOf::new)?; toml::from_str(&str).map_err(OneOf::new) @@ -209,7 +210,7 @@ mod tests { use super::*; #[test] - fn test_config_load() -> Result<(), OneOf<(std::io::Error, toml::de::Error)>> { + fn test_server_config_load() -> Result<(), OneOf<(std::io::Error, toml::de::Error)>> { let fs = FileSystem::new_temp().map_err(OneOf::new)?; fs.write_file( "git-next-server.toml", @@ -225,7 +226,7 @@ mod tests { "#, ) .map_err(OneOf::new)?; - let config = Config::load(&fs)?; + 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()); diff --git a/src/server/mod.rs b/src/server/mod.rs index 120989e..fbd1fb8 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -36,7 +36,7 @@ pub fn start(fs: FileSystem) { return; }; info!("Starting Server..."); - let config = match config::Config::load(&fs) { + let config = match config::ServerConfig::load(&fs) { Ok(config) => config, Err(err) => { error!("Failed to load config file. Error: {}", err);