From 197a78a8e284a726495c4379fb652b1f2a5ef01c Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 13 Nov 2018 02:52:53 +0200 Subject: [test] Add test for when requesting the same resource many times This test would have prevented the crash fixed by the previous patch. --- test/storage/online_file_source.test.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/storage/online_file_source.test.cpp b/test/storage/online_file_source.test.cpp index 5021a513e3..39582543ef 100644 --- a/test/storage/online_file_source.test.cpp +++ b/test/storage/online_file_source.test.cpp @@ -515,4 +515,22 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(LowHighPriorityRequestsMany)) { NetworkStatus::Set(NetworkStatus::Status::Online); loop.run(); -} \ No newline at end of file +} + +TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RequestSameUrlMultipleTimes)) { + util::RunLoop loop; + OnlineFileSource fs; + + int count = 0; + std::vector> requests; + + for (int i = 0; i < 100; ++i) { + requests.emplace_back(fs.request({ Resource::Unknown, "http://127.0.0.1:3000/load" }, [&](Response) { + if (++count == 100) { + loop.stop(); + } + })); + } + + loop.run(); +} -- cgit v1.2.1