Skip to content

Commit 88ccea6

Browse files
committed
test: add test for jail watcher
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent d31ed8d commit 88ccea6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/lib/Files/Cache/Wrapper/CacheJailTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use OC\Files\Cache\Wrapper\CacheJail;
1212
use OC\Files\Search\SearchComparison;
1313
use OC\Files\Search\SearchQuery;
14+
use OC\Files\Storage\Wrapper\Jail;
1415
use OC\User\User;
1516
use OCP\EventDispatcher\IEventDispatcher;
1617
use OCP\Files\Search\ISearchComparison;
@@ -218,4 +219,33 @@ public function testRootJail() {
218219
$this->assertCount(1, $result);
219220
$this->assertEquals('foo/bar/asd', $result[0]['path']);
220221
}
222+
223+
public function testWatcher() {
224+
$storage = new Jail([
225+
'storage' => $this->storage,
226+
'root' => 'foo'
227+
]);
228+
$storage->getScanner()->scan('');
229+
$storage->file_put_contents('bar', 'asd');
230+
231+
$this->assertFalse($this->cache->inCache('bar'));
232+
$storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']);
233+
$this->assertTrue($this->cache->inCache('bar'));
234+
}
235+
236+
public function testWatcherAfterInnerWatcher() {
237+
$storage = new Jail([
238+
'storage' => $this->storage,
239+
'root' => 'foo'
240+
]);
241+
$storage->getScanner()->scan('');
242+
$storage->file_put_contents('bar', 'asd');
243+
244+
// let the underlying storage create it's watcher first
245+
$this->storage->getWatcher();
246+
247+
$this->assertFalse($this->cache->inCache('bar'));
248+
$storage->getWatcher()->update('bar', ['mimetype' => 'text/plain']);
249+
$this->assertTrue($this->cache->inCache('bar'));
250+
}
221251
}

0 commit comments

Comments
 (0)