[svn] commit: r1387 - in /trunk/src/lib/auth/tests: sqlite3_unittest.cc testdata/brokendb.sqlite3 testdata/mkbrokendb.c
BIND 10 source code commits
bind10-changes at lists.isc.org
Sat Mar 13 02:47:09 UTC 2010
Author: jinmei
Date: Sat Mar 13 02:47:09 2010
New Revision: 1387
Log:
exception guarantee test with a half-broken DB file. it currently fails,
so commented out.
Added:
trunk/src/lib/auth/tests/testdata/brokendb.sqlite3 (with props)
trunk/src/lib/auth/tests/testdata/mkbrokendb.c (with props)
Modified:
trunk/src/lib/auth/tests/sqlite3_unittest.cc
Modified: trunk/src/lib/auth/tests/sqlite3_unittest.cc
==============================================================================
--- trunk/src/lib/auth/tests/sqlite3_unittest.cc (original)
+++ trunk/src/lib/auth/tests/sqlite3_unittest.cc Sat Mar 13 02:47:09 2010
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
+#include <sqlite3.h>
#include <gtest/gtest.h>
#include <dns/name.h>
@@ -48,6 +49,11 @@
"{ \"database_file\": \"testdata/test2.sqlite3\"}");
ElementPtr SQLITE_DBFILE_EXAMPLE_ROOT = Element::createFromString(
"{ \"database_file\": \"testdata/test-root.sqlite3\"}");
+ElementPtr SQLITE_DBFILE_BROKENDB = Element::createFromString(
+ "{ \"database_file\": \"testdata/brokendb.sqlite3\"}");
+ElementPtr SQLITE_DBFILE_MEMORY = Element::createFromString(
+ "{ \"database_file\": \":memory:\"}");
+
// The following file must be non existent and must be non"creatable";
// the sqlite3 library will try to create a new DB file if it doesn't exist,
// so to test a failure case the create operation should also fail.
@@ -376,6 +382,24 @@
EXPECT_THROW(data_source.close(), DataSourceError);
}
+#if 0 // currently fails
+TEST_F(Sqlite3DataSourceTest, openBrokenDB) {
+ EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
+ // The database exists but is broken. An exception will be thrown
+ // in the middle of the initialization.
+ EXPECT_THROW(data_source.init(SQLITE_DBFILE_BROKENDB), Sqlite3Error);
+ // Confirming the strong exception guarantee: the data source must be
+ // in the closed state.
+ EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_EXAMPLE));
+}
+#endif
+
+// This test only confirms that on-the-fly schema creation works.
+TEST_F(Sqlite3DataSourceTest, memoryDB) {
+ EXPECT_EQ(DataSrc::SUCCESS, data_source.close());
+ EXPECT_EQ(DataSrc::SUCCESS, data_source.init(SQLITE_DBFILE_MEMORY));
+}
+
TEST_F(Sqlite3DataSourceTest, findClosestEnclosure) {
NameMatch name_match(www_name);
data_source.findClosestEnclosure(name_match, rrclass);
More information about the bind10-changes
mailing list