Skip to content

Commit

Permalink
Reproduce #12 in test suite
Browse files Browse the repository at this point in the history
For more information:
#12
  • Loading branch information
xolox committed Aug 2, 2018
1 parent 2be50fb commit 12190d2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion rotate_backups/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# External dependencies.
from executor.contexts import RemoteContext
from humanfriendly.testing import TemporaryDirectory, TestCase, run_cli
from humanfriendly.testing import TemporaryDirectory, TestCase, run_cli, touch
from six.moves import configparser

# The module we're testing.
Expand Down Expand Up @@ -140,6 +140,18 @@ def test_argument_validation(self):
returncode, output = run_cli(main, '-n', '/root')
assert returncode != 0

def test_invalid_dates(self):
"""Make sure filenames with invalid dates don't cause an exception."""
with TemporaryDirectory(prefix='rotate-backups-', suffix='-test-suite') as root:
file_with_valid_date = os.path.join(root, 'snapshot-201808030034.tar.gz')
file_with_invalid_date = os.path.join(root, 'snapshot-180731150101.tar.gz')
for filename in file_with_valid_date, file_with_invalid_date:
touch(filename)
program = RotateBackups(rotation_scheme=dict(monthly='always'))
backups = program.collect_backups(root)
assert len(backups) == 1
assert backups[0].pathname == file_with_valid_date

def test_dry_run(self):
"""Make sure dry run doesn't remove any backups."""
with TemporaryDirectory(prefix='rotate-backups-', suffix='-test-suite') as root:
Expand Down

0 comments on commit 12190d2

Please sign in to comment.