aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBlaok <i@blaok.me>2018-05-18 14:51:08 -0700
committerBlaok <i@blaok.me>2018-05-18 14:51:08 -0700
commit4a3471595aec40aca825339a2446d9f9dd8ab963 (patch)
tree150e56e12e0ebb13a3f4955ea13437c0714874bb /tests
parent21b9ad397817af96d6d4204642debd263233bdda (diff)
downloadnextcloud-server-4a3471595aec40aca825339a2446d9f9dd8ab963.tar.gz
nextcloud-server-4a3471595aec40aca825339a2446d9f9dd8ab963.zip
test: add unit test for files:scan --shallow
Signed-off-by: Yuze Chi <i@blaok.me>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Utils/ScannerTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php
index 1379bc2e906..8748b52f0ca 100644
--- a/tests/lib/Files/Utils/ScannerTest.php
+++ b/tests/lib/Files/Utils/ScannerTest.php
@@ -209,4 +209,35 @@ class ScannerTest extends \Test\TestCase {
$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'));
+ }
+
}