service controller test

This commit is contained in:
2025-04-09 11:38:14 +01:00
parent eefe6243bc
commit 6f3cf84a61
4 changed files with 302 additions and 10 deletions

View File

@@ -7,7 +7,6 @@ use App\Enums\ServiceStatus;
use App\Enums\ServiceType;
use App\Jobs\Services\DeployService;
use App\Models\Server;
use Illuminate\Support\Str;
class CreateService
{

View File

@@ -16,9 +16,10 @@ class Postgres17Driver extends DatabaseDriver
public ?string $containerId = null,
public ?array $credentials = null,
) {
$user = $credentials['user'];
$password = $credentials['password'];
$db = $credentials['db'];
$credentials = $credentials ?? $this->defaultCredentials();
$user = $credentials['user'] ?? null;
$password = $credentials['password'] ?? null;
$db = $credentials['db'] ?? null;
$this->deploymentPlan = new Plan(steps: [
new Step(

View File

@@ -36,7 +36,7 @@ class ServiceController extends Controller
$server = Server::findOrFail($request->route('server'));
$response = app(CreateService::class)->execute(
$service = app(CreateService::class)->execute(
server: $server,
name: $request->name,
category: $request->enum('category', ServiceCategory::class),
@@ -44,12 +44,11 @@ class ServiceController extends Controller
version: $request->version,
);
$service = $response['service'];
$defaultPassword = $response['defaultPassword'];
return redirect()->route('servers.show', $server)->with([
return redirect()->route('servers.show', [
'organisation' => $server->organisation->id,
'server' => $server->id,
])->with([
'success' => 'Service created successfully',
'defaultPassword' => $defaultPassword,
'service' => $service,
]);
}