mirror of
https://github.com/nextcloud/server.git
synced 2026-06-14 19:20:35 -04:00
test(dav): add clarifying comments to testPutLocking test
Signed-off-by: Josh <josh.t.richards@gmail.com>
This commit is contained in:
parent
3ab1bd4549
commit
2d524128c5
1 changed files with 15 additions and 5 deletions
|
|
@ -800,7 +800,13 @@ class FileTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test whether locks are set before and after the operation
|
||||
* Test that PUT keeps hook-time lock semantics compatible:
|
||||
* - pre-write hooks run while the file is shared-locked
|
||||
* - post-write hooks also run while the file is shared-locked
|
||||
*
|
||||
* Post-write hooks are expected to observe a fully finalized file state,
|
||||
* but should still be able to access the file without exclusive-lock
|
||||
* contention.
|
||||
*/
|
||||
public function testPutLocking(): void {
|
||||
$view = new View('/' . $this->user . '/files/');
|
||||
|
|
@ -832,8 +838,8 @@ class FileTest extends TestCase {
|
|||
$wasLockedPost = false;
|
||||
$eventHandler = $this->createMock(EventHandlerMock::class);
|
||||
|
||||
// both pre and post hooks might need access to the file,
|
||||
// so only shared lock is acceptable
|
||||
// Pre-write hooks should run under a shared lock so observers can safely
|
||||
// inspect the target while the write is in progress.
|
||||
$eventHandler->expects($this->once())
|
||||
->method('writeCallback')
|
||||
->willReturnCallback(
|
||||
|
|
@ -842,6 +848,10 @@ class FileTest extends TestCase {
|
|||
$wasLockedPre = $wasLockedPre && !$this->isFileLocked($view, $path, ILockingProvider::LOCK_EXCLUSIVE);
|
||||
}
|
||||
);
|
||||
|
||||
// Post-write hooks should also run under a shared lock. They are expected to
|
||||
// see fully finalized metadata/state, but still be able to access the file
|
||||
// during the callback.
|
||||
$eventHandler->expects($this->once())
|
||||
->method('postWriteCallback')
|
||||
->willReturnCallback(
|
||||
|
|
@ -872,8 +882,8 @@ class FileTest extends TestCase {
|
|||
// afterMethod unlocks
|
||||
$view->unlockFile($path, ILockingProvider::LOCK_SHARED);
|
||||
|
||||
$this->assertTrue($wasLockedPre, 'File was locked during pre-hooks');
|
||||
$this->assertTrue($wasLockedPost, 'File was locked during post-hooks');
|
||||
$this->assertTrue($wasLockedPre, 'File was shared-locked during pre-hooks');
|
||||
$this->assertTrue($wasLockedPost, 'File was shared-locked during post-hooks');
|
||||
|
||||
$this->assertFalse(
|
||||
$this->isFileLocked($view, $path, ILockingProvider::LOCK_SHARED),
|
||||
|
|
|
|||
Loading…
Reference in a new issue