diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-01-21 19:30:58 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-02-04 10:49:05 +0100 |
commit | 8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd (patch) | |
tree | e3f0e8f4b16071667c6a4fdf706740335500dbc6 /test/storage/cache_response.cpp | |
parent | 5503aef6907b1fea74d6bdbe696f02b9f016f752 (diff) | |
download | qtlocation-mapboxgl-8a1fce547e9ad0bf750418c844c9b23a3ee6d8dd.tar.gz |
rearrange tests and add storage tests
Diffstat (limited to 'test/storage/cache_response.cpp')
-rw-r--r-- | test/storage/cache_response.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/storage/cache_response.cpp b/test/storage/cache_response.cpp new file mode 100644 index 0000000000..c775647f77 --- /dev/null +++ b/test/storage/cache_response.cpp @@ -0,0 +1,39 @@ +#include "../util.hpp" + +#include <uv.h> + +#include <mbgl/storage/default/default_file_source.hpp> +#include <mbgl/storage/default/sqlite_cache.hpp> + +TEST(Storage, CacheResponse) { + SCOPED_TEST(CacheResponse); + + using namespace mbgl; + + SQLiteCache cache(":memory:"); + DefaultFileSource fs(&cache, uv_default_loop()); + + const Resource resource { Resource::Unknown, "http://127.0.0.1:3000/cache" }; + + fs.request(resource, uv_default_loop(), [&](const Response &res) { + EXPECT_EQ(res.status, Response::Successful); + EXPECT_EQ(res.data, "Response 1"); + EXPECT_GT(res.expires, 0); + EXPECT_EQ(res.modified, 0); + EXPECT_EQ(res.etag, ""); + EXPECT_EQ(res.message, ""); + + fs.request(resource, uv_default_loop(), [&, res](const Response &res2) { + EXPECT_EQ(res2.status, res.status); + EXPECT_EQ(res2.data, res.data); + EXPECT_EQ(res2.expires, res.expires); + EXPECT_EQ(res2.modified, res.modified); + EXPECT_EQ(res2.etag, res.etag); + EXPECT_EQ(res2.message, res.message); + + CacheResponse.finish(); + }); + }); + + uv_run(uv_default_loop(), UV_RUN_DEFAULT); +} |