mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-12 15:53:46 -04:00
- Remove tests that only check markup, CSS, static text, wire:key strings, framework behavior, copied app logic, or expect(true) - Replace source-grep and Reflection checks of security fixes with tests that run the real code (shell quoting, locked properties, 403 checks, webhook fork trust, log redaction, Sentinel token cleanup) - Assert response bodies and unchanged data on API error paths - Run the Traefik version job through handle() instead of private methods - Update stale tests for scheduled task props, the default Postgres image, and the disabled transfer link of unvalidated servers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
2.2 KiB
PHP
58 lines
2.2 KiB
PHP
<?php
|
|
|
|
use App\Exceptions\DeploymentException;
|
|
use App\Exceptions\Handler;
|
|
|
|
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();
|
|
});
|