From 83a8415d99da5445cdbd560144b18485bf745cef Mon Sep 17 00:00:00 2001 From: jnahmias Date: Thu, 16 Feb 2023 11:14:20 -0500 Subject: [PATCH] Use assertEqualsWithDelta() to test time_spent Timing, clock skew, and network conditions can cause slight skew in the generated/expected timestamps in the unit test vs. actual recorded timestamps in the database. This can cause flakiness in the tests due to sporadic failures when things don't perfectly align. To fix this, we change assertEquals() to assertEqualsWithDelta() with a small (3 second) delta to account for this potential delay. --- tests/units/Model/TransitionTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/units/Model/TransitionTest.php b/tests/units/Model/TransitionTest.php index 45564b0ea..2c89a713c 100644 --- a/tests/units/Model/TransitionTest.php +++ b/tests/units/Model/TransitionTest.php @@ -133,9 +133,9 @@ class TransitionTest extends Base $this->assertEquals('admin', $transitions[2]['username']); $this->assertEquals('admin', $transitions[3]['username']); - $this->assertEquals(1200, $transitions[0]['time_spent']); - $this->assertEquals(1200, $transitions[1]['time_spent']); - $this->assertEquals(3600, $transitions[2]['time_spent']); - $this->assertEquals(3600, $transitions[3]['time_spent']); + $this->assertEqualsWithDelta(1200, $transitions[0]['time_spent'], 3); + $this->assertEqualsWithDelta(1200, $transitions[1]['time_spent'], 3); + $this->assertEqualsWithDelta(3600, $transitions[2]['time_spent'], 3); + $this->assertEqualsWithDelta(3600, $transitions[3]['time_spent'], 3); } }