summaryrefslogtreecommitdiff
path: root/test/storage
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-02-05 16:52:07 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-10 15:40:20 -0800
commite9302c797f68c7e48b908b87b126045c8c5e5209 (patch)
tree044441cdb82ed8752401c43ead9e84018b067fbd /test/storage
parent7eb1a91c4e5134ecfbfb91b61a6622be40478af5 (diff)
downloadqtlocation-mapboxgl-e9302c797f68c7e48b908b87b126045c8c5e5209.tar.gz
[all] Don't interpret 404s on non-tile resources as "no content"
Diffstat (limited to 'test/storage')
-rw-r--r--test/storage/http_reading.cpp50
-rw-r--r--test/storage/offline_database.cpp14
-rwxr-xr-xtest/storage/server.js4
3 files changed, 61 insertions, 7 deletions
diff --git a/test/storage/http_reading.cpp b/test/storage/http_reading.cpp
index d360ec0031..b8e474ee43 100644
--- a/test/storage/http_reading.cpp
+++ b/test/storage/http_reading.cpp
@@ -59,6 +59,56 @@ TEST_F(Storage, HTTP404) {
loop.run();
}
+TEST_F(Storage, HTTPTile404) {
+ SCOPED_TEST(HTTPTile404)
+
+ using namespace mbgl;
+
+ util::RunLoop loop;
+ OnlineFileSource fs;
+
+ std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Tile, "http://127.0.0.1:3000/doesnotexist" },
+ [&](Response res) {
+ req2.reset();
+ EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main));
+ EXPECT_TRUE(res.noContent);
+ EXPECT_FALSE(bool(res.error));
+ EXPECT_FALSE(bool(res.data));
+ EXPECT_FALSE(bool(res.expires));
+ EXPECT_FALSE(bool(res.modified));
+ EXPECT_FALSE(bool(res.etag));
+ loop.stop();
+ HTTPTile404.finish();
+ });
+
+ loop.run();
+}
+
+TEST_F(Storage, HTTP204) {
+ SCOPED_TEST(HTTP204)
+
+ using namespace mbgl;
+
+ util::RunLoop loop;
+ OnlineFileSource fs;
+
+ std::unique_ptr<FileRequest> req2 = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/no-content" },
+ [&](Response res) {
+ req2.reset();
+ EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main));
+ EXPECT_TRUE(res.noContent);
+ EXPECT_FALSE(bool(res.error));
+ EXPECT_FALSE(bool(res.data));
+ EXPECT_FALSE(bool(res.expires));
+ EXPECT_FALSE(bool(res.modified));
+ EXPECT_FALSE(bool(res.etag));
+ loop.stop();
+ HTTP204.finish();
+ });
+
+ loop.run();
+}
+
TEST_F(Storage, HTTP500) {
SCOPED_TEST(HTTP500)
diff --git a/test/storage/offline_database.cpp b/test/storage/offline_database.cpp
index e2e32ee36b..1c43506066 100644
--- a/test/storage/offline_database.cpp
+++ b/test/storage/offline_database.cpp
@@ -334,19 +334,19 @@ TEST(OfflineDatabase, PutTile) {
EXPECT_EQ("data", *res->data);
}
-TEST(OfflineDatabase, PutResourceNotFound) {
+TEST(OfflineDatabase, PutResourceNoContent) {
using namespace mbgl;
OfflineDatabase db(":memory:");
Resource resource { Resource::Style, "http://example.com/" };
Response response;
- response.error = std::make_unique<Response::Error>(Response::Error::Reason::NotFound);
+ response.noContent = true;
db.put(resource, response);
auto res = db.get(resource);
- EXPECT_NE(nullptr, res->error);
- EXPECT_EQ(Response::Error::Reason::NotFound, res->error->reason);
+ EXPECT_EQ(nullptr, res->error);
+ EXPECT_TRUE(res->noContent);
EXPECT_FALSE(res->data.get());
}
@@ -364,11 +364,11 @@ TEST(OfflineDatabase, PutTileNotFound) {
0
};
Response response;
- response.error = std::make_unique<Response::Error>(Response::Error::Reason::NotFound);
+ response.noContent = true;
db.put(resource, response);
auto res = db.get(resource);
- EXPECT_NE(nullptr, res->error);
- EXPECT_EQ(Response::Error::Reason::NotFound, res->error->reason);
+ EXPECT_EQ(nullptr, res->error);
+ EXPECT_TRUE(res->noContent);
EXPECT_FALSE(res->data.get());
}
diff --git a/test/storage/server.js b/test/storage/server.js
index 0024330037..16b507daa9 100755
--- a/test/storage/server.js
+++ b/test/storage/server.js
@@ -84,6 +84,10 @@ app.get('/revalidate-etag', function(req, res) {
revalidateEtagCounter++;
});
+app.get('/no-content', function(req, res) {
+ res.status(204).send();
+});
+
app.get('/not-found', function(req, res) {
res.status(404).send('Not Found!');
});