Browse Source

[1177] Test for the SQLite3 find previous

Michal 'vorner' Vaner 13 years ago
parent
commit
f8720ba467
2 changed files with 18 additions and 2 deletions
  1. 2 2
      src/lib/datasrc/database.h
  2. 16 0
      src/lib/datasrc/tests/sqlite3_accessor_unittest.cc

+ 2 - 2
src/lib/datasrc/database.h

@@ -481,7 +481,7 @@ public:
      * This is used in DatabaseClient::findPreviousName and does more
      * or less the real work, except for working on strings.
      *
-     * \param name The name to ask for previous of.
+     * \param rname The name to ask for previous of, in reversed form.
      * \param zone_id The zone to look through.
      * \return The previous name.
      *
@@ -489,7 +489,7 @@ public:
      * \throw NotImplemented if this database doesn't support DNSSEC.
      */
     virtual std::string findPreviousName(int zone_id,
-                                         const std::string& name) const = 0;
+                                         const std::string& rname) const = 0;
 };
 
 /**

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

@@ -351,6 +351,22 @@ TEST_F(SQLite3AccessorTest, getRecords) {
     EXPECT_FALSE(context->getNext(columns));
 }
 
+TEST_F(SQLite3AccessorTest, findPrevious) {
+    EXPECT_EQ("dns01.example.com.",
+              accessor->findPreviousName(1, "com.example.dns02."));
+    // Wrap around
+    EXPECT_EQ("www.example.com.",
+              accessor->findPreviousName(1, "com.example."));
+}
+
+TEST_F(SQLite3AccessorTest, findPreviousNoData) {
+    // This one doesn't hold any NSEC records, so it shouldn't work
+    // The underlying DB/data don't support DNSSEC, so it's not implemented
+    // (does it make sense? Or different exception here?)
+    EXPECT_THROW(accessor->findPreviousName(3, "com.example."),
+                 isc::NotImplemented);
+}
+
 // Test fixture for creating a db that automatically deletes it before start,
 // and when done
 class SQLite3Create : public ::testing::Test {