feat(tests): Test that mtime is the same after move or rename

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2024-02-20 14:41:43 +01:00
parent c0d84f9fb2
commit 531ec42b64
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -243,12 +243,14 @@ abstract class Storage extends \Test\TestCase {
public function testMove($source, $target) {
$this->initSourceAndTarget($source);
$mTime = $this->instance->filemtime($source);
$this->instance->rename($source, $target);
$this->wait();
$this->assertTrue($this->instance->file_exists($target), $target . ' was not created');
$this->assertFalse($this->instance->file_exists($source), $source . ' still exists');
$this->assertSameAsLorem($target);
$this->assertEquals($mTime, $this->instance->filemtime($target), 'mtime was not preserved by move');
}
/**
@ -271,11 +273,13 @@ abstract class Storage extends \Test\TestCase {
public function testMoveOverwrite($source, $target) {
$this->initSourceAndTarget($source, $target);
$mTime = $this->instance->filemtime($source);
$this->instance->rename($source, $target);
$this->assertTrue($this->instance->file_exists($target), $target . ' was not created');
$this->assertFalse($this->instance->file_exists($source), $source . ' still exists');
$this->assertSameAsLorem($target);
$this->assertEquals($mTime, $this->instance->filemtime($target), 'mtime was not preserved by move');
}
public function testLocal() {
@ -485,6 +489,10 @@ abstract class Storage extends \Test\TestCase {
$this->instance->file_put_contents('source/test2.txt', 'qwerty');
$this->instance->mkdir('source/subfolder');
$this->instance->file_put_contents('source/subfolder/test.txt', 'bar');
$mTimeDirectory = $this->instance->filemtime('source');
$mTimeTestFile = $this->instance->filemtime('source/subfolder/test.txt');
$this->instance->rename('source', 'target');
$this->assertFalse($this->instance->file_exists('source'));
@ -505,6 +513,8 @@ abstract class Storage extends \Test\TestCase {
$this->assertEquals('foo', $this->instance->file_get_contents('target/test1.txt'));
$this->assertEquals('qwerty', $this->instance->file_get_contents('target/test2.txt'));
$this->assertEquals('bar', $this->instance->file_get_contents('target/subfolder/test.txt'));
$this->assertEquals($mTimeDirectory, $this->instance->filemtime('target'), 'directory mtime was not preserved by rename');
$this->assertEquals($mTimeTestFile, $this->instance->filemtime('target/subfolder/test.txt'), 'file mtime was not preserved by rename');
}
public function testRenameOverWriteDirectory() {