Mock Rclone installation
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				ci/woodpecker/push/woodpecker Pipeline was successful
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	ci/woodpecker/push/woodpecker Pipeline was successful
				
			This commit is contained in:
		@@ -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
									
								
							
							
						
						
									
										2
									
								
								tests/mock-rclone
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					echo rclone v1.53.3-DEV
 | 
				
			||||||
		Reference in New Issue
	
	Block a user