mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Minor new unit tests for backups and database busy timeout
This commit is contained in:
parent
ef26cf09a1
commit
69d9b0805c
@ -31,6 +31,7 @@ Backup::Backup(Database& aDestDatabase,
|
||||
apSrcDatabaseName);
|
||||
if (NULL == mpSQLiteBackup)
|
||||
{
|
||||
// If an error occurs, the error code and message are attached to the destination database connection.
|
||||
throw SQLite::Exception(aDestDatabase.getHandle());
|
||||
}
|
||||
}
|
||||
@ -48,6 +49,7 @@ Backup::Backup(Database& aDestDatabase,
|
||||
aSrcDatabaseName.c_str());
|
||||
if (NULL == mpSQLiteBackup)
|
||||
{
|
||||
// If an error occurs, the error code and message are attached to the destination database connection.
|
||||
throw SQLite::Exception(aDestDatabase.getHandle());
|
||||
}
|
||||
}
|
||||
@ -62,6 +64,7 @@ Backup::Backup(Database &aDestDatabase, Database &aSrcDatabase) :
|
||||
"main");
|
||||
if (NULL == mpSQLiteBackup)
|
||||
{
|
||||
// If an error occurs, the error code and message are attached to the destination database connection.
|
||||
throw SQLite::Exception(aDestDatabase.getHandle());
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,16 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
TEST(Backup, initException) {
|
||||
remove("backup_test.db3");
|
||||
SQLite::Database srcDB("backup_test.db3", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
|
||||
srcDB.exec("CREATE TABLE backup_test (id INTEGER PRIMARY KEY, value TEXT)");
|
||||
ASSERT_EQ(1, srcDB.exec("INSERT INTO backup_test VALUES (1, \"first\")"));
|
||||
ASSERT_EQ(1, srcDB.exec("INSERT INTO backup_test VALUES (2, \"second\")"));
|
||||
EXPECT_THROW(SQLite::Backup backup(srcDB, "src", srcDB, "src"), SQLite::Exception);
|
||||
remove("backup_test.db3");
|
||||
}
|
||||
|
||||
TEST(Backup, executeStep) {
|
||||
remove("backup_test.db3");
|
||||
remove("backup_test.db3.backup");
|
||||
|
@ -114,6 +114,16 @@ TEST(Database, busyTimeout) {
|
||||
SQLite::Database db(":memory:", SQLITE_OPEN_READWRITE, 5000);
|
||||
EXPECT_EQ(5000, db.execAndGet("PRAGMA busy_timeout").getInt());
|
||||
|
||||
// Reset timeout to null
|
||||
db.setBusyTimeout(0);
|
||||
EXPECT_EQ(0, db.execAndGet("PRAGMA busy_timeout").getInt());
|
||||
}
|
||||
{
|
||||
// Create a new database with a non null busy timeout
|
||||
const std::string memory = ":memory:";
|
||||
SQLite::Database db(memory, SQLITE_OPEN_READWRITE, 5000);
|
||||
EXPECT_EQ(5000, db.execAndGet("PRAGMA busy_timeout").getInt());
|
||||
|
||||
// Reset timeout to null
|
||||
db.setBusyTimeout(0);
|
||||
EXPECT_EQ(0, db.execAndGet("PRAGMA busy_timeout").getInt());
|
||||
@ -234,3 +244,4 @@ TEST(Database, execException) {
|
||||
}
|
||||
|
||||
// TODO: test Database::createFunction()
|
||||
// TODO: test Database::loadExtension()
|
||||
|
Loading…
x
Reference in New Issue
Block a user