From 2b44c4b096bbe49d2d1d7c3e17f7e7fee825cb41 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Mon, 22 Feb 2016 19:43:25 +0200 Subject: [tests] Add utests for HTTP 200 with no data The implementation should return a valid empty string. --- test/storage/http_reading.cpp | 25 +++++++++++++++++++++++++ test/storage/server.js | 4 ++++ 2 files changed, 29 insertions(+) (limited to 'test') diff --git a/test/storage/http_reading.cpp b/test/storage/http_reading.cpp index b8e474ee43..fdc49ee5e6 100644 --- a/test/storage/http_reading.cpp +++ b/test/storage/http_reading.cpp @@ -84,6 +84,31 @@ TEST_F(Storage, HTTPTile404) { loop.run(); } +TEST_F(Storage, HTTP200EmptyData) { + SCOPED_TEST(HTTP200EmptyData) + + using namespace mbgl; + + util::RunLoop loop; + OnlineFileSource fs; + + std::unique_ptr req = fs.request({ Resource::Unknown, "http://127.0.0.1:3000/empty-data" }, + [&](Response res) { + req.reset(); + EXPECT_TRUE(util::ThreadContext::currentlyOn(util::ThreadType::Main)); + EXPECT_FALSE(res.noContent); + EXPECT_FALSE(bool(res.error)); + EXPECT_EQ(*res.data, std::string()); + EXPECT_FALSE(bool(res.expires)); + EXPECT_FALSE(bool(res.modified)); + EXPECT_FALSE(bool(res.etag)); + loop.stop(); + HTTP200EmptyData.finish(); + }); + + loop.run(); +} + TEST_F(Storage, HTTP204) { SCOPED_TEST(HTTP204) diff --git a/test/storage/server.js b/test/storage/server.js index 16b507daa9..d15544a0fd 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('/empty-data', function(req, res) { + res.status(200).send(); +}); + app.get('/no-content', function(req, res) { res.status(204).send(); }); -- cgit v1.2.1