aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 3f6021d..e38d10f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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,