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:
authorRobin McCorkell <rmccorkell@karoshi.org.uk>2015-03-18 19:19:04 +0300
committerRobin McCorkell <rmccorkell@karoshi.org.uk>2015-03-20 19:19:08 +0300
commit58ad3fac063ef960bda97fe2cbc2e2f64fc6ad4d (patch)
tree7bfaa61e5f1ec2a561f5fc8c7a7c0011aac27e92 /tests
parent88a180fadb73f21cb0af32b4d2a9db6d6baf35a5 (diff)
Add unit tests for gc() for \OC\Cache\FileGlobalGC
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/cache/fileglobalgc.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/lib/cache/fileglobalgc.php b/tests/lib/cache/fileglobalgc.php
index 0b0a4cb002d..4f032538e7d 100644
--- a/tests/lib/cache/fileglobalgc.php
+++ b/tests/lib/cache/fileglobalgc.php
@@ -70,4 +70,38 @@ class FileGlobalGC extends TestCase {
mkdir($this->cacheDir . 'asd');
$this->assertEquals([$this->cacheDir . 'foo'], $this->gc->getExpiredPaths($this->cacheDir, $time));
}
+
+ public function testGcUnlink() {
+ $time = time();
+ $this->addCacheFile('foo', $time - 10);
+ $this->addCacheFile('bar', $time - 10);
+ $this->addCacheFile('asd', $time + 10);
+
+ $config = $this->getMock('\OCP\IConfig');
+ $config->expects($this->once())
+ ->method('getAppValue')
+ ->with('core', 'global_cache_gc_lastrun', 0)
+ ->willReturn($time - \OC\Cache\FileGlobalGC::CLEANUP_TTL_SEC - 1);
+ $config->expects($this->once())
+ ->method('setAppValue');
+
+ $this->gc->gc($config, $this->cacheDir);
+ $this->assertFileNotExists($this->cacheDir . 'foo');
+ $this->assertFileNotExists($this->cacheDir . 'bar');
+ $this->assertFileExists($this->cacheDir . 'asd');
+ }
+
+ public function testGcLastRun() {
+ $time = time();
+
+ $config = $this->getMock('\OCP\IConfig');
+ $config->expects($this->once())
+ ->method('getAppValue')
+ ->with('core', 'global_cache_gc_lastrun', 0)
+ ->willReturn($time);
+ $config->expects($this->never())
+ ->method('setAppValue');
+
+ $this->gc->gc($config, $this->cacheDir);
+ }
}