Browse Source

[1791] added a couple of more tests.

- confirm separating iterator triggers an exception as expected.
- try to load a bit more realistic zone with some trivial checks.
JINMEI Tatuya 13 years ago
parent
commit
d5531c9856
1 changed files with 21 additions and 1 deletions
  1. 21 1
      src/lib/datasrc/tests/memory_datasrc_unittest.cc

+ 21 - 1
src/lib/datasrc/tests/memory_datasrc_unittest.cc

@@ -1103,7 +1103,7 @@ TEST_F(InMemoryZoneFinderTest, load) {
 
 
     // Try loading zone that is wrong in a different way
     // Try loading zone that is wrong in a different way
     EXPECT_THROW(zone_finder_.load(TEST_DATA_DIR "/duplicate_rrset.zone"),
     EXPECT_THROW(zone_finder_.load(TEST_DATA_DIR "/duplicate_rrset.zone"),
-        MasterLoadError);
+                 MasterLoadError);
 }
 }
 
 
 TEST_F(InMemoryZoneFinderTest, loadFromIterator) {
 TEST_F(InMemoryZoneFinderTest, loadFromIterator) {
@@ -1147,6 +1147,26 @@ TEST_F(InMemoryZoneFinderTest, loadFromIterator) {
 
 
     // File name should be (re)set to empty.
     // File name should be (re)set to empty.
     EXPECT_TRUE(zone_finder_.getFileName().empty());
     EXPECT_TRUE(zone_finder_.getFileName().empty());
+
+    // Loading the zone with an iterator separating RRs of the same RRset
+    // will fail because the resulting sequence doesn't meet assumptions of
+    // the (current) in-memory implementation.
+    EXPECT_THROW(zone_finder_.load(*db_client->getIterator(origin_, true)),
+                 MasterLoadError);
+
+    // Load the zone from a file that contains more realistic data (borrowed
+    // from a different test).  There's nothing special in this case for the
+    // purpose of this test, so it should just succeed.
+    db_client = unittest::createSQLite3Client(
+        class_, origin_, TEST_DATA_BUILDDIR "/contexttest.sqlite3.copied",
+        TEST_DATA_DIR "/contexttest.zone");
+    zone_finder_.load(*db_client->getIterator(origin_));
+
+    // just checking a couple of RRs in the new version of zone.
+    findTest(Name("mx1.example.org"), RRType::A(), ZoneFinder::SUCCESS, true,
+             textToRRset("mx1.example.org. 3600 IN A 192.0.2.10"));
+    findTest(Name("ns1.example.org"), RRType::AAAA(), ZoneFinder::SUCCESS,
+             true, textToRRset("ns1.example.org. 3600 IN AAAA 2001:db8::1"));
 }
 }
 
 
 /*
 /*