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 try
{ {
$version = $this->exec('--version'); $version = $this->exec('--version');
$this->version = explode("\n", $version)[0];
} }
catch(ProcessFailedException $e) catch(ProcessFailedException $e)
{ {
throw new Exception("Check installation of rclone"); 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 final class RcloneTest extends TestCase
{ {
public function testExceptionOnInvalidRclonePath(): void public function testRclonePath(): void
{ {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$rclone = new \App\Rclone\Rclone('invalid'); $rclone = new \App\Rclone\Rclone('invalid');
} }
public function testRcloneInvalidVersion(): void
public function testRcloneVersion(): void
{ {
$rclone = new \App\Rclone\Rclone(); $this->expectException(\Exception::class);
$this->assertStringContainsString('rclone', $rclone->getversion()); $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