forked from GithubBackups/healthchecks
Overwrite Check.last_start value
This commit is contained in:
parent
fe04429fad
commit
eee6fc12f4
@ -219,10 +219,7 @@ class Check(models.Model):
|
||||
|
||||
def ping(self, remote_addr, scheme, method, ua, body, action):
|
||||
if action == "start":
|
||||
# If we receive multiple start events in a row,
|
||||
# we remember the first one, not the last one
|
||||
if self.last_start is None:
|
||||
self.last_start = timezone.now()
|
||||
self.last_start = timezone.now()
|
||||
# DOn't update "last_ping" field.
|
||||
else:
|
||||
self.last_start = None
|
||||
|
@ -168,16 +168,3 @@ class PingTestCase(TestCase):
|
||||
self.check.refresh_from_db()
|
||||
self.assertTrue(self.check.last_start)
|
||||
self.assertEqual(self.check.status, "paused")
|
||||
|
||||
def test_start_does_not_overwrite_last_start(self):
|
||||
first_start = now() - td(hours=2)
|
||||
|
||||
self.check.last_start = first_start
|
||||
self.check.save()
|
||||
|
||||
r = self.client.get("/ping/%s/start" % self.check.code)
|
||||
self.assertEqual(r.status_code, 200)
|
||||
|
||||
self.check.refresh_from_db()
|
||||
# Should still be the original value
|
||||
self.assertEqual(self.check.last_start, first_start)
|
||||
|
Loading…
x
Reference in New Issue
Block a user