test: add unit test for files:scan --shallow

Signed-off-by: Yuze Chi <i@blaok.me>
This commit is contained in:
Blaok 2018-05-18 14:51:08 -07:00
parent 21b9ad3978
commit 4a3471595a
No known key found for this signature in database
GPG Key ID: 684EE93D7F515B9C
1 changed files with 31 additions and 0 deletions

View File

@ -209,4 +209,35 @@ class ScannerTest extends \Test\TestCase {
$scanner->backgroundScan(''); $scanner->backgroundScan('');
} }
public function testShallow() {
$storage = new Temporary(array());
$mount = new MountPoint($storage, '');
Filesystem::getMountManager()->addMount($mount);
$cache = $storage->getCache();
$storage->mkdir('folder');
$storage->mkdir('folder/subfolder');
$storage->file_put_contents('foo.txt', 'qwerty');
$storage->file_put_contents('folder/bar.txt', 'qwerty');
$storage->file_put_contents('folder/subfolder/foobar.txt', 'qwerty');
$scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), \OC::$server->getLogger());
$scanner->addMount($mount);
$scanner->scan('', $recusive = false);
$this->assertTrue($cache->inCache('folder'));
$this->assertFalse($cache->inCache('folder/subfolder'));
$this->assertTrue($cache->inCache('foo.txt'));
$this->assertFalse($cache->inCache('folder/bar.txt'));
$this->assertFalse($cache->inCache('folder/subfolder/foobar.txt'));
$scanner->scan('folder', $recusive = false);
$this->assertTrue($cache->inCache('folder'));
$this->assertTrue($cache->inCache('folder/subfolder'));
$this->assertTrue($cache->inCache('foo.txt'));
$this->assertTrue($cache->inCache('folder/bar.txt'));
$this->assertFalse($cache->inCache('folder/subfolder/foobar.txt'));
}
} }