Skip to content

Commit 63965ba

Browse files
authored
Merge pull request #904 from nextcloud/tests/flaky-test-fix
fix(tests): use delta tolerance for lock ETA assertions to prevent flaky test failures
2 parents 80afbc5 + 0662d05 commit 63965ba

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/Feature/LockFeatureTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ public function testExtendLock() {
361361

362362
// We should have one lock for that file with 15 minutes ETA
363363
$this->assertCount(1, $locks);
364-
$this->assertEquals(15 * 60, $locks[0]->getEta());
364+
$this->assertEqualsWithDelta(15 * 60, $locks[0]->getEta(), 2, 'Initial lock ETA should be approximately 15 minutes');
365365

366366
// going to the future we see the ETA to be 5 minutes
367367
$this->toTheFuture(10 * 60);
368368
$locks = $this->lockManager->getLocks($file->getId());
369369
$this->assertCount(1, $locks);
370-
$this->assertEquals(5 * 60, $locks[0]->getEta());
370+
$this->assertEqualsWithDelta(5 * 60, $locks[0]->getEta(), 2, 'After 10 minutes, ETA should be approximately 5 minutes');
371371
$id = $locks[0]->getId();
372372

373373
// Extend the lock (lock again)
@@ -376,7 +376,7 @@ public function testExtendLock() {
376376
// The lock should only be extended, so same ID but fresh ETA
377377
$locks = $this->lockManager->getLocks($file->getId());
378378
$this->assertCount(1, $locks);
379-
$this->assertEquals(15 * 60, $locks[0]->getEta());
379+
$this->assertEqualsWithDelta(15 * 60, $locks[0]->getEta(), 2, 'Extended lock ETA should be approximately 15 minutes');
380380
$this->assertEquals($id, $locks[0]->getId());
381381
}
382382

0 commit comments

Comments
 (0)