Browse Source

fix a unittest issue

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac439@3945 e5f2f494-b856-4b98-b285-d166d9295462
Jerry 14 years ago
parent
commit
a8312db1d0
1 changed files with 17 additions and 2 deletions
  1. 17 2
      src/bin/auth/tests/auth_srv_unittest.cc

+ 17 - 2
src/bin/auth/tests/auth_srv_unittest.cc

@@ -47,11 +47,14 @@ using namespace asio_link;
 
 namespace {
 const char* const CONFIG_TESTDB =
-    "{\"database_file\": \"" TEST_DATA_DIR "/example.sqlite3\"}";
+    "{\"database_file\": \"" TEST_DATA_DIR "/example.sqlite3\", \"use_memory_datasrc\": false}";
+
+const char* const MEMORY_CONFIG_TESTDB =
+    "{\"database_file\": \"" TEST_DATA_DIR "/example.sqlite3\", \"use_memory_datasrc\": true}";
 // The following file must be non existent and must be non"creatable" (see
 // the sqlite3 test).
 const char* const BADCONFIG_TESTDB =
-    "{ \"database_file\": \"" TEST_DATA_DIR "/nodir/notexist\"}";
+    "{ \"database_file\": \"" TEST_DATA_DIR "/nodir/notexist\", \"use_memory_datasrc\": false}";
 const char* const DEFAULT_REMOTE_ADDRESS = "192.0.2.1";
 
 class AuthSrvTest : public ::testing::Test {
@@ -758,6 +761,18 @@ TEST_F(AuthSrvTest, updateConfigFail) {
                 QR_FLAG | AA_FLAG, 1, 1, 1, 0);
 }
 
+TEST_F(AuthSrvTest, useMemoryDataSrc) {
+    // First, load a memory data source.
+    updateConfig(&server, MEMORY_CONFIG_TESTDB, true);
+
+    // The memory data source is empty, should return SERVFAIL rcode.
+    createDataFromFile("examplequery_fromWire.wire");
+    EXPECT_TRUE(server.processMessage(*io_message, parse_message,
+                                      response_renderer));
+    headerCheck(parse_message, default_qid, Rcode::SERVFAIL(), opcode.getCode(),
+                QR_FLAG | AA_FLAG, 1, 0, 0, 0);
+}
+
 TEST_F(AuthSrvTest, cacheSlots) {
     // simple check for the get/set operations
     server.setCacheSlots(10);    // 10 = arbitrary choice