From c4cb93e6448f217afad33c684e02fd9e8614f976 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 27 Apr 2015 18:03:04 +0200 Subject: Added storage backend test for checkUpdate This helps testing whether checkUpdate properly returns false when no change exists --- tests/lib/files/storage/storage.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php index 62fba4c1716..4ec474f2f01 100644 --- a/tests/lib/files/storage/storage.php +++ b/tests/lib/files/storage/storage.php @@ -22,6 +22,8 @@ namespace Test\Files\Storage; +use OC\Files\Cache\Watcher; + abstract class Storage extends \Test\TestCase { /** * @var \OC\Files\Storage\Storage instance @@ -309,6 +311,19 @@ abstract class Storage extends \Test\TestCase { $this->assertTrue($this->instance->hasUpdated('/', $mtimeStart - 5)); } + /** + * Test whether checkUpdate properly returns false when there was + * no change. + */ + public function testCheckUpdate() { + $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; + $watcher = $this->instance->getWatcher(); + $watcher->setPolicy(Watcher::CHECK_ALWAYS); + $this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile)); + $this->assertTrue($watcher->checkUpdate('/lorem.txt'), 'Update detected'); + $this->assertFalse($watcher->checkUpdate('/lorem.txt'), 'No update'); + } + public function testUnlink() { $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; $this->instance->file_put_contents('/lorem.txt', file_get_contents($textFile)); -- cgit v1.2.3 From 120588dd7a22af9f1e85ad85e192c5aede92b32c Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 2 Jun 2015 15:14:37 +0200 Subject: Disable update check test when testing wrappers The checkUpdate test is intended for testing real storages, not wrappers. --- tests/lib/files/storage/storage.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php index 4ec474f2f01..2355009c9bf 100644 --- a/tests/lib/files/storage/storage.php +++ b/tests/lib/files/storage/storage.php @@ -316,6 +316,9 @@ abstract class Storage extends \Test\TestCase { * no change. */ public function testCheckUpdate() { + if ($this->instance instanceof \OC\Files\Storage\Wrapper\Wrapper) { + $this->markTestSkipped('Cannot test update check on wrappers'); + } $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; $watcher = $this->instance->getWatcher(); $watcher->setPolicy(Watcher::CHECK_ALWAYS); -- cgit v1.2.3