diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-11-30 21:00:59 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-11-30 21:00:59 -0800 |
commit | 686edc56adc0d8964af8505e41dc9455c1fe732c (patch) | |
tree | 221eeb94826ae4191d3e761f8920bbb83a9a9540 /src | |
parent | 62604bb96eabac5bad069d13354b87874ab5f1ef (diff) | |
download | modelthing-686edc56adc0d8964af8505e41dc9455c1fe732c.tar.gz modelthing-686edc56adc0d8964af8505e41dc9455c1fe732c.zip |
fix metadata parsing test
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -54,8 +54,12 @@ pub struct ModelEntry { pub fn parse_metadata(raw: String) -> Result<ModelMetadata,String> { let root = toml::Parser::new(&raw).parse().unwrap(); - let model = root.get("model").unwrap().as_table().unwrap(); - let variables = root.get("variables").unwrap().as_table().unwrap(); + let model = root.get("model") + .expect("missing 'model' section") + .as_table().unwrap(); + let variables = root.get("variables") + .expect("missing 'variables' section") + .as_table().unwrap(); let mut vars = vec![]; for (slug, info) in variables { let info = info.as_table().unwrap(); @@ -183,7 +187,13 @@ pub fn pp_parseerror(raw: &str, pe: ParseError<usize, (usize, &str), ()>) -> Str #[test] fn test_parse_metadata() { - assert_eq!(parse_metadata("asdf".to_string()).unwrap(), + let raw = +r#" +[model] +name-en = "Bogus Dummy Model" +[variables] +"#.to_string(); + assert_eq!(parse_metadata(raw).unwrap(), ModelMetadata { name_en: "Bogus Dummy Model".to_string(), description_en: None, |