Skip to content

Commit

Permalink
test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerboa-app committed May 13, 2024
1 parent 4e3e097 commit 7ba980c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn read_config(path: &str) -> Option<Config>
Some(d) => d,
None =>
{
println!("Error reading configuration file {} no data", path);
crate::debug(format!("Error reading configuration file {} no data", path), None);
return None
}
};
Expand All @@ -104,7 +104,7 @@ pub fn read_config(path: &str) -> Option<Config>
Ok(data) => {data},
Err(why) =>
{
println!("Error reading configuration file {}\n{}", path, why);
crate::debug(format!("Error reading configuration file {}\n{}", path, why), None);
return None
}
};
Expand All @@ -113,7 +113,7 @@ pub fn read_config(path: &str) -> Option<Config>
}
else
{
println!("Error configuration file {} does not exist", path);
crate::debug(format!("Error configuration file {} does not exist", path), None);
None
}
}
12 changes: 12 additions & 0 deletions tests/test_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@ mod config
assert_eq!(config.content.server_cache_period_seconds, 1);
assert_eq!(config.content.ignore_regexes.unwrap(), vec!["/.git", "workspace"]);
}

#[test]
fn test_config_error()
{
let missing_config = read_config("not_a_config");

assert!(missing_config.is_none());

let not_a_config = read_config("test/pages/b.html");

assert!(not_a_config.is_none());
}
}

0 comments on commit 7ba980c

Please sign in to comment.