From a9b30200aec6b7b3f4a9d387efd6eb709f89fc9b Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 14 Jul 2017 16:52:48 +0300 Subject: [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. --- test/storage/sqlite.test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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); + } +} -- cgit v1.2.1