diff options
Diffstat (limited to 'test/storage/http_load.cpp')
-rw-r--r-- | test/storage/http_load.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/test/storage/http_load.cpp b/test/storage/http_load.cpp index 2347a76ab4..fa0468a848 100644 --- a/test/storage/http_load.cpp +++ b/test/storage/http_load.cpp @@ -15,11 +15,15 @@ TEST_F(Storage, HTTPLoad) { const int max = 10000; int number = 1; - std::function<void()> req = [&]() { + Request* reqs[concurrency]; + + std::function<void(int)> req = [&](int i) { const auto current = number++; - fs.request({ Resource::Unknown, + reqs[i] = fs.request({ Resource::Unknown, std::string("http://127.0.0.1:3000/load/") + std::to_string(current) }, - uv_default_loop(), [&, current](const Response &res) { + uv_default_loop(), [&, i, current](const Response &res) { + fs.cancel(reqs[i]); + reqs[i] = nullptr; EXPECT_EQ(Response::Successful, res.status); EXPECT_EQ(std::string("Request ") + std::to_string(current), res.data); EXPECT_EQ(0, res.expires); @@ -28,7 +32,7 @@ TEST_F(Storage, HTTPLoad) { EXPECT_EQ("", res.message); if (number <= max) { - req(); + req(i); } else if (current == max) { HTTPLoad.finish(); } @@ -37,7 +41,7 @@ TEST_F(Storage, HTTPLoad) { for (int i = 0; i < concurrency; i++) { - req(); + req(i); } uv_run(uv_default_loop(), UV_RUN_DEFAULT); |