26 lines
875 B
PHP
26 lines
875 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
use App\Services\External\SalesFinderLivenessProbe;
|
||
|
|
use Illuminate\Support\Facades\Http;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
uses(TestCase::class);
|
||
|
|
|
||
|
|
beforeEach(fn () => config()->set('services.sales_finder.base_url', 'https://lk.liderra.ru/finder/'));
|
||
|
|
|
||
|
|
it('зелёный при 200', function () {
|
||
|
|
Http::fake(['lk.liderra.ru/finder/*' => Http::response('<html>', 200)]);
|
||
|
|
expect((new SalesFinderLivenessProbe)->check()->light)->toBe('green');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('красный при 502', function () {
|
||
|
|
Http::fake(['lk.liderra.ru/finder/*' => Http::response('bad gateway', 502)]);
|
||
|
|
expect((new SalesFinderLivenessProbe)->check()->light)->toBe('red');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('серый, когда base_url пуст', function () {
|
||
|
|
config()->set('services.sales_finder.base_url', '');
|
||
|
|
expect((new SalesFinderLivenessProbe)->check()->light)->toBe('grey');
|
||
|
|
});
|