Tests: add test for loading a non-existent service.
authorDavin McCall <davmac@davmac.org>
Fri, 22 Jun 2018 17:51:49 +0000 (18:51 +0100)
committerDavin McCall <davmac@davmac.org>
Fri, 22 Jun 2018 17:51:49 +0000 (18:51 +0100)
src/tests/loadtests.cc

index ec0e2a439067357e2fd2639a0eaad75dfcabce6a..cbca7e028d2ece1fcefbdb3f24d1a483152bb937 100644 (file)
@@ -35,6 +35,19 @@ void test_env_subst()
     assert(strcmp("", exec_parts[3]) == 0);
 }
 
+void test_nonexistent()
+{
+    bool got_service_not_found = false;
+    dirload_service_set sset(test_service_dir.c_str());
+    try {
+        sset.load_service("does-not-exist");
+    }
+    catch (service_not_found &) {
+        got_service_not_found = true;
+    }
+    assert(got_service_not_found);
+}
+
 #define RUN_TEST(name, spacing) \
     std::cout << #name "..." spacing; \
     name(); \
@@ -43,7 +56,8 @@ void test_env_subst()
 int main(int argc, char **argv)
 {
     init_test_service_dir();
-    RUN_TEST(test_basic, "    ");
-    RUN_TEST(test_env_subst, "");
+    RUN_TEST(test_basic, "      ");
+    RUN_TEST(test_env_subst, "  ");
+    RUN_TEST(test_nonexistent, "");
     return 0;
 }