diff options
author | Robin Appelman <robin@icewind.nl> | 2024-04-08 18:42:44 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-04-09 10:41:50 +0000 |
commit | 338c8aaea4ca93b74be53c338904c2fc32d66b3e (patch) | |
tree | 316f9ccdbe9342cab3d343cd42110466d01a07b6 /tests | |
parent | 6c142a3cd5aa8884a8bab1ccafd2012fb26ea479 (diff) | |
download | nextcloud-server-338c8aaea4ca93b74be53c338904c2fc32d66b3e.tar.gz nextcloud-server-338c8aaea4ca93b74be53c338904c2fc32d66b3e.zip |
test: add test for jail watcher
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Cache/Wrapper/CacheJailTest.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php index 8d7e6536418..8c96e7f84e5 100644 --- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php +++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php @@ -11,6 +11,7 @@ namespace Test\Files\Cache\Wrapper; use OC\Files\Cache\Wrapper\CacheJail; use OC\Files\Search\SearchComparison; use OC\Files\Search\SearchQuery; +use OC\Files\Storage\Wrapper\Jail; use OC\User\User; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Search\ISearchComparison; @@ -218,4 +219,33 @@ class CacheJailTest extends CacheTest { $this->assertCount(1, $result); $this->assertEquals('foo/bar/asd', $result[0]['path']); } + + public function testWatcher() { + $storage = new Jail([ + 'storage' => $this->storage, + 'root' => 'foo' + ]); + $storage->getScanner()->scan(''); + $storage->file_put_contents('bar', 'asd'); + + $this->assertFalse($this->cache->inCache('bar')); + $storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']); + $this->assertTrue($this->cache->inCache('bar')); + } + + public function testWatcherAfterInnerWatcher() { + $storage = new Jail([ + 'storage' => $this->storage, + 'root' => 'foo' + ]); + $storage->getScanner()->scan(''); + $storage->file_put_contents('bar', 'asd'); + + // let the underlying storage create it's watcher first + $this->storage->getWatcher(); + + $this->assertFalse($this->cache->inCache('bar')); + $storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']); + $this->assertTrue($this->cache->inCache('bar')); + } } |