[snowpatch] [PATCH 2/2] settings: add basic tests

Andrew Donnellan andrew.donnellan at au1.ibm.com
Fri Mar 24 13:56:48 AEDT 2017


Signed-off-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
---
 src/settings.rs | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/settings.rs b/src/settings.rs
index e05bc98..826f792 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -104,3 +104,25 @@ pub fn parse(path: &str) -> Config {
         }
     }
 }
+
+#[cfg(test)]
+mod test {
+    use settings::*;
+
+    #[test]
+    #[should_panic(expected = "Couldn't open config file")]
+    fn bad_path() {
+        parse("/nonexistent/config.file");
+    }
+
+    #[test]
+    fn parse_example_openpower() {
+        parse("examples/openpower.toml");
+    }
+
+    #[test]
+    #[should_panic(expected = "Could not parse configuration file, exiting")]
+    fn parse_example_invalid() {
+        parse("examples/tests/invalid.toml");
+    }
+}
-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com  IBM Australia Limited



More information about the snowpatch mailing list