Skip to content

Commit

Permalink
allow negative checks
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBurchLog committed Jul 11, 2024
1 parent 1102e42 commit 010a3c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion brewtils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def set_status_heartbeat(self, status, max_history=None):
self.heartbeat = datetime.utcnow()
self.history.append(StatusHistory(status=copy.deepcopy(status), heartbeat=self.heartbeat))

if max_history and len(self.history) > max_history:
if max_history and max_history > 0 and len(self.history) > max_history:
self.history = self.history[(max_history * -1):]

def __str__(self):
Expand Down
8 changes: 8 additions & 0 deletions test/models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,3 +735,11 @@ def test_history(self):
status_info.set_status_heartbeat("RUNNING")

assert len(status_info.history) == 10

def test_negative_history(self):
status_info = StatusInfo()

for _ in range(10):
status_info.set_status_heartbeat("RUNNING", max_history=-1)

assert len(status_info.history) == 10

0 comments on commit 010a3c5

Please sign in to comment.