Skip to content

Commit fe0d2d1

Browse files
committed
Adds a specific keep=all test
1 parent 89c6a2c commit fe0d2d1

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/borg/testsuite/archiver/prune_cmd_test.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def test_prune_keep_yearly_int_or_interval(archivers, request, backup_files, kee
707707

708708

709709
@pytest.mark.parametrize("keep_arg", ["--keep-daily=-1", "--keep-daily=all"])
710-
def test_prune_keep_all(archivers, request, backup_files, keep_arg):
710+
def test_prune_keep_daily_all(archivers, request, backup_files, keep_arg):
711711
archiver = request.getfixturevalue(archivers)
712712
cmd(archiver, "repo-create", RK_ENCRYPTION)
713713
dt = datetime(2023, 12, 31, 23, 59, 59, tzinfo=timezone.utc)
@@ -720,6 +720,23 @@ def test_prune_keep_all(archivers, request, backup_files, keep_arg):
720720
assert re.search(r"Keeping archive \(rule: daily #3\):\s+test-3", output)
721721

722722

723+
@pytest.mark.parametrize("keep_arg", ["--keep=-1", "--keep=all"])
724+
def test_prune_keep_flat_all(archivers, request, backup_files, keep_arg):
725+
"""--keep=all / --keep=-1 keeps every archive."""
726+
archiver = request.getfixturevalue(archivers)
727+
cmd(archiver, "repo-create", RK_ENCRYPTION)
728+
dt = datetime(2023, 12, 31, 23, 59, 59, tzinfo=timezone.utc)
729+
_create_archive_dt(archiver, backup_files, "test-1", dt - timedelta(microseconds=1))
730+
_create_archive_dt(archiver, backup_files, "test-2", dt - timedelta(microseconds=2))
731+
_create_archive_dt(archiver, backup_files, "test-3", dt - timedelta(days=3))
732+
_create_archive_dt(archiver, backup_files, "test-4", dt - timedelta(days=33333))
733+
output = cmd(archiver, "prune", "--list", "--dry-run", "--since", dt.isoformat(), keep_arg)
734+
assert re.search(r"Keeping archive \(rule: keep #1\):\s+test-1", output)
735+
assert re.search(r"Keeping archive \(rule: keep #2\):\s+test-2", output)
736+
assert re.search(r"Keeping archive \(rule: keep #3\):\s+test-3", output)
737+
assert re.search(r"Keeping archive \(rule: keep #4\):\s+test-4", output)
738+
739+
723740
def _cmd_prune_error(archiver, *args):
724741
"""Run prune expecting a CommandError. Returns error string for assertions."""
725742
if archiver.FORK_DEFAULT:

0 commit comments

Comments
 (0)