[tests] Add test to enforce database not found behavior

Make sure all the implementations, currently Qt and Default, throw
an exception with error code CANTOPEN when opening a database that
doesn't exist without the CREATE flag.
This commit is contained in:
Thiago Marcos P. Santos
2017-07-14 16:52:48 +03:00
parent d9ad09ca36
commit 544d875445

View File

@@ -25,3 +25,14 @@ TEST(SQLite, Statement) {
ASSERT_EQ(stmt2.lastInsertRowId(), 2);
ASSERT_EQ(stmt2.changes(), 1u);
}
TEST(SQLite, TEST_REQUIRES_WRITE(CantOpenException)) {
try {
// Should throw a CANTOPEN when the database doesn't exist,
// make sure all the backends behave the same way.
mapbox::sqlite::Database("test/fixtures/offline_database/foobar123.db", mapbox::sqlite::ReadOnly);
FAIL();
} catch (mapbox::sqlite::Exception& ex) {
ASSERT_EQ(ex.code, mapbox::sqlite::Exception::Code::CANTOPEN);
}
}