refactor(config): rename Config as ServerConfig

This commit is contained in:
Paul Campbell 2024-04-08 08:31:45 +01:00
parent a4e781d4e4
commit d5e9b14e3d
2 changed files with 6 additions and 5 deletions

View file

@ -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<String, Forge>,
}
impl Config {
impl ServerConfig {
pub(crate) fn load(fs: &FileSystem) -> Result<Self, OneOf<(std::io::Error, toml::de::Error)>> {
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());

View file

@ -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);