Parcourir la source

[1330] Add failing test to extract first RR from difference set

Stephen Morris il y a 13 ans
Parent
commit
480da1fe07

+ 22 - 0
src/lib/datasrc/tests/sqlite3_accessor_unittest.cc

@@ -229,8 +229,30 @@ TEST_F(SQLite3AccessorTest, diffIteratorNoVersion) {
     EXPECT_THROW(accessor->getDiffs(zone_info.second, 1231, 2234),
                  NoSuchSerial);
 
+}
+
+// Try to iterate through a valid set of differences
+TEST_F(SQLite3AccessorTest, validSequence) {
+
+    // Our test zone is conveniently small, but not empty
+    initAccessor(SQLITE_DBFILE_DIFFS, "IN");
 
+    const std::pair<bool, int> zone_info(accessor->getZone("example.org."));
+    ASSERT_TRUE(zone_info.first);
     // Get the iterator context
+    DatabaseAccessor::IteratorContextPtr
+        context(accessor->getDiffs(zone_info.second, 1230, 1232));
+    ASSERT_NE(DatabaseAccessor::IteratorContextPtr(), context);
+
+    std::string data[DatabaseAccessor::COLUMN_COUNT];
+
+    // Check the records
+    EXPECT_TRUE(context->getNext(data));
+    EXPECT_EQ("SOA", data[DatabaseAccessor::TYPE_COLUMN]);
+    EXPECT_EQ("3600", data[DatabaseAccessor::TTL_COLUMN]);
+    EXPECT_EQ("ns1.example.org. admin.example.org. 1230, 3600 1800 2419200 7200",
+        data[DatabaseAccessor::RDATA_COLUMN]);
+    EXPECT_EQ("example.org.", data[DatabaseAccessor::NAME_COLUMN]);
 }
 
 TEST(SQLite3Open, getDBNameExample2) {

BIN
src/lib/datasrc/tests/testdata/diffs.sqlite3


+ 10 - 10
src/lib/datasrc/tests/testdata/diffs_table.sql

@@ -45,14 +45,14 @@ CREATE TABLE diffs (id INTEGER PRIMARY KEY AUTOINCREMENT,
 -- Update one record in the zone.
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 4294967280,  0, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 4294967280 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 4294967280 3600 1800 2419200 7200");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 4294967280, 0, "www.example.org.", "A", 3600, "192.0.2.31");
 
 -- Records added in version 1230 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1230, 1, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 1230 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1230 3600 1800 2419200 7200");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1230, 1, "www.example.org.", "A", 3600, "192.0.2.21");
 
@@ -60,37 +60,37 @@ INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
 -- Records removed from version 1230 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1230, 0, "example.org.", "SOA", 1800,
-           "ns1.example.org. admin.example.org. 1230 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1230 3600 1800 2419200 7200");
 
 -- Records added in version 1231 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1231, 1, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 1231 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1231 3600 1800 2419200 7200");
 
 
 -- Change 1231 to 1232: Remove one record, don't add anything.
 -- Records removed from version 1231 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1231, 0, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 1231 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1231 3600 1800 2419200 7200");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1231, 0, "unused.example.org.", "A", 3600, "192.0.2.102");
 
 -- Records added in version 1232 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1232, 1, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 1232 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1232 3600 1800 2419200 7200");
 
 -- Change 1232 to 1233: Add two, don't remove anything.
 -- Records removed from version 1232 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1232, 0, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 1232 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1232 3600 1800 2419200 7200");
 
 -- Records added in version 1233 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1233, 1, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 1233 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1233 3600 1800 2419200 7200");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1233, 1, "sub.example.org.", "NS", 3600, "ns.sub.example.org.");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
@@ -101,7 +101,7 @@ INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
 -- Records removed from version 1233 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1233, 0, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 1233 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1233 3600 1800 2419200 7200");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1233, 0, "www.example.org.", "A", 3600, "192.0.2.21");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
@@ -110,7 +110,7 @@ INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
 -- Records added in version 1234 of the zone
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1234, 1, "example.org.", "SOA", 3600,
-           "ns1.example.org. admin.example.org. 1234 3600 1800 2419200, 7200");
+           "ns1.example.org. admin.example.org. 1234 3600 1800 2419200 7200");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
     VALUES(1, 1234, 1, "www.example.org.", "A", 3600, "192.0.2.1");
 INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)