Mock Rclone installation
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Jens True 2023-05-31 10:12:52 +00:00
parent 6d940c58b2
commit 7a6e71dc6c
3 changed files with 19 additions and 6 deletions

@ -24,11 +24,17 @@ class Rclone
try
{
$version = $this->exec('--version');
$this->version = explode("\n", $version)[0];
}
catch(ProcessFailedException $e)
{
throw new Exception("Check installation of rclone");
return;
}
$this->version = explode("\n", $version)[0];
if (!\str_contains($this->version, 'rclone')) {
throw new Exception("Rclone not recognized");
}
}

@ -3,16 +3,21 @@ use PHPUnit\Framework\TestCase;
final class RcloneTest extends TestCase
{
public function testExceptionOnInvalidRclonePath(): void
public function testRclonePath(): void
{
$this->expectException(\Exception::class);
$rclone = new \App\Rclone\Rclone('invalid');
}
public function testRcloneVersion(): void
public function testRcloneInvalidVersion(): void
{
$rclone = new \App\Rclone\Rclone();
$this->assertStringContainsString('rclone', $rclone->getversion());
$this->expectException(\Exception::class);
$rclone = new \App\Rclone\Rclone('uname');
}
public function testRcloneValidVersion(): void
{
$rclone = new \App\Rclone\Rclone('./tests/mock-rclone');
$this->assertStringContainsString('rclone', $rclone->getVersion());
}
}

2
tests/mock-rclone Executable file

@ -0,0 +1,2 @@
#!/bin/bash
echo rclone v1.53.3-DEV