Commit 01e052f3 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

[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.
parent 25b99148
......@@ -350,6 +350,7 @@ public:
const DataSourceClient* getCacheClient() const;
boost::shared_ptr<memory::InMemoryClient> cache_;
boost::shared_ptr<memory::ZoneTableSegment> ztable_segment_;
std::string name_;
};
/// \brief The collection of data sources.
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment