From 7c18134dc65cda82ca99c9d960f949d103ca64cf Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Fri, 22 Jun 2018 18:51:49 +0100 Subject: [PATCH] Tests: add test for loading a non-existent service. --- src/tests/loadtests.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tests/loadtests.cc b/src/tests/loadtests.cc index ec0e2a4..cbca7e0 100644 --- a/src/tests/loadtests.cc +++ b/src/tests/loadtests.cc @@ -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; } -- 2.25.1