Skip to content
Merged
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
Prev Previous commit
test: add test for jail watcher
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and backportbot[bot] committed Apr 9, 2024
commit 338c8aaea4ca93b74be53c338904c2fc32d66b3e
30 changes: 30 additions & 0 deletions tests/lib/Files/Cache/Wrapper/CacheJailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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;
Expand Down Expand Up @@ -218,4 +219,33 @@ public function testRootJail() {
$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'));
}
}