summaryrefslogtreecommitdiff
path: root/test/storage
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <tmpsantos@gmail.com>2017-08-21 17:58:36 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-08-22 12:46:38 +0300
commitbd15e273dce767458d335aeb1f50aa081390d593 (patch)
treec3e8b654953b78cb05e3d85692509963dd7e8e76 /test/storage
parent558d4b1a88c5b8367a073fc428b2843f28555d96 (diff)
downloadqtlocation-mapboxgl-bd15e273dce767458d335aeb1f50aa081390d593.tar.gz
[tests] Enforce the schema downgrade behavior
Which is, delete and recreate the database.
Diffstat (limited to 'test/storage')
-rw-r--r--test/storage/offline_database.test.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp
index c196107639..d99c1f946f 100644
--- a/test/storage/offline_database.test.cpp
+++ b/test/storage/offline_database.test.cpp
@@ -737,3 +737,27 @@ TEST(OfflineDatabase, MigrateFromV5Schema) {
"compressed", "accessed", "must_revalidate" }),
databaseTableColumns("test/fixtures/offline_database/migrated.db", "resources"));
}
+
+TEST(OfflineDatabase, DowngradeSchema) {
+ using namespace mbgl;
+
+ // v999.db is a v999 database, it should be deleted
+ // and recreated with the current schema.
+
+ deleteFile("test/fixtures/offline_database/migrated.db");
+ writeFile("test/fixtures/offline_database/migrated.db", util::read_file("test/fixtures/offline_database/v999.db"));
+
+ {
+ OfflineDatabase db("test/fixtures/offline_database/migrated.db", 0);
+ }
+
+ EXPECT_EQ(6, databaseUserVersion("test/fixtures/offline_database/migrated.db"));
+
+ EXPECT_EQ((std::vector<std::string>{ "id", "url_template", "pixel_ratio", "z", "x", "y",
+ "expires", "modified", "etag", "data", "compressed",
+ "accessed", "must_revalidate" }),
+ databaseTableColumns("test/fixtures/offline_database/migrated.db", "tiles"));
+ EXPECT_EQ((std::vector<std::string>{ "id", "url", "kind", "expires", "modified", "etag", "data",
+ "compressed", "accessed", "must_revalidate" }),
+ databaseTableColumns("test/fixtures/offline_database/migrated.db", "resources"));
+}