mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
test(BinaryFinder): Make sure the test is portable between systems
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
39dc1dfd41
commit
e391e50446
1 changed files with 14 additions and 6 deletions
|
|
@ -13,6 +13,8 @@ use OC\Memcache\ArrayCache;
|
|||
use OCP\ICache;
|
||||
use OCP\ICacheFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
|
||||
class BinaryFinderTest extends TestCase {
|
||||
private ICache $cache;
|
||||
|
|
@ -43,8 +45,8 @@ class BinaryFinderTest extends TestCase {
|
|||
return $default;
|
||||
});
|
||||
$finder = new BinaryFinder($this->cacheFactory, $config);
|
||||
$this->assertEquals($finder->findBinaryPath('cat'), '/usr/bin/cat');
|
||||
$this->assertEquals($this->cache->get('cat'), '/usr/bin/cat');
|
||||
$this->assertStringEndsWith('/cat', $finder->findBinaryPath('cat'));
|
||||
$this->assertStringEndsWith('/cat', $this->cache->get('cat'));
|
||||
}
|
||||
|
||||
public function testDefaultDoesNotFindCata() {
|
||||
|
|
@ -61,22 +63,28 @@ class BinaryFinderTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testCustomPathFindsCat() {
|
||||
$tmpdir = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
touch($tmpdir . '/cat');
|
||||
chmod($tmpdir . '/cat', 100);
|
||||
|
||||
$config = $this->createMock(IConfig::class);
|
||||
$config
|
||||
->method('getSystemValue')
|
||||
->with('binary_search_paths', $this->anything())
|
||||
->willReturn(['/usr/bin']);
|
||||
->willReturn([$tmpdir]);
|
||||
$finder = new BinaryFinder($this->cacheFactory, $config);
|
||||
$this->assertEquals($finder->findBinaryPath('cat'), '/usr/bin/cat');
|
||||
$this->assertEquals($this->cache->get('cat'), '/usr/bin/cat');
|
||||
$this->assertEquals($tmpdir . '/cat', $finder->findBinaryPath('cat'));
|
||||
$this->assertEquals($tmpdir . '/cat', $this->cache->get('cat'));
|
||||
}
|
||||
|
||||
public function testWrongCustomPathDoesNotFindCat() {
|
||||
$tmpdir = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
|
||||
$config = $this->createMock(IConfig::class);
|
||||
$config
|
||||
->method('getSystemValue')
|
||||
->with('binary_search_paths')
|
||||
->willReturn(['/wrong']);
|
||||
->willReturn([$tmpdir]);
|
||||
$finder = new BinaryFinder($this->cacheFactory, $config);
|
||||
$this->assertFalse($finder->findBinaryPath('cat'));
|
||||
$this->assertFalse($this->cache->get('cat'));
|
||||
|
|
|
|||
Loading…
Reference in a new issue