feat(external): keyso — проба живости (зависимость поиска клиентов, 13-й ключ)
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
use App\Services\External\KeysoLivenessProbe;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
uses(TestCase::class);
|
||||
|
||||
beforeEach(fn () => config()->set('services.keyso.base_url', 'https://api.keys.so'));
|
||||
|
||||
it('зелёный при 200', function () {
|
||||
Http::fake(['api.keys.so/*' => Http::response('ok', 200)]);
|
||||
expect((new KeysoLivenessProbe)->check()->light)->toBe('green');
|
||||
});
|
||||
|
||||
it('зелёный при 404 (хост достучались — keys.so жив)', function () {
|
||||
Http::fake(['api.keys.so/*' => Http::response('Not Found', 404)]);
|
||||
expect((new KeysoLivenessProbe)->check()->light)->toBe('green');
|
||||
});
|
||||
|
||||
it('красный при 5xx и при обрыве', function () {
|
||||
Http::fake(['api.keys.so/*' => Http::response('err', 503)]);
|
||||
expect((new KeysoLivenessProbe)->check()->light)->toBe('red');
|
||||
Http::fake(fn () => throw new RuntimeException('down'));
|
||||
expect((new KeysoLivenessProbe)->check()->light)->toBe('red');
|
||||
});
|
||||
|
||||
it('серый, когда base_url пуст', function () {
|
||||
config()->set('services.keyso.base_url', '');
|
||||
expect((new KeysoLivenessProbe)->check()->light)->toBe('grey');
|
||||
});
|
||||
|
||||
it('serviceKey = keyso', function () {
|
||||
expect((new KeysoLivenessProbe)->serviceKey())->toBe('keyso');
|
||||
});
|
||||
Reference in New Issue
Block a user