Parcourir la source

[2108] Add a basic InMemoryClient::load() test

Mukund Sivaraman il y a 12 ans
Parent
commit
0523c84f2a

+ 1 - 0
src/lib/datasrc/memory/tests/Makefile.am

@@ -1,6 +1,7 @@
 AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
 AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
 AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/lib/dns
 AM_CPPFLAGS += -I$(top_builddir)/src/lib/dns -I$(top_srcdir)/src/lib/dns
 AM_CPPFLAGS += $(BOOST_INCLUDES)
 AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += -DTEST_DATA_DIR=\"$(abs_srcdir)/testdata\"
 
 
 AM_CXXFLAGS = $(B10_CXXFLAGS)
 AM_CXXFLAGS = $(B10_CXXFLAGS)
 
 

+ 11 - 0
src/lib/datasrc/memory/tests/memory_client_unittest.cc

@@ -66,6 +66,17 @@ protected:
     memory::ZoneTable* zone_table;
     memory::ZoneTable* zone_table;
 };
 };
 
 
+TEST_F(MemoryClientTest, load) {
+    // Zone "example.org." doesn't exist
+    EXPECT_THROW(client_->getIterator(Name("example.org")), DataSourceError);
+    EXPECT_EQ(0, client_->getZoneCount());
+
+    client_->load(Name("example.org"), TEST_DATA_DIR "/example.org-empty.zone");
+    EXPECT_EQ(1, client_->getZoneCount());
+
+    ZoneIteratorPtr iterator(client_->getIterator(Name("example.org")));
+}
+
 TEST_F(MemoryClientTest, getIteratorNonExistent) {
 TEST_F(MemoryClientTest, getIteratorNonExistent) {
     // Zone "." doesn't exist
     // Zone "." doesn't exist
     EXPECT_THROW(client_->getIterator(Name(".")), DataSourceError);
     EXPECT_THROW(client_->getIterator(Name(".")), DataSourceError);

+ 3 - 0
src/lib/datasrc/memory/tests/testdata/Makefile.am

@@ -0,0 +1,3 @@
+CLEANFILES = *.copied
+
+EXTRA_DIST = example.org-empty.zone

+ 2 - 0
src/lib/datasrc/memory/tests/testdata/example.org-empty.zone

@@ -0,0 +1,2 @@
+;; empty example.org zone
+example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 68 3600 300 3600000 3600