aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/BackgroundJob
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2024-03-08 08:14:05 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2024-03-21 18:37:21 +0100
commit3dea99f42b4a8956f0cbe6a726e30afedace39a4 (patch)
tree4e2089efd219e48d2666e865b2fb129d45e0ea92 /apps/dav/tests/unit/BackgroundJob
parenta7dfec070a1dda79ade7cfea91b3dc7e74d184a6 (diff)
downloadnextcloud-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/BackgroundJob')
-rw-r--r--apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php b/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php
index be6298b3372..20169072687 100644
--- a/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php
+++ b/apps/dav/tests/unit/BackgroundJob/PruneOutdatedSyncTokensJobTest.php
@@ -29,6 +29,7 @@ declare(strict_types=1);
*/
namespace OCA\DAV\Tests\unit\BackgroundJob;
+use InvalidArgumentException;
use OCA\DAV\AppInfo\Application;
use OCA\DAV\BackgroundJob\PruneOutdatedSyncTokensJob;
use OCA\DAV\CalDAV\CalDavBackend;
@@ -72,18 +73,27 @@ class PruneOutdatedSyncTokensJobTest extends TestCase {
/**
* @dataProvider dataForTestRun
*/
- public function testRun(string $configValue, int $actualLimit, int $deletedCalendarSyncTokens, int $deletedAddressBookSyncTokens): void {
- $this->config->expects($this->once())
+ public function testRun(string $configToKeep, string $configRetentionDays, int $actualLimit, int $retentionDays, int $deletedCalendarSyncTokens, int $deletedAddressBookSyncTokens): void {
+ $this->config->expects($this->exactly(2))
->method('getAppValue')
- ->with(Application::APP_ID, 'totalNumberOfSyncTokensToKeep', '10000')
- ->willReturn($configValue);
+ ->with(Application::APP_ID, self::anything(), self::anything())
+ ->willReturnCallback(function ($app, $key) use ($configToKeep, $configRetentionDays) {
+ switch ($key) {
+ case 'totalNumberOfSyncTokensToKeep':
+ return $configToKeep;
+ case 'syncTokensRetentionDays':
+ return $configRetentionDays;
+ default:
+ throw new InvalidArgumentException();
+ }
+ });
$this->calDavBackend->expects($this->once())
->method('pruneOutdatedSyncTokens')
->with($actualLimit)
->willReturn($deletedCalendarSyncTokens);
$this->cardDavBackend->expects($this->once())
->method('pruneOutdatedSyncTokens')
- ->with($actualLimit)
+ ->with($actualLimit, $retentionDays)
->willReturn($deletedAddressBookSyncTokens);
$this->logger->expects($this->once())
->method('info')
@@ -97,8 +107,9 @@ class PruneOutdatedSyncTokensJobTest extends TestCase {
public function dataForTestRun(): array {
return [
- ['100', 100, 2, 3],
- ['0', 1, 0, 0]
+ ['100', '2', 100, 7 * 24 * 3600, 2, 3],
+ ['100', '14', 100, 14 * 24 * 3600, 2, 3],
+ ['0', '60', 1, 60 * 24 * 3600, 0, 0]
];
}
}