Browse Source

[2108] Add tests for duplicate types in load()

Mukund Sivaraman 12 years ago
parent
commit
b9c899265d

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

@@ -221,6 +221,19 @@ TEST_F(MemoryClientTest, loadReloadZone) {
     // Teardown checks for memory segment leaks
 }
 
+TEST_F(MemoryClientTest, loadDuplicateType) {
+    // This should not result in any exceptions:
+    client_->load(Name("example.org"),
+                  TEST_DATA_DIR "/example.org-duplicate-type.zone");
+
+    // This should throw:
+    EXPECT_THROW(client_->load(Name("example.org"),
+                               TEST_DATA_DIR
+                               "/example.org-duplicate-type-bad.zone"),
+                 InMemoryClient::AddError);
+    // Teardown checks for memory segment leaks
+}
+
 TEST_F(MemoryClientTest, loadRRSIGFollowsNothing) {
     EXPECT_THROW(client_->load(Name("example.org"),
                                TEST_DATA_DIR

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

@@ -9,3 +9,5 @@ EXTRA_DIST += example.org-rrsig-follows-nothing.zone
 EXTRA_DIST += example.org-rrsig-name-unmatched.zone
 EXTRA_DIST += example.org-rrsig-type-unmatched.zone
 EXTRA_DIST += example.org-rrsigs.zone
+EXTRA_DIST += example.org-duplicate-type.zone
+EXTRA_DIST += example.org-duplicate-type-bad.zone

+ 4 - 0
src/lib/datasrc/memory/tests/testdata/example.org-duplicate-type-bad.zone

@@ -0,0 +1,4 @@
+example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 77 3600 300 3600000 3600
+ns1.example.org.		      3600 IN A	 	192.168.0.1
+ns1.example.org.		      3600 IN AAAA 	::1
+ns1.example.org.		      3600 IN A	 	192.168.0.2

+ 4 - 0
src/lib/datasrc/memory/tests/testdata/example.org-duplicate-type.zone

@@ -0,0 +1,4 @@
+example.org. 3600 IN SOA	ns1.example.org. bugs.x.w.example.org. 76 3600 300 3600000 3600
+ns1.example.org.		      3600 IN A	 	192.168.0.1
+ns1.example.org.		      3600 IN A	 	192.168.0.2
+ns1.example.org.		      3600 IN AAAA 	::1