Merge pull request #4703 from nextcloud/improve-memcache-test
Make cache tests a bit more clear
This commit is contained in:
commit
ee2dfb24e0
2 changed files with 44 additions and 12 deletions
|
@ -53,21 +53,48 @@ abstract class TestCache extends \Test\TestCase {
|
||||||
|
|
||||||
function testClear() {
|
function testClear() {
|
||||||
$value='ipsum lorum';
|
$value='ipsum lorum';
|
||||||
$this->instance->set('1_value1', $value);
|
$this->instance->set('1_value1', $value . '1');
|
||||||
$this->instance->set('1_value2', $value);
|
$this->instance->set('1_value2', $value . '2');
|
||||||
$this->instance->set('2_value1', $value);
|
$this->instance->set('2_value1', $value . '3');
|
||||||
$this->instance->set('3_value1', $value);
|
$this->instance->set('3_value1', $value . '4');
|
||||||
|
|
||||||
|
$this->assertEquals([
|
||||||
|
'1_value1' => 'ipsum lorum1',
|
||||||
|
'1_value2' => 'ipsum lorum2',
|
||||||
|
'2_value1' => 'ipsum lorum3',
|
||||||
|
'3_value1' => 'ipsum lorum4',
|
||||||
|
], [
|
||||||
|
'1_value1' => $this->instance->get('1_value1'),
|
||||||
|
'1_value2' => $this->instance->get('1_value2'),
|
||||||
|
'2_value1' => $this->instance->get('2_value1'),
|
||||||
|
'3_value1' => $this->instance->get('3_value1'),
|
||||||
|
]);
|
||||||
$this->assertTrue($this->instance->clear('1_'));
|
$this->assertTrue($this->instance->clear('1_'));
|
||||||
$this->assertFalse($this->instance->hasKey('1_value1'));
|
|
||||||
$this->assertFalse($this->instance->hasKey('1_value2'));
|
$this->assertEquals([
|
||||||
$this->assertTrue($this->instance->hasKey('2_value1'));
|
'1_value1' => null,
|
||||||
$this->assertTrue($this->instance->hasKey('3_value1'));
|
'1_value2' => null,
|
||||||
|
'2_value1' => 'ipsum lorum3',
|
||||||
|
'3_value1' => 'ipsum lorum4',
|
||||||
|
], [
|
||||||
|
'1_value1' => $this->instance->get('1_value1'),
|
||||||
|
'1_value2' => $this->instance->get('1_value2'),
|
||||||
|
'2_value1' => $this->instance->get('2_value1'),
|
||||||
|
'3_value1' => $this->instance->get('3_value1'),
|
||||||
|
]);
|
||||||
|
|
||||||
$this->assertTrue($this->instance->clear());
|
$this->assertTrue($this->instance->clear());
|
||||||
$this->assertFalse($this->instance->hasKey('1_value1'));
|
|
||||||
$this->assertFalse($this->instance->hasKey('1_value2'));
|
$this->assertEquals([
|
||||||
$this->assertFalse($this->instance->hasKey('2_value1'));
|
'1_value1' => null,
|
||||||
$this->assertFalse($this->instance->hasKey('3_value1'));
|
'1_value2' => null,
|
||||||
|
'2_value1' => null,
|
||||||
|
'3_value1' => null,
|
||||||
|
], [
|
||||||
|
'1_value1' => $this->instance->get('1_value1'),
|
||||||
|
'1_value2' => $this->instance->get('1_value2'),
|
||||||
|
'2_value1' => $this->instance->get('2_value1'),
|
||||||
|
'3_value1' => $this->instance->get('3_value1'),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ class RedisTest extends Cache {
|
||||||
},
|
},
|
||||||
E_WARNING
|
E_WARNING
|
||||||
);
|
);
|
||||||
|
$instance = null;
|
||||||
try {
|
try {
|
||||||
$instance = new \OC\Memcache\Redis(self::getUniqueID());
|
$instance = new \OC\Memcache\Redis(self::getUniqueID());
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
|
@ -34,6 +35,10 @@ class RedisTest extends Cache {
|
||||||
self::markTestSkipped($errorOccurred);
|
self::markTestSkipped($errorOccurred);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($instance === null) {
|
||||||
|
throw new \Exception('redis server is not reachable');
|
||||||
|
}
|
||||||
|
|
||||||
if ($instance->set(self::getUniqueID(), self::getUniqueID()) === false) {
|
if ($instance->set(self::getUniqueID(), self::getUniqueID()) === false) {
|
||||||
self::markTestSkipped('redis server seems to be down.');
|
self::markTestSkipped('redis server seems to be down.');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue