Files
coolify/tests/Feature/HelperVersionTest.php
T
Andras Bacsai 2db26e88ab fix(jobs): stop notifying on transient CDN failures in version checks
CheckHelperImageJob now logs a warning and returns when the versions
endpoint fails instead of sending an internal notification and
rethrowing. The next scheduled run retries. PullTemplatesFromCDN also
no longer sends internal notifications on non-success responses or
exceptions; it still logs them.

Add tests checking that the stored helper version is kept and that no
notification is sent when the CDN is unavailable.
2026-10-15 15:20:57 +02:00

56 lines
1.8 KiB
PHP

<?php
use App\Jobs\CheckHelperImageJob;
use App\Models\InstanceSettings;
use App\Models\Team;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Notification;
uses(RefreshDatabase::class);
beforeEach(function () {
InstanceSettings::forceCreate(['id' => 0]);
config([
'app.env' => 'production',
'constants.coolify.helper_version' => '1.0.17',
'constants.coolify.versions_url' => 'https://cdn.example.com/coolify/versions.json',
]);
});
it('uses a newer helper version after fetching it from the CDN', function () {
Http::preventStrayRequests();
Http::fake([
'https://cdn.example.com/coolify/versions.json' => Http::response([
'coolify' => ['helper' => ['version' => '1.0.18']],
]),
]);
(new CheckHelperImageJob)->handle();
expect(InstanceSettings::findOrFail(0)->helper_version)->toBe('1.0.18')
->and(getHelperVersion())->toBe('1.0.18');
});
it('does not use a stored helper version older than the bundled version', function () {
InstanceSettings::findOrFail(0)->update(['helper_version' => '1.0.16']);
expect(getHelperVersion())->toBe('1.0.17');
});
it('keeps the stored helper version and does not notify when the CDN is unavailable', function () {
Team::factory()->create(['id' => 0])->discordNotificationSettings()->update(['discord_enabled' => true]);
InstanceSettings::findOrFail(0)->update(['helper_version' => '1.0.17']);
Notification::fake();
Http::preventStrayRequests();
Http::fake([
'https://cdn.example.com/coolify/versions.json' => Http::response('error code: 1200', 503),
]);
(new CheckHelperImageJob)->handle();
expect(InstanceSettings::findOrFail(0)->helper_version)->toBe('1.0.17');
Notification::assertNothingSent();
});