diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-06-17 18:03:57 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-06-17 18:03:57 +0200 |
commit | 2ed0e6e91573489b9db0c37d1d4f3ae1c1393f00 (patch) | |
tree | 8f694637004b2846ea657bbcc35755be27e83baf /tests | |
parent | 398fe8bf3255df7ac9d301522401c4a746a0e7f9 (diff) | |
download | nextcloud-server-2ed0e6e91573489b9db0c37d1d4f3ae1c1393f00.tar.gz nextcloud-server-2ed0e6e91573489b9db0c37d1d4f3ae1c1393f00.zip |
add tests for reusing existing data in scanner
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/cache/scanner.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php index 3885c99e6d3..3dacefa2b80 100644 --- a/tests/lib/files/cache/scanner.php +++ b/tests/lib/files/cache/scanner.php @@ -104,7 +104,7 @@ class Scanner extends \PHPUnit_Framework_TestCase { $this->assertNotEquals($cachedDataFolder['size'], -1); } - function testBackgroundScan(){ + function testBackgroundScan() { $this->fillTestFolders(); $this->storage->mkdir('folder2'); $this->storage->file_put_contents('folder2/bar.txt', 'foobar'); @@ -126,6 +126,24 @@ class Scanner extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->cache->getIncomplete()); } + public function testReuseExisting() { + $this->fillTestFolders(); + + $this->scanner->scan(''); + $oldData = $this->cache->get(''); + $this->storage->unlink('folder/bar.txt'); + $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE); + $newData = $this->cache->get(''); + $this->assertNotEquals($oldData['etag'], $newData['etag']); + $this->assertEquals($oldData['size'], $newData['size']); + + $oldData = $newData; + $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG); + $newData = $this->cache->get(''); + $this->assertEquals($oldData['etag'], $newData['etag']); + $this->assertEquals(-1, $newData['size']); + } + function setUp() { $this->storage = new \OC\Files\Storage\Temporary(array()); $this->scanner = new \OC\Files\Cache\Scanner($this->storage); |