From a41ab3ca56270950065b8deff78ae18702086ede Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 3 Feb 2025 11:36:20 +0100 Subject: [PATCH] test(timeout): locks are deprecated after expiry Signed-off-by: Max --- tests/Feature/LockFeatureTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Feature/LockFeatureTest.php b/tests/Feature/LockFeatureTest.php index 30ef120e..baae5d86 100644 --- a/tests/Feature/LockFeatureTest.php +++ b/tests/Feature/LockFeatureTest.php @@ -8,6 +8,7 @@ use OCA\FilesLock\AppInfo\Application; use OCA\FilesLock\Model\FileLock; use OCA\FilesLock\Service\ConfigService; +use OCA\FilesLock\Service\LockService; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Files\File; use OCP\Files\IRootFolder; @@ -204,6 +205,16 @@ public function testLockUserExpire() { self::assertEquals('CCC', $file->getContent()); } + public function testExpiredLocksAreDeprecated() { + \OCP\Server::get(IConfig::class)->setAppValue(Application::APP_ID, ConfigService::LOCK_TIMEOUT, 30); + $file = $this->loginAndGetUserFolder(self::TEST_USER1) + ->newFile('test-expired-lock-is-deprecated', 'AAA'); + $this->lockManager->lock(new LockContext($file, ILock::TYPE_USER, self::TEST_USER1)); + $this->toTheFuture(3600); + $deprecated = \OCP\Server::get(LockService::class)->getDeprecatedLocks(); + self::assertNotEmpty($deprecated); + } + public function testLockUserInfinite() { \OCP\Server::get(IConfig::class)->setAppValue(Application::APP_ID, ConfigService::LOCK_TIMEOUT, 0); $file = $this->loginAndGetUserFolder(self::TEST_USER1)