From: Michal 'vorner' Vaner Date: Thu, 14 Mar 2013 10:26:28 +0000 (+0100) Subject: [2835] Test the names in C++ too X-Git-Tag: bind10-1.1.0beta1-release~23^2~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=01e052f372b1878b9bc40bfcea80d37e408a58ca;p=thirdparty%2Fkea.git [2835] Test the names in C++ too Test the names of the data sources in client lists in the C++ code as well as in the configuration checker. --- diff --git a/src/lib/datasrc/client_list.h b/src/lib/datasrc/client_list.h index d1a35b5481..3cfe1b99df 100644 --- a/src/lib/datasrc/client_list.h +++ b/src/lib/datasrc/client_list.h @@ -350,6 +350,7 @@ public: const DataSourceClient* getCacheClient() const; boost::shared_ptr cache_; boost::shared_ptr ztable_segment_; + std::string name_; }; /// \brief The collection of data sources. diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc index 3d7813822e..9365d30ffc 100644 --- a/src/lib/datasrc/tests/client_list_unittest.cc +++ b/src/lib/datasrc/tests/client_list_unittest.cc @@ -834,6 +834,54 @@ TEST_F(ListTest, masterFiles) { EXPECT_EQ(0, list_->getDataSources().size()); } +// Test the names are set correctly and collission is detected. +TEST_F(ListTest, names) { + // Explicit name + const ConstElementPtr elem1(Element::fromJSON("[" + "{" + " \"type\": \"MasterFiles\"," + " \"cache-enable\": true," + " \"params\": {" + " \".\": \"" TEST_DATA_DIR "/root.zone\"" + " }," + " \"name\": \"Whatever\"" + "}]")); + list_->configure(elem1, true); + EXPECT_EQ("Whatever", list_->getDataSources()[0].name_); + + // Default name + const ConstElementPtr elem2(Element::fromJSON("[" + "{" + " \"type\": \"MasterFiles\"," + " \"cache-enable\": true," + " \"params\": {" + " \".\": \"" TEST_DATA_DIR "/root.zone\"" + " }" + "}]")); + list_->configure(elem2, true); + EXPECT_EQ("MasterFiles", list_->getDataSources()[0].name_); + + // Collission + const ConstElementPtr elem3(Element::fromJSON("[" + "{" + " \"type\": \"MasterFiles\"," + " \"cache-enable\": true," + " \"params\": {" + " \".\": \"" TEST_DATA_DIR "/root.zone\"" + " }" + "}," + "{" + " \"type\": \"MasterFiles\"," + " \"cache-enable\": true," + " \"params\": {" + " \".\": \"" TEST_DATA_DIR "/root.zone\"" + " }," + " \"name\": \"MasterFiles\"" + "}]")); + EXPECT_THROW(list_->configure(elem3, true), + ConfigurableClientList::ConfigurationError); +} + TEST_F(ListTest, BadMasterFile) { // Configuration should succeed, and the good zones in the list // below should be loaded. No bad zones should be loaded.