Files
coolify/tests/Feature/ServiceParserServicesSectionTest.php
Andras Bacsai 455b22f26c fix(deploy): explain SSH exit 255 and handle non-map compose services
- Add a hint to failed command messages when the exit code is 255,
  which explains that the SSH connection to the server closed before
  the command finished.
- Return no services from applicationParser and serviceParser when the
  compose `services` key is empty or is not a map, so parsing does not
  fail.
- Move Server::getIp() out of the sshEndpointInUse() docblock, where it
  was misplaced and broke the class.
- Add tests for the SSH hint, for services keys that are not maps, and
  for saved compose variable values that must survive a redeploy
  (#6995).
2026-11-05 09:49:35 +01:00

35 lines
1.1 KiB
PHP

<?php
use App\Models\Environment;
use App\Models\Project;
use App\Models\Server;
use App\Models\Service;
use App\Models\StandaloneDocker;
use App\Models\Team;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Bus;
uses(RefreshDatabase::class);
it('returns no services when the services key of a service stack is not a map', function (string $compose) {
Bus::fake();
$team = Team::factory()->create();
$server = Server::factory()->create(['team_id' => $team->id]);
$destination = StandaloneDocker::where('server_id', $server->id)->firstOrFail();
$project = Project::factory()->create(['team_id' => $team->id]);
$environment = Environment::factory()->create(['project_id' => $project->id]);
$service = Service::factory()->create([
'docker_compose_raw' => $compose,
'environment_id' => $environment->id,
'server_id' => $server->id,
'destination_id' => $destination->id,
'destination_type' => $destination->getMorphClass(),
]);
expect(serviceParser($service))->toBeEmpty();
})->with([
'no value' => "services:\n",
'a string' => "services: web\n",
]);