Skip to content

Commit

Permalink
test(unit): Avoid false positive because of 1 second difference
Browse files Browse the repository at this point in the history
  • Loading branch information
julienloizelet committed Oct 16, 2024
1 parent d0cf9ee commit 1c00ad4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/Unit/CapiRemediationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1349,12 +1349,12 @@ public function testRefreshDecisions($cacheType)
$cachedValue[1][0]
);
$lastPullItem = $remediation->getCacheStorage()->getItem($lastPullCacheKey);

$this->assertEquals(
[AbstractCache::INDEX_EXP => $listExpiration, AbstractCache::LAST_PULL => $time],
$lastPullItem->get(),
'Expiration and pull date should not have change'
);
$lastPullItemContent = $lastPullItem->get();
// Expiration and pull date should not have change
// Avoid false positive with tme manipulation (strict equality sometimes leads to error of 1 second)
$this->assertTrue($lastPullItemContent[AbstractCache::INDEX_EXP] <= $listExpiration && $listExpiration - 1 <= $lastPullItemContent[1]);
$this->assertTrue($lastPullItemContent[AbstractCache::LAST_PULL] <= $time && $time - 1 <=
$lastPullItemContent['last_pull']);
// Test 13 : new + list again
// We wait to test that expiration and pull date won't change
$result = $remediation->refreshDecisions();
Expand Down

0 comments on commit 1c00ad4

Please sign in to comment.