This commit is contained in:
Edwin Eefting 2021-04-17 21:53:27 +02:00
parent e47d461999
commit f52b8bbf58
2 changed files with 4 additions and 1 deletions

View File

@ -36,6 +36,9 @@ class TestThinner(unittest2.TestCase):
with self.assertRaisesRegexp(Exception, "^Invalid schedule"):
ThinnerRule("XXX")
with self.assertRaisesRegexp(Exception, "^Number of"):
Thinner("-1")
def test_incremental(self):
ok=['2023-01-03 10:53:16',

View File

@ -19,7 +19,7 @@ class Thinner:
rule_strs = schedule_str.split(",")
for rule_str in rule_strs:
if rule_str.isdigit():
if rule_str.lstrip('-').isdigit():
self.always_keep = int(rule_str)
if self.always_keep < 0:
raise (Exception("Number of snapshots to keep cant be negative: {}".format(self.always_keep)))