[2/2] settings: add basic tests
diff mbox

Message ID 20170324025648.14588-2-andrew.donnellan@au1.ibm.com
State Superseded
Headers show

Commit Message

Andrew Donnellan March 24, 2017, 2:56 a.m. UTC
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
---
 src/settings.rs | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Patch
diff mbox

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");
+    }
+}