Skip to content

Commit

Permalink
add test for trying to fopen a file which no longer exists on disk
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Oct 6, 2022
1 parent 3aabb38 commit 6023dee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/dav/tests/unit/Connector/Sabre/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ public function testGetFopenFails() {

$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
'permissions' => \OCP\Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
'type' => FileInfo::TYPE_FILE,
], null);

$file = new \OCA\DAV\Connector\Sabre\File($view, $info);
Expand All @@ -1172,7 +1172,7 @@ public function testGetFopenThrows() {

$info = new \OC\Files\FileInfo('/test.txt', $this->getMockStorage(), null, [
'permissions' => \OCP\Constants::PERMISSION_ALL,
'type' => FileInfo::TYPE_FOLDER,
'type' => FileInfo::TYPE_FILE,
], null);

$file = new \OCA\DAV\Connector\Sabre\File($view, $info);
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/Files/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2722,4 +2722,23 @@ public function testCacheExtension() {
$this->assertEquals(25, $info->getUploadTime());
$this->assertEquals(0, $info->getCreationTime());
}

public function testFopenGone() {
$storage = new Temporary([]);
$scanner = $storage->getScanner();
$storage->file_put_contents('foo.txt', 'bar');
$scanner->scan('');
$cache = $storage->getCache();

Filesystem::mount($storage, [], '/test/');
$view = new View('/test');

$storage->unlink('foo.txt');

$this->assertTrue($cache->inCache('foo.txt'));

$this->assertFalse($view->fopen('foo.txt', 'r'));

$this->assertFalse($cache->inCache('foo.txt'));
}
}

0 comments on commit 6023dee

Please sign in to comment.