fix overzealous snapshot removal bug
This commit is contained in:
+14
-1
@@ -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]:
|
||||
|
||||
Reference in New Issue
Block a user