Fix tests

This commit is contained in:
alesapin 2021-02-16 20:47:12 +03:00
parent b029f3e5cf
commit b76b8013ba
2 changed files with 20 additions and 3 deletions

View File

@ -344,7 +344,6 @@ void Changelog::compact(size_t up_to_log_idx)
ChangelogName parsed_name = getChangelogName(itr->second); ChangelogName parsed_name = getChangelogName(itr->second);
if (parsed_name.to_log_idx <= up_to_log_idx) if (parsed_name.to_log_idx <= up_to_log_idx)
{ {
for (size_t idx = parsed_name.from_log_idx; idx <= parsed_name.to_log_idx; ++idx) for (size_t idx = parsed_name.from_log_idx; idx <= parsed_name.to_log_idx; ++idx)
{ {
auto index_pos = index_to_start_pos.find(idx); auto index_pos = index_to_start_pos.find(idx);

View File

@ -643,6 +643,15 @@ TEST(CoordinationTest, ChangelogTestWriteAtPreviousFile)
auto entry = getLogEntry(std::to_string(i) + "_hello_world", i * 10); auto entry = getLogEntry(std::to_string(i) + "_hello_world", i * 10);
changelog.appendEntry(changelog.getNextEntryIndex(), entry); changelog.appendEntry(changelog.getNextEntryIndex(), entry);
} }
EXPECT_TRUE(fs::exists("./logs/changelog_1_5.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_6_10.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_11_15.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_16_20.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_21_25.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_26_30.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_31_35.bin"));
EXPECT_EQ(changelog.size(), 33); EXPECT_EQ(changelog.size(), 33);
changelog.writeAt(7, getLogEntry("helloworld", 5555)); changelog.writeAt(7, getLogEntry("helloworld", 5555));
@ -656,7 +665,7 @@ TEST(CoordinationTest, ChangelogTestWriteAtPreviousFile)
EXPECT_FALSE(fs::exists("./logs/changelog_11_15.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_11_15.bin"));
EXPECT_FALSE(fs::exists("./logs/changelog_16_20.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_16_20.bin"));
EXPECT_FALSE(fs::exists("./logs/changelog_11_25.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_21_25.bin"));
EXPECT_FALSE(fs::exists("./logs/changelog_26_30.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_26_30.bin"));
EXPECT_FALSE(fs::exists("./logs/changelog_31_35.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_31_35.bin"));
@ -679,6 +688,15 @@ TEST(CoordinationTest, ChangelogTestWriteAtFileBorder)
auto entry = getLogEntry(std::to_string(i) + "_hello_world", i * 10); auto entry = getLogEntry(std::to_string(i) + "_hello_world", i * 10);
changelog.appendEntry(changelog.getNextEntryIndex(), entry); changelog.appendEntry(changelog.getNextEntryIndex(), entry);
} }
EXPECT_TRUE(fs::exists("./logs/changelog_1_5.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_6_10.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_11_15.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_16_20.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_21_25.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_26_30.bin"));
EXPECT_TRUE(fs::exists("./logs/changelog_31_35.bin"));
EXPECT_EQ(changelog.size(), 33); EXPECT_EQ(changelog.size(), 33);
changelog.writeAt(11, getLogEntry("helloworld", 5555)); changelog.writeAt(11, getLogEntry("helloworld", 5555));
@ -692,7 +710,7 @@ TEST(CoordinationTest, ChangelogTestWriteAtFileBorder)
EXPECT_TRUE(fs::exists("./logs/changelog_11_15.bin")); EXPECT_TRUE(fs::exists("./logs/changelog_11_15.bin"));
EXPECT_FALSE(fs::exists("./logs/changelog_16_20.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_16_20.bin"));
EXPECT_FALSE(fs::exists("./logs/changelog_11_25.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_21_25.bin"));
EXPECT_FALSE(fs::exists("./logs/changelog_26_30.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_26_30.bin"));
EXPECT_FALSE(fs::exists("./logs/changelog_31_35.bin")); EXPECT_FALSE(fs::exists("./logs/changelog_31_35.bin"));