fix overzealous snapshot removal bug

This commit is contained in:
Dr. Matthias Ratajczak
2022-05-04 11:26:39 +02:00
parent 07960781b5
commit 21b3cb588e
2 changed files with 24 additions and 7 deletions
+14 -1
View File
@@ -207,7 +207,20 @@ class TestDataset:
counter = 0
ds._clean_old_snapshots_for_interval("daily", MAX_COUNT)
assert counter == MAX_COUNT
assert counter <= MAX_COUNT
@pytest.mark.parametrize("max_count", [10, 40])
def test__get_oldest_snapshots_exceeding_max_count(self, max_count):
snapshots = [
snap for snap in gen_snapshots_for_tank_ROOT() if "daily" in str(snap)
]
ORIGINAL_COUNT = 31
assert len(snapshots) == ORIGINAL_COUNT
expected_result_len = ORIGINAL_COUNT - max_count
if expected_result_len < 0:
expected_result_len = 0
result = Dataset._get_oldest_snapshots_exceeding_max_count(snapshots, max_count)
assert len(result) == expected_result_len
def gen_snapshots_for_tank_ROOT() -> list[Snapshot]: