mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-07 14:36:44 -04:00
- Deleting a Docker Compose preview removed every top-level network and volume named in the compose file, so it could disconnect coolify-proxy from the coolify network or a shared proxy network and delete a shared named volume. It now removes only the network and volumes that Coolify generated for that preview, and a network only when no other container uses it. - A deployment that stops with an explained error (unsafe compose, missing secret keys, invalid build variable names) shows the explanation once, followed by "Deployment failed.". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
3.1 KiB
PHP
84 lines
3.1 KiB
PHP
<?php
|
|
|
|
use App\Exceptions\DeploymentException;
|
|
use App\Exceptions\Handler;
|
|
|
|
test('DeploymentException is in the dontReport array', function () {
|
|
$handler = new Handler(app());
|
|
|
|
// Use reflection to access the protected $dontReport property
|
|
$reflection = new ReflectionClass($handler);
|
|
$property = $reflection->getProperty('dontReport');
|
|
$property->setAccessible(true);
|
|
$dontReport = $property->getValue($handler);
|
|
|
|
expect($dontReport)->toContain(DeploymentException::class);
|
|
});
|
|
|
|
test('DeploymentException can be created with a message', function () {
|
|
$exception = new DeploymentException('Test deployment error');
|
|
|
|
expect($exception->getMessage())->toBe('Test deployment error');
|
|
expect($exception)->toBeInstanceOf(Exception::class);
|
|
});
|
|
|
|
test('DeploymentException can be created with a message and code', function () {
|
|
$exception = new DeploymentException('Test error', 69420);
|
|
|
|
expect($exception->getMessage())->toBe('Test error');
|
|
expect($exception->getCode())->toBe(69420);
|
|
});
|
|
|
|
test('DeploymentException can be created from another exception', function () {
|
|
$originalException = new RuntimeException('Original error', 500);
|
|
$deploymentException = DeploymentException::fromException($originalException);
|
|
|
|
expect($deploymentException->getMessage())->toBe('Original error');
|
|
expect($deploymentException->getCode())->toBe(500);
|
|
expect($deploymentException->getPrevious())->toBe($originalException);
|
|
});
|
|
|
|
test('DeploymentException is not reported when thrown', function () {
|
|
$handler = new Handler(app());
|
|
|
|
// DeploymentException should not be reported (logged)
|
|
$exception = new DeploymentException('Test deployment failure');
|
|
|
|
// Check that the exception should not be reported
|
|
$reflection = new ReflectionClass($handler);
|
|
$method = $reflection->getMethod('shouldReport');
|
|
$method->setAccessible(true);
|
|
|
|
$shouldReport = $method->invoke($handler, $exception);
|
|
|
|
expect($shouldReport)->toBeFalse();
|
|
});
|
|
|
|
test('RuntimeException is still reported when thrown', function () {
|
|
$handler = new Handler(app());
|
|
|
|
// RuntimeException should still be reported (this is for Coolify bugs)
|
|
$exception = new RuntimeException('Unexpected error in Coolify code');
|
|
|
|
// Check that the exception should be reported
|
|
$reflection = new ReflectionClass($handler);
|
|
$method = $reflection->getMethod('shouldReport');
|
|
$method->setAccessible(true);
|
|
|
|
$shouldReport = $method->invoke($handler, $exception);
|
|
|
|
expect($shouldReport)->toBeTrue();
|
|
});
|
|
|
|
test('DeploymentException marks a message as already logged only when asked', function () {
|
|
$previous = new RuntimeException('Original error');
|
|
$logged = DeploymentException::alreadyLogged('Shown in the log', 7, $previous);
|
|
|
|
expect($logged->isMessageAlreadyLogged())->toBeTrue()
|
|
->and($logged->getMessage())->toBe('Shown in the log')
|
|
->and($logged->getCode())->toBe(7)
|
|
->and($logged->getPrevious())->toBe($previous)
|
|
->and((new DeploymentException('Not shown yet'))->isMessageAlreadyLogged())->toBeFalse()
|
|
->and(DeploymentException::fromException($previous)->isMessageAlreadyLogged())->toBeFalse();
|
|
});
|