Commit 199269b8 authored by Paul Selkirk's avatar Paul Selkirk
Browse files

[2907] small improvement to unit test

parent a6f80229
......@@ -416,10 +416,11 @@ ConfigurableClientList::getZoneTableAccessor(const std::string& datasrc_name,
}
const internal::CacheConfig* config(info.getCacheConfig());
if (!config->isEnabled() && datasrc_name.empty())
if (!config->isEnabled() && datasrc_name.empty()) {
continue;
}
// If caching is disabled for the data source, this will
// If caching is disabled for the named data source, this will
// return an accessor to an effectivley empty table.
return (boost::shared_ptr<const ZoneTableAccessor>
(new internal::ZoneTableAccessorCache(*config)));
......
......@@ -493,7 +493,7 @@ public:
/// true.
/// \throw NotImplemented if \c use_cache is false.
/// \return A pointer to the accessor, or NULL if the requested data
/// source is not found or has its cache disabled.
/// source is not found.
boost::shared_ptr<const ZoneTableAccessor>
getZoneTableAccessor(const std::string& datasrc_name,
bool use_cache) const;
......
......@@ -255,7 +255,7 @@ public:
ConfigurableClientList::CacheStatus doReload(
const Name& origin, const string& datasrc_name = "");
void accessorIterate(boost::shared_ptr<const ZoneTableAccessor>accessor,
int numZones);
int numZones, const string& zoneName);
const RRClass rrclass_;
shared_ptr<TestedList> list_;
......@@ -1132,13 +1132,24 @@ TEST_F(ListTest, reloadByDataSourceName) {
void
ListTest::accessorIterate(boost::shared_ptr<const ZoneTableAccessor>accessor,
int numZones)
int numZones, const string& zoneName="")
{
// Confirm basic iterator behavior.
ZoneTableAccessor::IteratorPtr it = accessor->getIterator();
ASSERT_TRUE(it);
for (int i = 0; i < numZones; ++i) {
it->next();
if (numZones > 0) {
EXPECT_FALSE(it->isLast());
EXPECT_EQ(0, it->getCurrent().index);
// Iterator does not guarantee ordering, so we look for the target
// name anywhere in the table.
bool found = false;
for (int i = 0; i < numZones; ++i) {
if (Name(zoneName) == it->getCurrent().origin) {
found = true;
}
it->next();
}
EXPECT_TRUE(found);
}
EXPECT_TRUE(it->isLast());
}
......@@ -1163,7 +1174,7 @@ TEST_F(ListTest, zoneTableAccessor) {
list_->configure(config_elem_zones_, true);
EXPECT_THROW(list_->getZoneTableAccessor("", false), isc::NotImplemented);
EXPECT_THROW(list_->getZoneTableAccessor("type1", false),
isc::NotImplemented);
isc::NotImplemented);
const ConstElementPtr elem2(Element::fromJSON("["
"{"
......@@ -1197,11 +1208,11 @@ TEST_F(ListTest, zoneTableAccessor) {
// return first enabled datasrc
z = list_->getZoneTableAccessor("", true);
accessorIterate(z, 1);
accessorIterate(z, 1, "example.com");
// search by name
z = list_->getZoneTableAccessor("type3", true);
accessorIterate(z, 2);
accessorIterate(z, 2, "example.net");
}
// Check the status holds data
......
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