clusev/tests/Feature/FleetTestConnectionTest.php

28 lines
764 B
PHP

<?php
namespace Tests\Feature;
use App\Models\Server;
use App\Services\FleetService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class FleetTestConnectionTest extends TestCase
{
use RefreshDatabase;
public function test_unreachable_host_returns_error_without_throwing(): void
{
$server = Server::create(['name' => 'x', 'ip' => '127.0.0.1', 'ssh_port' => 1, 'status' => 'pending']);
$server->credential()->create([
'username' => 'root', 'auth_type' => 'password', 'secret' => 'nope',
]);
$server->load('credential');
$res = app(FleetService::class)->testConnection($server);
$this->assertFalse($res['ok']);
$this->assertNotNull($res['error']);
}
}