Compare commits
2 Commits
277f638c60
...
247c06dd9e
| Author | SHA1 | Date | |
|---|---|---|---|
| 247c06dd9e | |||
| cb314a8b4c |
@@ -71,7 +71,7 @@ struct WholeFile {
|
|||||||
project_overrides: Vec<PartialConfig>,
|
project_overrides: Vec<PartialConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lconf(text: &str) -> Result<WholeFile> {
|
fn read_conf_str(text: &str) -> Result<WholeFile> {
|
||||||
let mut whole = WholeFile::default();
|
let mut whole = WholeFile::default();
|
||||||
|
|
||||||
let toml_val = text.parse::<Value>()?;
|
let toml_val = text.parse::<Value>()?;
|
||||||
@@ -235,11 +235,25 @@ repo = \"rcalc\"
|
|||||||
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
let conf = lconf(fx_sample_config_string)?;
|
let conf = read_conf_str(fx_sample_config_string)?;
|
||||||
println!(" ->> Test conf: {:?}", conf);
|
println!(" ->> Test conf: {:?}", conf);
|
||||||
println!(" ->> Ref conf: {:?}", fx_expected_struct);
|
println!(" ->> Ref conf: {:?}", fx_expected_struct);
|
||||||
|
|
||||||
assert_eq!(conf, fx_expected_struct);
|
assert_eq!(conf, fx_expected_struct);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Improve semantics around reading an empty string
|
||||||
|
An empty config string will result in Error::NoSuchTable when "[all]"
|
||||||
|
is retrieved. But this will *also* happen when other configs are present,
|
||||||
|
but "[all]" isn't. Do I treat these as valid configurations, using some
|
||||||
|
hard-coded default as the fallback? Or do I reject configs that don't have
|
||||||
|
an all-table?
|
||||||
|
*/
|
||||||
|
#[test]
|
||||||
|
fn read_config_string_empty() {
|
||||||
|
let fx_sample_cfg = "";
|
||||||
|
let conf = read_conf_str(fx_sample_cfg);
|
||||||
|
assert!(conf.is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user