Skip to content

Commit bf479b8

Browse files
moodyjmzclaude
andcommitted
test: add regression test for default infinite lock timeout (-1)
Verifies that LOCK_TIMEOUT = -1 (the default) produces ETA_INFINITE rather than a negative timeout value that clients misread as a past expiry. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
1 parent 0b5b120 commit bf479b8

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/Feature/LockFeatureTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,21 @@ public function testExtendLock() {
387387
$this->assertEquals($id, $locks[0]->getId());
388388
}
389389

390+
/**
391+
* Default config (LOCK_TIMEOUT = -1) must produce ETA_INFINITE, not a negative timestamp.
392+
* Regression: getTimeout() returned -60 which clients interpreted as a past expiry.
393+
*/
394+
public function testDefaultInfiniteTimeoutProducesEtaInfinite() {
395+
\OCP\Server::get(IConfig::class)->setAppValue(Application::APP_ID, ConfigService::LOCK_TIMEOUT, '-1');
396+
397+
$file = $this->loginAndGetUserFolder(self::TEST_USER1)->newFile('test-file', 'AAA');
398+
$this->lockManager->lock(new LockContext($file, ILock::TYPE_USER, self::TEST_USER1));
399+
$locks = $this->lockManager->getLocks($file->getId());
400+
401+
$this->assertCount(1, $locks);
402+
$this->assertEquals(FileLock::ETA_INFINITE, $locks[0]->getEta());
403+
}
404+
390405
/**
391406
* Regression test for https://github.com/nextcloud/files_lock/issues/130
392407
*/

0 commit comments

Comments
 (0)