diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2024-03-08 08:14:05 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2024-03-21 18:37:21 +0100 |
commit | 3dea99f42b4a8956f0cbe6a726e30afedace39a4 (patch) | |
tree | 4e2089efd219e48d2666e865b2fb129d45e0ea92 /apps/dav/tests/unit/CardDAV/CardDavBackendTest.php | |
parent | a7dfec070a1dda79ade7cfea91b3dc7e74d184a6 (diff) | |
download | nextcloud-server-3dea99f42b4a8956f0cbe6a726e30afedace39a4.tar.gz nextcloud-server-3dea99f42b4a8956f0cbe6a726e30afedace39a4.zip |
fix(dav): Add retention time to sync token cleanup
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/tests/unit/CardDAV/CardDavBackendTest.php')
-rw-r--r-- | apps/dav/tests/unit/CardDAV/CardDavBackendTest.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index ea80187f554..942718f7ce5 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -60,6 +60,7 @@ use Sabre\DAV\PropPatch; use Sabre\VObject\Component\VCard; use Sabre\VObject\Property\Text; use Test\TestCase; +use function time; /** * Class CardDavBackendTest @@ -880,7 +881,12 @@ class CardDavBackendTest extends TestCase { $uri = $this->getUniqueID('card'); $this->backend->createCard($addressBookId, $uri, $this->vcardTest0); $this->backend->updateCard($addressBookId, $uri, $this->vcardTest1); - $deleted = $this->backend->pruneOutdatedSyncTokens(0); + + // Do not delete anything if week data as old as ts=0 + $deleted = $this->backend->pruneOutdatedSyncTokens(0, 0); + self::assertSame(0, $deleted); + + $deleted = $this->backend->pruneOutdatedSyncTokens(0, time()); // At least one from the object creation and one from the object update $this->assertGreaterThanOrEqual(2, $deleted); $changes = $this->backend->getChangesForAddressBook($addressBookId, $syncToken, 1); @@ -912,7 +918,7 @@ class CardDavBackendTest extends TestCase { $this->assertEmpty($changes['deleted']); // Delete all but last change - $deleted = $this->backend->pruneOutdatedSyncTokens(1); + $deleted = $this->backend->pruneOutdatedSyncTokens(1, time()); $this->assertEquals(1, $deleted); // We had two changes before, now one // Only update should remain @@ -920,8 +926,8 @@ class CardDavBackendTest extends TestCase { $this->assertEmpty($changes['added']); $this->assertEquals(1, count($changes['modified'])); $this->assertEmpty($changes['deleted']); - + // Check that no crash occurs when prune is called without current changes - $deleted = $this->backend->pruneOutdatedSyncTokens(1); + $deleted = $this->backend->pruneOutdatedSyncTokens(1, time()); } } |