Jens True
3b9cea1c70
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
71 lines
1.9 KiB
PHP
71 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests;
|
|
|
|
use App\Rclone\Rclone;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class RcloneTest extends TestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
exec('rclone test makefiles temp/source 2>&1');
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
exec('rclone purge temp 2>&1');
|
|
}
|
|
|
|
|
|
public function testRclonePath(): void
|
|
{
|
|
$this->expectException(\Exception::class);
|
|
$rclone = new Rclone('invalid');
|
|
$this->assertEquals('', $rclone->getVersion());
|
|
}
|
|
|
|
public function testRcloneInvalidVersion(): void
|
|
{
|
|
$this->expectException(\Exception::class);
|
|
$rclone = new Rclone('uname');
|
|
$this->assertEquals('', $rclone->getVersion());
|
|
}
|
|
|
|
public function testRcloneValidVersion(): void
|
|
{
|
|
$rclone = new Rclone();
|
|
$this->assertStringStartsWith('rclone', $rclone->getVersion());
|
|
}
|
|
|
|
public function testRcloneSize(): void
|
|
{
|
|
$rclone = new Rclone();
|
|
$size = $rclone->getSize('temp/source');
|
|
$this->assertGreaterThan(10000, $size);
|
|
|
|
$this->expectException(\Exception::class);
|
|
$this->expectExceptionMessage("ERROR");
|
|
$size = $rclone->getSize('temp/bogus-source');
|
|
$this->assertEquals(0, $size);
|
|
}
|
|
|
|
public function testRcloneCopy(): void
|
|
{
|
|
$rclone = new Rclone();
|
|
$rclone->copy('temp/source', 'temp/destination');
|
|
$this->assertDirectoryExists('temp/destination');
|
|
|
|
$rclone = new Rclone();
|
|
$rclone->copy('temp/source', 'temp/destination', ['bwlimit' => '6M']);
|
|
$this->assertDirectoryExists('temp/destination');
|
|
|
|
$this->expectException(\Exception::class);
|
|
$this->expectExceptionMessage("ERROR");
|
|
$rclone->copy('temp/bogus-source', 'temp/bogus-destination');
|
|
$this->assertDirectoryDoesNotExist('temp/bogus-destination');
|
|
}
|
|
}
|