core: ambient cache for pmtile sources (#4290)
This commit is contained in:
@@ -396,6 +396,22 @@ TEST(OfflineDatabase, PutTile) {
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
}
|
||||
|
||||
// Cache-key encoding for byte-range sources (eg. PMTiles). The range is appended
|
||||
// to the URL so distinct ranges occupy distinct cache rows under the resources
|
||||
// table's UNIQUE(url) constraint.
|
||||
TEST(OfflineDatabase, CacheKey) {
|
||||
Resource bare{Resource::Kind::Source, "https://example.com/x.pmtiles"};
|
||||
EXPECT_EQ("https://example.com/x.pmtiles", OfflineDatabase::cacheKey(bare));
|
||||
|
||||
Resource ranged{Resource::Kind::Source, "https://example.com/x.pmtiles"};
|
||||
ranged.dataRange = std::make_pair<uint64_t, uint64_t>(0, 126);
|
||||
EXPECT_EQ("https://example.com/x.pmtiles?_mlnRange=0-126", OfflineDatabase::cacheKey(ranged));
|
||||
|
||||
Resource rangedWithQuery{Resource::Kind::Source, "https://example.com/x.pmtiles?token=abc"};
|
||||
rangedWithQuery.dataRange = std::make_pair<uint64_t, uint64_t>(200, 399);
|
||||
EXPECT_EQ("https://example.com/x.pmtiles?token=abc&_mlnRange=200-399", OfflineDatabase::cacheKey(rangedWithQuery));
|
||||
}
|
||||
|
||||
TEST(OfflineDatabase, PutResourceNoContent) {
|
||||
FixtureLog log;
|
||||
OfflineDatabase db(":memory:", fixture::tileServerOptions);
|
||||
|
||||
Reference in New Issue
Block a user