forked from GithubBackups/healthchecks
API: fix updating kind=cron to kind=simple
This commit is contained in:
parent
666706ef3e
commit
31eca9c8e8
@ -75,3 +75,14 @@ class UpdateCheckTestCase(BaseTestCase):
|
||||
made_up_code = "07c2f548-9850-4b27-af5d-6c9dc157ec02"
|
||||
r = self.post(made_up_code, {"api_key": "abc"})
|
||||
self.assertEqual(r.status_code, 400)
|
||||
|
||||
def test_it_updates_cron_to_simple(self):
|
||||
self.check.kind = "cron"
|
||||
self.check.schedule = "5 * * * *"
|
||||
self.check.save()
|
||||
|
||||
r = self.post(self.check.code, {"api_key": "abc", "timeout": 3600})
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
self.check.refresh_from_db()
|
||||
self.assertEqual(self.check.kind, "simple")
|
||||
|
@ -72,6 +72,7 @@ def _update(check, spec):
|
||||
check.tags = spec["tags"]
|
||||
|
||||
if "timeout" in spec and "schedule" not in spec:
|
||||
check.kind = "simple"
|
||||
check.timeout = td(seconds=spec["timeout"])
|
||||
|
||||
if "grace" in spec:
|
||||
@ -80,7 +81,7 @@ def _update(check, spec):
|
||||
if "schedule" in spec:
|
||||
check.kind = "cron"
|
||||
check.schedule = spec["schedule"]
|
||||
if "tz" in spec and "schedule" in spec:
|
||||
if "tz" in spec:
|
||||
check.tz = spec["tz"]
|
||||
|
||||
check.save()
|
||||
|
Loading…
x
Reference in New Issue
Block a user