Browse Source

[1177] Test for the previous name in DB

Michal 'vorner' Vaner 13 years ago
parent
commit
c5e0db2b7d
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/lib/datasrc/tests/database_unittest.cc

+ 13 - 0
src/lib/datasrc/tests/database_unittest.cc

@@ -171,6 +171,8 @@ const char* const TEST_RECORDS[][5] = {
     {"*.delegatedwild.example.org.", "A", "3600", "", "192.0.2.5"},
     {"wild.*.foo.example.org.", "A", "3600", "", "192.0.2.5"},
     {"wild.*.foo.*.bar.example.org.", "A", "3600", "", "192.0.2.5"},
+    // For finding previous, this one is the last one in the zone
+    {"zzz.example.org.", "NSEC", "3600", "", "example.org NSEC"},
 
     {NULL, NULL, NULL, NULL, NULL},
 };
@@ -2193,4 +2195,15 @@ TYPED_TEST(DatabaseClientTest, compoundUpdate) {
                ZoneFinder::SUCCESS, this->expected_rdatas_,
                this->empty_rdatas_);
 }
+
+TYPED_TEST(DatabaseClientTest, previous) {
+    shared_ptr<DatabaseClient::Finder> finder(this->getFinder());
+
+    EXPECT_EQ(Name("www.example.org."),
+              finder->findPreviousName(Name("www2.example.org.")));
+    // Check wrap around
+    EXPECT_EQ(Name("zzz.example.org."),
+              finder->findPreviousName(Name("example.org.")));
+}
+
 }