|
|
|
@ -648,24 +648,24 @@ mod tests {
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_config_file_ok() {
|
|
|
|
|
let file = get_toml_from_examples_dir("sdb.toml".to_owned()).unwrap();
|
|
|
|
|
let file = get_toml_from_examples_dir("skyd.toml".to_owned()).unwrap();
|
|
|
|
|
let cfg = ParsedConfig::new_from_toml_str(file).unwrap();
|
|
|
|
|
assert_eq!(cfg, ParsedConfig::default());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_config_file_err() {
|
|
|
|
|
let file = get_toml_from_examples_dir("sdb.toml".to_owned()).unwrap();
|
|
|
|
|
let file = get_toml_from_examples_dir("skyd.toml".to_owned()).unwrap();
|
|
|
|
|
let cfg = ParsedConfig::new_from_file(file);
|
|
|
|
|
assert!(cfg.is_err());
|
|
|
|
|
}
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_args() {
|
|
|
|
|
let cmdlineargs = vec!["sdb", "--withconfig", "../examples/config-files/sdb.toml"];
|
|
|
|
|
let cmdlineargs = vec!["skyd", "--withconfig", "../examples/config-files/skyd.toml"];
|
|
|
|
|
let cfg_layout = load_yaml!("../cli.yml");
|
|
|
|
|
let matches = App::from_yaml(cfg_layout).get_matches_from(cmdlineargs);
|
|
|
|
|
let filename = matches.value_of("config").unwrap();
|
|
|
|
|
assert_eq!("../examples/config-files/sdb.toml", filename);
|
|
|
|
|
assert_eq!("../examples/config-files/skyd.toml", filename);
|
|
|
|
|
let cfg =
|
|
|
|
|
ParsedConfig::new_from_toml_str(std::fs::read_to_string(filename).unwrap()).unwrap();
|
|
|
|
|
assert_eq!(cfg, ParsedConfig::default());
|
|
|
|
|