mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 14:50:05 +00:00
Fixing warnings provider test
This commit is contained in:
parent
87af6479d6
commit
549f7ece61
1 changed files with 9 additions and 35 deletions
|
|
@ -13,53 +13,27 @@ static const std::string& kAlternateUrl {"https://warnings.cod.edu"};
|
||||||
class WarningsProviderTest : public testing::TestWithParam<std::string>
|
class WarningsProviderTest : public testing::TestWithParam<std::string>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
TEST_P(WarningsProviderTest, ListFiles)
|
|
||||||
{
|
|
||||||
WarningsProvider provider(GetParam());
|
|
||||||
|
|
||||||
auto [newObjects, totalObjects] = provider.ListFiles();
|
|
||||||
|
|
||||||
// No objects, skip test
|
|
||||||
if (totalObjects == 0)
|
|
||||||
{
|
|
||||||
GTEST_SKIP();
|
|
||||||
}
|
|
||||||
|
|
||||||
EXPECT_GT(newObjects, 0);
|
|
||||||
EXPECT_GT(totalObjects, 0);
|
|
||||||
EXPECT_EQ(newObjects, totalObjects);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_P(WarningsProviderTest, LoadUpdatedFiles)
|
TEST_P(WarningsProviderTest, LoadUpdatedFiles)
|
||||||
{
|
{
|
||||||
WarningsProvider provider(GetParam());
|
WarningsProvider provider(GetParam());
|
||||||
|
|
||||||
auto [newObjects, totalObjects] = provider.ListFiles();
|
std::chrono::sys_time<std::chrono::hours> now =
|
||||||
auto updatedFiles = provider.LoadUpdatedFiles();
|
std::chrono::floor<std::chrono::hours>(std::chrono::system_clock::now());
|
||||||
|
std::chrono::sys_time<std::chrono::hours> startTime =
|
||||||
|
now - std::chrono::days {3};
|
||||||
|
|
||||||
|
auto updatedFiles = provider.LoadUpdatedFiles(startTime);
|
||||||
|
|
||||||
// No objects, skip test
|
// No objects, skip test
|
||||||
if (totalObjects == 0)
|
if (updatedFiles.empty())
|
||||||
{
|
{
|
||||||
GTEST_SKIP();
|
GTEST_SKIP();
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_GT(newObjects, 0);
|
EXPECT_GT(updatedFiles.size(), 0);
|
||||||
EXPECT_GT(totalObjects, 0);
|
|
||||||
EXPECT_EQ(newObjects, totalObjects);
|
|
||||||
EXPECT_EQ(updatedFiles.size(), newObjects);
|
|
||||||
|
|
||||||
auto [newObjects2, totalObjects2] = provider.ListFiles();
|
|
||||||
auto updatedFiles2 = provider.LoadUpdatedFiles();
|
auto updatedFiles2 = provider.LoadUpdatedFiles();
|
||||||
|
|
||||||
// There should be no more than 2 updated warnings files since the last query
|
|
||||||
// (assumption that the previous newest file was updated, and a new file was
|
|
||||||
// created on the hour)
|
|
||||||
EXPECT_LE(newObjects2, 2);
|
|
||||||
EXPECT_EQ(updatedFiles2.size(), newObjects2);
|
|
||||||
|
|
||||||
// The total number of objects may have changed, since the oldest file could
|
|
||||||
// have dropped off the list
|
|
||||||
EXPECT_GT(totalObjects2, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(WarningsProvider,
|
INSTANTIATE_TEST_SUITE_P(WarningsProvider,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue