Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add test for shared storage root being changed after watcher
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Feb 7, 2025
commit 62b5bf9140ccb5719ec31cbcb4280dea3d65e4a2
37 changes: 37 additions & 0 deletions apps/files_sharing/tests/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
*/
namespace OCA\Files_Sharing\Tests;

use OC\Files\Filesystem;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Jail;
use OCA\Files_Sharing\SharedStorage;
use OCP\Constants;
use OCP\Files\Cache\IWatcher;
use OCP\Share\IShare;

/**
Expand Down Expand Up @@ -564,4 +567,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'));
}
}