Added storage backend test for checkUpdate

This helps testing whether checkUpdate properly returns false when no
change exists
This commit is contained in:
Vincent Petry 2015-04-27 18:03:04 +02:00
parent 30d7f92763
commit c4cb93e644

View file

@ -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));