diff options
author | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2015-03-18 16:19:04 +0000 |
---|---|---|
committer | Robin McCorkell <rmccorkell@karoshi.org.uk> | 2015-03-18 16:19:04 +0000 |
commit | 693ca9a92ff268ecbd16c7bd7795a177869ea785 (patch) | |
tree | 53e41524114770bc0529db8069e383d00be813fc /tests | |
parent | 42fcd0e8b7bda681069a79be1511a2fe407f09fa (diff) | |
download | nextcloud-server-693ca9a92ff268ecbd16c7bd7795a177869ea785.tar.gz nextcloud-server-693ca9a92ff268ecbd16c7bd7795a177869ea785.zip |
Add unit tests for gc() for \OC\Cache\FileGlobalGC
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/cache/fileglobalgc.php | 34 |
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); + } } |