diff options
author | Andreas Fischer <bantu@owncloud.com> | 2013-09-23 18:13:12 +0400 |
---|---|---|
committer | Andreas Fischer <bantu@owncloud.com> | 2013-09-30 01:24:33 +0400 |
commit | e01efd3887400ab26341260de48c23cc27a6eb82 (patch) | |
tree | 4b92509a2850f188f13b66d92bc3af3af2177941 /tests | |
parent | e71c7ee635728013e3b97583df838bbc96efbd01 (diff) |
Cherry-pick of 5d671a8 onto stable5.
recreate an etag within the scanner if the cache contains an empty etag
Conflicts:
lib/files/cache/cache.php
tests/lib/files/cache/scanner.php
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/cache/scanner.php | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php index 916ac449f29..3f3a045377a 100644 --- a/tests/lib/files/cache/scanner.php +++ b/tests/lib/files/cache/scanner.php @@ -24,6 +24,21 @@ class Scanner extends \PHPUnit_Framework_TestCase { */ private $cache; + function setUp() { + $this->storage = new \OC\Files\Storage\Temporary(array()); + $this->scanner = new \OC\Files\Cache\Scanner($this->storage); + $this->cache = new \OC\Files\Cache\Cache($this->storage); + } + + function tearDown() { + if ($this->cache) { + $ids = $this->cache->getAll(); + $permissionsCache = $this->storage->getPermissionsCache(); + $permissionsCache->removeMultiple($ids, \OC_User::getUser()); + $this->cache->clear(); + } + } + function testFile() { $data = "dummy file data\n"; $this->storage->file_put_contents('foo.txt', $data); @@ -194,16 +209,28 @@ class Scanner extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->cache->inCache('folder/bar.txt')); } - function setUp() { - $this->storage = new \OC\Files\Storage\Temporary(array()); - $this->scanner = new \OC\Files\Cache\Scanner($this->storage); - $this->cache = new \OC\Files\Cache\Cache($this->storage); - } + public function testETagRecreation() { + $this->fillTestFolders(); - function tearDown() { - $ids = $this->cache->getAll(); - $permissionsCache = $this->storage->getPermissionsCache(); - $permissionsCache->removeMultiple($ids, \OC_User::getUser()); - $this->cache->clear(); + $this->scanner->scan('folder/bar.txt'); + + // manipulate etag to simulate an empty etag + $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG); + $data0 = $this->cache->get('folder/bar.txt'); + $data1 = $this->cache->get('folder'); + $data2 = $this->cache->get(''); + $data0['etag'] = ''; + $this->cache->put('folder/bar.txt', $data0); + + // rescan + $this->scanner->scan('folder/bar.txt', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG); + + // verify cache content + $newData0 = $this->cache->get('folder/bar.txt'); + $newData1 = $this->cache->get('folder'); + $newData2 = $this->cache->get(''); + $this->assertNotEmpty($newData0['etag']); + $this->assertNotEquals($data1['etag'], $newData1['etag']); + $this->assertNotEquals($data2['etag'], $newData2['etag']); } } |