diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-07-14 16:52:48 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-07-17 16:47:29 +0300 |
commit | 544d875445d80ae34317c13e31a33d9e80385b8f (patch) | |
tree | 2d284a9523846f51c759990ff4611ce1ea7e5a91 /test | |
parent | d9ad09ca364df52a316f644f908b7bb493093b48 (diff) | |
download | qtlocation-mapboxgl-544d875445d80ae34317c13e31a33d9e80385b8f.tar.gz |
[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.
Diffstat (limited to 'test')
-rw-r--r-- | test/storage/sqlite.test.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/storage/sqlite.test.cpp b/test/storage/sqlite.test.cpp index dbd7a09868..36715a2fd0 100644 --- a/test/storage/sqlite.test.cpp +++ b/test/storage/sqlite.test.cpp @@ -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); + } +} |