From ce11fc6cfeb157673befd6a00290e19d6522b01a Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Fri, 17 Apr 2020 17:44:45 +0300 Subject: Add OnlineFileSource.RespectMinimumUpdateInterval unit test --- test/storage/online_file_source.test.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/storage/online_file_source.test.cpp b/test/storage/online_file_source.test.cpp index 1bed5f9618..050b9d0f3f 100644 --- a/test/storage/online_file_source.test.cpp +++ b/test/storage/online_file_source.test.cpp @@ -217,6 +217,25 @@ TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectPriorExpires)) { loop.run(); } +TEST(OnlineFileSource, TEST_REQUIRES_SERVER(RespectMinimumUpdateInterval)) { + util::RunLoop loop; + std::unique_ptr fs = std::make_unique(); + + auto start = util::now(); + Resource resource{Resource::Unknown, "http://127.0.0.1:3000/test"}; + resource.priorExpires = start + std::chrono::duration_cast(Milliseconds(100)); + resource.minimumUpdateInterval = Seconds(1); + + std::unique_ptr req = fs->request(resource, [&](Response) { + auto wait = util::now() - start; + EXPECT_GE(wait, resource.minimumUpdateInterval); + EXPECT_LT(wait, resource.minimumUpdateInterval + Milliseconds(10)); + loop.stop(); + }); + + loop.run(); +} + TEST(OnlineFileSource, TEST_REQUIRES_SERVER(Load)) { util::RunLoop loop; std::unique_ptr fs = std::make_unique(); -- cgit v1.2.1