]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#916] Added tests
authorFrancis Dupont <fdupont@isc.org>
Fri, 29 May 2020 19:45:05 +0000 (21:45 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 8 Jul 2020 12:32:45 +0000 (14:32 +0200)
src/lib/process/tests/d_controller_unittests.cc
src/lib/process/testutils/d_test_stubs.h

index accc6dc6b122c8a315ca3c51784349426af290bf..010cd4e9144d597c3a17396870eca10480c5dfd6 100644 (file)
@@ -28,12 +28,13 @@ public:
     /// @brief Constructor.
     /// Note the constructor passes in the static DStubController instance
     /// method.
-    DStubControllerTest() : DControllerTest (DStubController::instance) {
+    DStubControllerTest() : DControllerTest(DStubController::instance) {
         controller_ = boost::dynamic_pointer_cast<DStubController>
                                                  (DControllerTest::
                                                   getController());
     }
 
+    /// @brief The controller.
     DStubControllerPtr controller_;
 };
 
@@ -287,6 +288,28 @@ TEST_F(DStubControllerTest, configUpdateTests) {
     EXPECT_EQ(1, rcode);
 }
 
+// Tests that handleOtherObjects behaves as expected.
+TEST_F(DStubControllerTest, handleOtherObjects) {
+    using namespace isc::data;
+
+    // A bad config.
+    ElementPtr config = Element::createMap();
+    config->set(controller_->getAppName(), Element::create(1));
+    config->set("foo", Element::create(2));
+    config->set("bar", Element::create(3));
+
+    // Check the error message.
+    std::string errmsg;
+    EXPECT_NO_THROW(errmsg = controller_->handleOtherObjects(config));
+    EXPECT_EQ(" contains unsupported 'bar' parameter (and 'foo')", errmsg);
+
+    // Retry with no error.
+    config = Element::createMap();
+    config->set(controller_->getAppName(), Element::create(1));
+    EXPECT_NO_THROW(errmsg = controller_->handleOtherObjects(config));
+    EXPECT_TRUE(errmsg.empty());
+}
+
 // Tests that registered signals are caught and handled.
 TEST_F(DStubControllerTest, ioSignals) {
     // Tell test controller just to record the signals, don't call the
@@ -355,8 +378,6 @@ TEST_F(DStubControllerTest, alternateParsing) {
     EXPECT_EQ(SIGHUP, signals[0]);
 }
 
-
-
 // Tests that the original configuration is replaced after a SIGHUP triggered
 // reconfiguration succeeds.
 TEST_F(DStubControllerTest, validConfigReload) {
index ff79363546a74a9dd41768077f980475d4c5c5f7..01531c76eb93abe92a5440f1d497919ada19eba2 100644 (file)
@@ -190,6 +190,9 @@ public:
         return (processed_signals_);
     }
 
+    /// @brief Deals with other (i.e. not application name) global objects.
+    using DControllerBase::handleOtherObjects;
+
     /// @brief Controls whether signals are processed in full or merely
     /// recorded.
     ///