Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2021-11-10 14:21:01 +0300
committerJohn Molakvoæ <skjnldsv@protonmail.com>2022-01-14 10:32:04 +0300
commit295348446bea500773209fe57afb7b6ca4108f30 (patch)
treeef995a1a0fcfde1099f938aceefc2e6af0bd3b15 /tests
parente0352ae684a6d8c8ef2cdc7d2a2b2e71cca0c029 (diff)
Implement multibucket shift for ObjectStore
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/Mount/ObjectHomeMountProviderTest.php12
-rw-r--r--tests/lib/Files/ObjectStore/MapperTest.php46
2 files changed, 41 insertions, 17 deletions
diff --git a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
index ea414679888..5dc93660d9c 100644
--- a/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
+++ b/tests/lib/Files/Mount/ObjectHomeMountProviderTest.php
@@ -54,7 +54,7 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
}
public function testMultiBucket() {
- $this->config->expects($this->once())
+ $this->config->expects($this->exactly(2))
->method('getSystemValue')
->with($this->equalTo('objectstore_multibucket'), '')
->willReturn([
@@ -98,9 +98,9 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
}
public function testMultiBucketWithPrefix() {
- $this->config->expects($this->once())
+ $this->config->expects($this->exactly(2))
->method('getSystemValue')
- ->with($this->equalTo('objectstore_multibucket'), '')
+ ->with('objectstore_multibucket')
->willReturn([
'class' => 'Test\Files\Mount\FakeObjectStore',
'arguments' => [
@@ -147,7 +147,7 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
public function testMultiBucketBucketAlreadySet() {
$this->config->expects($this->once())
->method('getSystemValue')
- ->with($this->equalTo('objectstore_multibucket'), '')
+ ->with('objectstore_multibucket')
->willReturn([
'class' => 'Test\Files\Mount\FakeObjectStore',
'arguments' => [
@@ -185,9 +185,9 @@ class ObjectHomeMountProviderTest extends \Test\TestCase {
}
public function testMultiBucketConfigFirst() {
- $this->config->expects($this->once())
+ $this->config->expects($this->exactly(2))
->method('getSystemValue')
- ->with($this->equalTo('objectstore_multibucket'))
+ ->with('objectstore_multibucket')
->willReturn([
'class' => 'Test\Files\Mount\FakeObjectStore',
]);
diff --git a/tests/lib/Files/ObjectStore/MapperTest.php b/tests/lib/Files/ObjectStore/MapperTest.php
index 307096d8dbc..d8427f993fe 100644
--- a/tests/lib/Files/ObjectStore/MapperTest.php
+++ b/tests/lib/Files/ObjectStore/MapperTest.php
@@ -22,17 +22,37 @@
namespace Test\Files\ObjectStore;
use OC\Files\ObjectStore\Mapper;
+use OCP\IConfig;
use OCP\IUser;
class MapperTest extends \Test\TestCase {
+
+ /** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
+ private $user;
+
+ /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
+ private $config;
+
+ /** @var Mapper */
+ private $mapper;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->user = $this->createMock(IUser::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->mapper = new Mapper($this->user, $this->config);
+ }
+
public function dataGetBucket() {
return [
- ['user', 64, '17'],
- ['USER', 64, '0'],
- ['bc0e8b52-a66c-1035-90c6-d9663bda9e3f', 64, '56'],
- ['user', 8, '1'],
- ['user', 2, '1'],
- ['USER', 2, '0'],
+ ['user', 64, 0, '17'],
+ ['USER', 64, 0, '0'],
+ ['bc0e8b52-a66c-1035-90c6-d9663bda9e3f', 64, 0, '56'],
+ ['user', 8, 0, '1'],
+ ['user', 2, 0, '1'],
+ ['USER', 2, 0, '0'],
+ ['user', 128, 64, '81'],
];
}
@@ -42,13 +62,17 @@ class MapperTest extends \Test\TestCase {
* @param int $numBuckets
* @param string $expectedBucket
*/
- public function testGetBucket($username, $numBuckets, $expectedBucket) {
- $user = $this->createMock(IUser::class);
- $user->method('getUID')
+ public function testGetBucket($username, $numBuckets, $bucketShift, $expectedBucket) {
+ $this->user->expects($this->once())
+ ->method('getUID')
->willReturn($username);
- $mapper = new Mapper($user);
+ $this->config->expects($this->once())
+ ->method('getSystemValue')
+ ->with('objectstore_multibucket')
+ ->willReturn(['arguments' => ['min_bucket' => $bucketShift]]);
- $this->assertSame($expectedBucket, $mapper->getBucket($numBuckets));
+ $result = $this->mapper->getBucket($numBuckets);
+ $this->assertEquals($expectedBucket, $result);
}
}