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.
This commit is contained in:
jnahmias 2023-02-16 11:14:20 -05:00 committed by Frédéric Guillot
parent 31408f53aa
commit 83a8415d99
1 changed files with 4 additions and 4 deletions

View File

@ -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);
}
}