Skip to content

Commit

Permalink
test: add test for shared storage root being changed after watcher
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>

[skip ci]
  • Loading branch information
icewind1991 authored and backportbot[bot] committed Feb 11, 2025
1 parent 8b97a2f commit 23f2804
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions apps/files_sharing/tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,4 +564,38 @@ public function testSearchShareJailedStorage() {
$results = $sharedStorage->getCache()->search("foo.txt");
$this->assertCount(1, $results);
}

public function testWatcherRootChange() {
$sourceStorage = new Temporary();
$sourceStorage->mkdir('shared');
$sourceStorage->file_put_contents('shared/foo.txt', 'foo');
$sourceStorage->getScanner()->scan('');
$sourceStorage->getWatcher()->setPolicy(IWatcher::CHECK_ALWAYS);
$this->registerMount(self::TEST_FILES_SHARING_API_USER1, $sourceStorage, '/' . self::TEST_FILES_SHARING_API_USER1 . '/files/foo');

self::loginHelper(self::TEST_FILES_SHARING_API_USER1);

$rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
$node = $rootFolder->get('foo/shared');
$this->assertEquals(3, $node->getSize());

$share = $this->shareManager->newShare();
$share->setNode($node)
->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(Constants::PERMISSION_ALL);
$share = $this->shareManager->createShare($share);
$share->setStatus(IShare::STATUS_ACCEPTED);
$this->shareManager->updateShare($share);
\OC_Util::tearDownFS();

self::loginHelper(self::TEST_FILES_SHARING_API_USER2);

$view = Filesystem::getView();

$sourceStorage->rmdir('shared');

$this->assertFalse($view->getFileInfo('shared'));
}
}

0 comments on commit 23f2804

Please sign in to comment.