]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1975] Check that data source error exception is propagated
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Wed, 6 Jun 2012 13:55:44 +0000 (15:55 +0200)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Wed, 6 Jun 2012 13:55:44 +0000 (15:55 +0200)
src/lib/datasrc/tests/container_unittest.cc

index be4ecbbe5f0bd36141cb6af60ae521b34e046cbc..1fa27185a2c78271d7e5ef0f661e43c067b59de9 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <datasrc/container.h>
 #include <datasrc/client.h>
+#include <datasrc/data_source.h>
 
 #include <dns/rrclass.h>
 
@@ -123,6 +124,9 @@ public:
     virtual DataSourcePair getDataSource(const string& type,
                                          const ConstElementPtr& configuration)
     {
+        if (type == "error") {
+            isc_throw(DataSourceError, "The error data source type");
+        }
         shared_ptr<TestDS> ds(new TestDS(type, configuration));
         // Make sure it is deleted when the test container is deleted.
         to_delete_.push_back(ds);
@@ -422,8 +426,18 @@ TEST_F(ContainerTest, defaults) {
         "{"
         "   \"type\": \"type1\""
         "}]"));
+    container_.reset(new TestedContainer(elem, true));
     EXPECT_EQ(1, container_->dataSources().size());
     checkDS(0, "type1", "null");
 }
 
+// Make sure the data source error exception from the factory is propagated
+TEST_F(ContainerTest, dataSrcError) {
+    ConstElementPtr elem(Element::fromJSON("["
+        "{"
+        "   \"type\": \"error\""
+        "}]"));
+    EXPECT_THROW(TestedContainer(elem, true), DataSourceError);
+}
+
 }