aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-04-12 18:08:14 +0200
committerRobin Appelman <robin@icewind.nl>2023-05-10 19:33:26 +0200
commit2ea41dab93324749164e7c9c380085b8daab6138 (patch)
treea6094b9b32f97b35ec92fb2a52455c59ac7d5597 /tests
parentf734a7646639549b626c05b12a789c8cdedf2511 (diff)
downloadnextcloud-server-2ea41dab93324749164e7c9c380085b8daab6138.tar.gz
nextcloud-server-2ea41dab93324749164e7c9c380085b8daab6138.zip
repair -1 folder sizes for object store background scan
Signed-off-by: Robin Appelman <robin@icewind.nl>
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());
}
}