summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-23 18:02:52 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-24 13:38:14 -0800
commit5cefaeb85716b21f2bbe57165a244844114b8dbe (patch)
tree33bdf56b0dc6c107e514dd7acb036e7e6e6b1479 /test
parent1bdeddab2cbda01117fac756367f76526b14bb9e (diff)
downloadqtlocation-mapboxgl-5cefaeb85716b21f2bbe57165a244844114b8dbe.tar.gz
[core] Enforce foreign key constraints in the offline database
Diffstat (limited to 'test')
-rw-r--r--test/storage/offline_database.cpp10
-rw-r--r--test/storage/offline_download.cpp33
2 files changed, 33 insertions, 10 deletions
diff --git a/test/storage/offline_database.cpp b/test/storage/offline_database.cpp
index 563c6f31dc..d93945fb40 100644
--- a/test/storage/offline_database.cpp
+++ b/test/storage/offline_database.cpp
@@ -461,7 +461,15 @@ TEST(OfflineDatabase, DeleteRegion) {
OfflineDatabase db(":memory:");
OfflineRegionDefinition definition { "http://example.com/style", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 2.0 };
OfflineRegionMetadata metadata {{ 1, 2, 3 }};
- db.deleteRegion(db.createRegion(definition, metadata));
+ OfflineRegion region = db.createRegion(definition, metadata);
+
+ Response response;
+ response.noContent = true;
+
+ db.putRegionResource(region.getID(), Resource::style("http://example.com/"), response);
+ db.putRegionResource(region.getID(), Resource::tile("http://example.com/", 1.0, 0, 0, 0), response);
+
+ db.deleteRegion(std::move(region));
ASSERT_EQ(0, db.listRegions().size());
}
diff --git a/test/storage/offline_download.cpp b/test/storage/offline_download.cpp
index 33c9c5a95d..73a6f80fcc 100644
--- a/test/storage/offline_download.cpp
+++ b/test/storage/offline_download.cpp
@@ -35,6 +35,12 @@ public:
OfflineDatabase db { ":memory:" };
std::size_t size = 0;
+ OfflineRegion createRegion() {
+ OfflineRegionDefinition definition { "", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 1.0 };
+ OfflineRegionMetadata metadata;
+ return db.createRegion(definition, metadata);
+ }
+
Response response(const std::string& path) {
Response result;
result.data = std::make_shared<std::string>(util::read_file("test/fixtures/"s + path));
@@ -47,8 +53,9 @@ public:
TEST(OfflineDownload, NoSubresources) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
@@ -76,8 +83,9 @@ TEST(OfflineDownload, NoSubresources) {
TEST(OfflineDownload, InlineSource) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
@@ -115,8 +123,9 @@ TEST(OfflineDownload, InlineSource) {
TEST(OfflineDownload, GeoJSONSource) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
@@ -149,8 +158,9 @@ TEST(OfflineDownload, GeoJSONSource) {
TEST(OfflineDownload, Activate) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
@@ -214,8 +224,9 @@ TEST(OfflineDownload, Activate) {
TEST(OfflineDownload, GetStatusNoResources) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
OfflineRegionStatus status = download.getStatus();
@@ -230,8 +241,9 @@ TEST(OfflineDownload, GetStatusNoResources) {
TEST(OfflineDownload, GetStatusStyleComplete) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
@@ -251,8 +263,9 @@ TEST(OfflineDownload, GetStatusStyleComplete) {
TEST(OfflineDownload, GetStatusStyleAndSourceComplete) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
@@ -276,8 +289,9 @@ TEST(OfflineDownload, GetStatusStyleAndSourceComplete) {
TEST(OfflineDownload, RequestError) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);
@@ -303,8 +317,9 @@ TEST(OfflineDownload, RequestError) {
TEST(OfflineDownload, RequestErrorsAreRetried) {
OfflineTest test;
+ OfflineRegion region = test.createRegion();
OfflineDownload download(
- 1,
+ region.getID(),
OfflineTilePyramidRegionDefinition("http://127.0.0.1:3000/offline/style.json", LatLngBounds::world(), 0.0, 0.0, 1.0),
test.db, test.fileSource);