summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-03-17 17:43:57 -0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-03-17 23:57:28 -0300
commit0e201eb23d6ae174599c0df5c41eb06fbdd586e0 (patch)
tree8f222161a727aebcae1577198b702b2ad9829cfa /test
parent0c3247bf3c09603829412f8d8f8a32a107886844 (diff)
downloadqtlocation-mapboxgl-0e201eb23d6ae174599c0df5c41eb06fbdd586e0.tar.gz
[tests] Add utest to make sure prior expiration time is being respected
Diffstat (limited to 'test')
-rw-r--r--test/storage/http_expires.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/storage/http_expires.cpp b/test/storage/http_expires.cpp
index 676e15da4f..0a2f610e46 100644
--- a/test/storage/http_expires.cpp
+++ b/test/storage/http_expires.cpp
@@ -68,3 +68,38 @@ TEST_F(Storage, HTTPRetryOnClockSkew) {
HTTPRetryOnClockSkew.finish();
}
+
+TEST_F(Storage, HTTPRespectPriorExpires) {
+ SCOPED_TEST(HTTPRespectPriorExpires)
+
+ using namespace mbgl;
+
+ util::RunLoop loop;
+ DefaultFileSource fs(":memory:", ".");
+
+ // Very long expiration time, should never arrive.
+ Resource resource1{ Resource::Unknown, "http://127.0.0.1:3000/test" };
+ resource1.priorExpires = SystemClock::now() + Seconds(100000);
+
+ std::unique_ptr<FileRequest> req1 = fs.request(resource1, [&](Response) {
+ FAIL() << "Should never be called";
+ });
+
+ // No expiration time, should be requested immediately.
+ Resource resource2{ Resource::Unknown, "http://127.0.0.1:3000/test" };
+
+ std::unique_ptr<FileRequest> req2 = fs.request(resource2, [&](Response) {
+ HTTPRespectPriorExpires.finish();
+ loop.stop();
+ });
+
+ // Very long expiration time, should never arrive.
+ Resource resource3{ Resource::Unknown, "http://127.0.0.1:3000/test" };
+ resource3.priorExpires = SystemClock::now() + Seconds(100000);
+
+ std::unique_ptr<FileRequest> req3 = fs.request(resource3, [&](Response) {
+ FAIL() << "Should never be called";
+ });
+
+ loop.run();
+}