summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-10 15:15:05 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-10 15:40:20 -0800
commit40ecdeb0b60a7dfd15339ce9e0e851ce209b5da1 (patch)
tree5a9ac032ab2fe4361e497a04591cea7cb120254c /test
parent0cf450e3e529423737c6b4aa196b271442530345 (diff)
downloadqtlocation-mapboxgl-40ecdeb0b60a7dfd15339ce9e0e851ce209b5da1.tar.gz
[core] Optimize offline database schema
* Under the hood, SQLite creates surrogate keys (ROWID) anyway. We may as well take advantage of this and use the surrogates for foreign keys as well, since they are simpler and more efficient than compound foreign keys. * Create indexes for efficient eviction queries
Diffstat (limited to 'test')
-rw-r--r--test/storage/offline_database.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/test/storage/offline_database.cpp b/test/storage/offline_database.cpp
index e4a5381d21..3a731e3995 100644
--- a/test/storage/offline_database.cpp
+++ b/test/storage/offline_database.cpp
@@ -517,23 +517,24 @@ TEST(OfflineDatabase, PutReturnsSize) {
TEST(OfflineDatabase, PutEvictsLeastRecentlyUsedResources) {
using namespace mbgl;
- OfflineDatabase db(":memory:", 1024 * 20);
+ OfflineDatabase db(":memory:", 1024 * 25);
Response response;
response.data = randomString(1024);
for (uint32_t i = 1; i <= 20; i++) {
- db.put(Resource::style("http://example.com/"s + util::toString(i)), response);
+ Resource resource = Resource::style("http://example.com/"s + util::toString(i));
+ db.put(resource, response);
+ EXPECT_TRUE(bool(db.get(resource))) << i;
}
EXPECT_FALSE(bool(db.get(Resource::style("http://example.com/1"))));
- EXPECT_TRUE(bool(db.get(Resource::style("http://example.com/20"))));
}
TEST(OfflineDatabase, PutRegionResourceDoesNotEvict) {
using namespace mbgl;
- OfflineDatabase db(":memory:", 1024 * 20);
+ OfflineDatabase db(":memory:", 1024 * 25);
OfflineRegionDefinition definition { "", LatLngBounds::world(), 0, INFINITY, 1.0 };
OfflineRegion region = db.createRegion(definition, OfflineRegionMetadata());
@@ -552,7 +553,7 @@ TEST(OfflineDatabase, PutFailsWhenEvictionInsuffices) {
using namespace mbgl;
Log::setObserver(std::make_unique<FixtureLogObserver>());
- OfflineDatabase db(":memory:", 1024 * 20);
+ OfflineDatabase db(":memory:", 1024 * 25);
Response small;
small.data = randomString(1024);