Skip to content

Commit 003569e

Browse files
committed
test: test_weekly_rotation
1 parent 32e966c commit 003569e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

rotate_backups/tests.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,23 @@ def test_minutely_rotation(self):
387387
assert os.path.exists(os.path.join(root, 'backup-2016-01-10_21-30-00'))
388388
assert os.path.exists(os.path.join(root, 'backup-2016-01-10_21-45-00'))
389389

390+
def test_weekly_rotation(self):
391+
"""Test weekly rotation."""
392+
with TemporaryDirectory(prefix='rotate-backups-', suffix='-test-suite') as root:
393+
os.mkdir(os.path.join(root, 'galera_backup_db4.sl.example.lab_2020-12-26_10-00'))
394+
os.mkdir(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-02_10-00'))
395+
os.mkdir(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-09_10-00'))
396+
os.mkdir(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-16_10-00'))
397+
os.mkdir(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-23_10-00'))
398+
os.mkdir(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-30_10-00'))
399+
run_cli(main, '--weekly=4', root)
400+
assert os.path.exists(os.path.join(root, 'galera_backup_db4.sl.example.lab_2020-12-26_10-00')) is False
401+
assert os.path.exists(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-02_10-00')) is False
402+
assert os.path.exists(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-09_10-00'))
403+
assert os.path.exists(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-16_10-00'))
404+
assert os.path.exists(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-23_10-00'))
405+
assert os.path.exists(os.path.join(root, 'galera_backup_db4.sl.example.lab_2021-01-30_10-00'))
406+
390407
def test_removal_command(self):
391408
"""Test that the removal command can be customized."""
392409
with TemporaryDirectory(prefix='rotate-backups-', suffix='-test-suite') as root:

0 commit comments

Comments
 (0)