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 15:18:01 +0300 |
commit | a9b30200aec6b7b3f4a9d387efd6eb709f89fc9b (patch) | |
tree | 47deb57f4d923afa82e0ddd7ee4ec281484a5038 | |
parent | d0cda490f32aa027d4d04e78185fa262dc8c7777 (diff) | |
download | qtlocation-mapboxgl-upstream/tmpsantos-qt_database.tar.gz |
[tests] Add test to enforce database not found behaviorupstream/tmpsantos-qt_database
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.
-rw-r--r-- | test/storage/sqlite.test.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/storage/sqlite.test.cpp b/test/storage/sqlite.test.cpp index dbd7a09868..5888e8d2e9 100644 --- a/test/storage/sqlite.test.cpp +++ b/test/storage/sqlite.test.cpp @@ -25,3 +25,16 @@ TEST(SQLite, Statement) { ASSERT_EQ(stmt2.lastInsertRowId(), 2); ASSERT_EQ(stmt2.changes(), 1u); } + +TEST(SQLite, TEST_REQUIRES_WRITE(CantOpenException)) { + using namespace mbgl; + + 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); + } +} |