From da114d5c7d5237b07e33cd45d89c7de06c121893 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 8 Apr 2024 18:42:44 +0200 Subject: test: add test for jail watcher Signed-off-by: Robin Appelman --- tests/lib/Files/Cache/Wrapper/CacheJailTest.php | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') 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')); + } } -- cgit v1.2.3