Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Nov 10, 2015
1 parent 7490a6f commit 450d56a
Showing 1 changed file with 10 additions and 37 deletions.
47 changes: 10 additions & 37 deletions tests/lib/files/cache/updaterlegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use \OC\Files\Filesystem as Filesystem;
use OC\Files\Storage\Temporary;
use OC\Files\View;

class UpdaterLegacy extends \Test\TestCase {
/**
Expand Down Expand Up @@ -111,7 +112,8 @@ public function testWriteWithMountPoints() {
$storage2->getScanner()->scan(''); //initialize etags
$cache2 = $storage2->getCache();
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
$folderCachedData = $this->cache->get('folder');
$view = new View('/' . self::$user . '/files');
$folderCachedData = $view->getFileInfo('folder');
$substorageCachedData = $cache2->get('');
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
$this->assertTrue($cache2->inCache('foo.txt'));
Expand All @@ -124,7 +126,7 @@ public function testWriteWithMountPoints() {
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);

$cachedData = $this->cache->get('folder');
$cachedData = $view->getFileInfo('folder');
$this->assertInternalType('string', $folderCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
Expand Down Expand Up @@ -168,8 +170,9 @@ public function testDeleteWithMountPoints() {
$cache2 = $storage2->getCache();
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
$view = new View('/' . self::$user . '/files');
$this->assertTrue($cache2->inCache('foo.txt'));
$folderCachedData = $this->cache->get('folder');
$folderCachedData = $view->getFileInfo('folder');
$substorageCachedData = $cache2->get('');
Filesystem::unlink('folder/substorage/foo.txt');
$this->assertFalse($cache2->inCache('foo.txt'));
Expand All @@ -180,7 +183,7 @@ public function testDeleteWithMountPoints() {
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
$this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']);

$cachedData = $this->cache->get('folder');
$cachedData = $view->getFileInfo('folder');
$this->assertInternalType('string', $folderCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
Expand Down Expand Up @@ -222,8 +225,9 @@ public function testRenameWithMountPoints() {
$cache2 = $storage2->getCache();
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
$view = new View('/' . self::$user . '/files');
$this->assertTrue($cache2->inCache('foo.txt'));
$folderCachedData = $this->cache->get('folder');
$folderCachedData = $view->getFileInfo('folder');
$substorageCachedData = $cache2->get('');
$fooCachedData = $cache2->get('foo.txt');
Filesystem::rename('folder/substorage/foo.txt', 'folder/substorage/bar.txt');
Expand All @@ -240,7 +244,7 @@ public function testRenameWithMountPoints() {
// rename can cause mtime change - invalid assert
// $this->assertEquals($mtime, $cachedData['mtime']);

$cachedData = $this->cache->get('folder');
$cachedData = $view->getFileInfo('folder');
$this->assertInternalType('string', $folderCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
Expand Down Expand Up @@ -287,35 +291,4 @@ public function testTouch() {
$this->assertEquals($time, $cachedData['mtime']);
}

public function testTouchWithMountPoints() {
$storage2 = new \OC\Files\Storage\Temporary(array());
$cache2 = $storage2->getCache();
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
$this->assertTrue($cache2->inCache('foo.txt'));
$folderCachedData = $this->cache->get('folder');
$substorageCachedData = $cache2->get('');
$fooCachedData = $cache2->get('foo.txt');
$cachedData = $cache2->get('foo.txt');
$time = 1371006070;
$this->cache->put('folder', ['mtime' => $time - 100]);
Filesystem::touch('folder/substorage/foo.txt', $time);
$cachedData = $cache2->get('foo.txt');
$this->assertInternalType('string', $fooCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($fooCachedData['etag'], $cachedData['etag']);
$this->assertEquals($time, $cachedData['mtime']);

$cachedData = $cache2->get('');
$this->assertInternalType('string', $substorageCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);

$cachedData = $this->cache->get('folder');
$this->assertInternalType('string', $folderCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
$this->assertEquals($time, $cachedData['mtime']);
}

}

0 comments on commit 450d56a

Please sign in to comment.