aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2023-05-11 08:15:41 +0200
committerGitHub <noreply@github.com>2023-05-11 08:15:41 +0200
commitdb026840082432f8b851171a8f0e8374de818ee1 (patch)
treea382d483b4e7abf752c0127f04667a4dd83e653a /tests
parent83ed1fb004e6fe3bb96171defbdafc89e302a72a (diff)
parent2ea41dab93324749164e7c9c380085b8daab6138 (diff)
downloadnextcloud-server-db026840082432f8b851171a8f0e8374de818ee1.tar.gz
nextcloud-server-db026840082432f8b851171a8f0e8374de818ee1.zip
Merge pull request #37691 from nextcloud/object-store-background-scan
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php (renamed from tests/lib/Files/ObjectStore/NoopScannerTest.php)42
1 files changed, 26 insertions, 16 deletions
diff --git a/tests/lib/Files/ObjectStore/NoopScannerTest.php b/tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php
index 7142fb6daf9..02d72defa92 100644
--- a/tests/lib/Files/ObjectStore/NoopScannerTest.php
+++ b/tests/lib/Files/ObjectStore/ObjectStoreScannerTest.php
@@ -12,18 +12,29 @@
namespace Test\Files\ObjectStore;
-class NoopScannerTest extends \Test\TestCase {
- /** @var \OC\Files\Storage\Storage $storage */
- private $storage;
+use OC\Files\Cache\Scanner;
+use OC\Files\ObjectStore\ObjectStoreScanner;
+use OC\Files\Storage\Temporary;
+use OCP\Files\Cache\ICache;
+use OCP\Files\Storage\IStorage;
+use Test\TestCase;
- /** @var \OC\Files\ObjectStore\NoopScanner $scanner */
- private $scanner;
+/**
+ * @group DB
+ */
+class ObjectStoreScannerTest extends TestCase {
+ private IStorage $storage;
+ private ICache $cache;
+ private ObjectStoreScanner $scanner;
+ private Scanner $realScanner;
protected function setUp(): void {
parent::setUp();
- $this->storage = new \OC\Files\Storage\Temporary([]);
- $this->scanner = new \OC\Files\ObjectStore\NoopScanner($this->storage);
+ $this->storage = new Temporary([]);
+ $this->cache = $this->storage->getCache();
+ $this->scanner = new ObjectStoreScanner($this->storage);
+ $this->realScanner = new Scanner($this->storage);
}
public function testFile() {
@@ -61,17 +72,16 @@ class NoopScannerTest extends \Test\TestCase {
$this->storage->mkdir('folder2');
$this->storage->file_put_contents('folder2/bar.txt', 'foobar');
- $this->assertEquals(
- [],
- $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW),
- 'Asserting that no error occurred while scan(SCAN_SHALLOW)'
- );
+ $this->realScanner->scan('');
+
+ $this->assertEquals(6, $this->cache->get('folder2')->getSize());
+
+ $this->cache->put('folder2', ['size' => -1]);
+
+ $this->assertEquals(-1, $this->cache->get('folder2')->getSize());
$this->scanner->backgroundScan();
- $this->assertTrue(
- true,
- 'Asserting that no error occurred while backgroundScan()'
- );
+ $this->assertEquals(6, $this->cache->get('folder2')->getSize());
}
}