summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-21 17:32:28 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2020-04-22 19:21:56 +0300
commit3bebd13d2e622b5c0c923747697044283945114c (patch)
treed90415692d381d28381aa41f33088340e26cbffd /test
parenteac6bdff16af09f8b3fc2f6d4a5bb781862b0f18 (diff)
downloadqtlocation-mapboxgl-3bebd13d2e622b5c0c923747697044283945114c.tar.gz
[core] Add Resource::StoragePolicy and consider it in resource loader
Diffstat (limited to 'test')
-rw-r--r--test/storage/main_resource_loader.test.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/storage/main_resource_loader.test.cpp b/test/storage/main_resource_loader.test.cpp
index 1bab30e1f8..9534aaa3fc 100644
--- a/test/storage/main_resource_loader.test.cpp
+++ b/test/storage/main_resource_loader.test.cpp
@@ -52,6 +52,33 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheResponse)) {
loop.run();
}
+TEST(MainResourceLoader, TEST_REQUIRES_SERVER(VolatileStoragePolicy)) {
+ util::RunLoop loop;
+ MainResourceLoader fs(ResourceOptions{});
+
+ Resource resource{Resource::Unknown, "http://127.0.0.1:3000/cache"};
+ resource.storagePolicy = Resource::StoragePolicy::Volatile;
+
+ std::unique_ptr<AsyncRequest> req;
+ req = fs.request(resource, [&](Response res1) {
+ EXPECT_EQ(nullptr, res1.error);
+ ASSERT_TRUE(res1.data);
+ std::string firstData = *res1.data;
+
+ // Volatile resources are not stored in cache,
+ // so we always get new data from the server ("Response N+1").
+ req = fs.request(resource, [&](Response res2) {
+ req.reset();
+ EXPECT_EQ(nullptr, res2.error);
+ ASSERT_TRUE(res2.data);
+ EXPECT_NE(firstData, *res2.data);
+ loop.stop();
+ });
+ });
+
+ loop.run();
+}
+
TEST(MainResourceLoader, TEST_REQUIRES_SERVER(CacheRevalidateSame)) {
util::RunLoop loop;
MainResourceLoader fs(ResourceOptions{});