mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Handled connection exceptions in Health action
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
namespace ShlinkioTest\Shlink\Rest\Action;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||
@@ -67,4 +68,26 @@ class HealthActionTest extends TestCase
|
||||
$this->assertEquals('application/health+json', $resp->getHeaderLine('Content-type'));
|
||||
$ping->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function failResponseIsReturnedWhenConnectionThrowsException()
|
||||
{
|
||||
$ping = $this->conn->ping()->willThrow(Exception::class);
|
||||
|
||||
/** @var JsonResponse $resp */
|
||||
$resp = $this->action->handle(new ServerRequest());
|
||||
$payload = $resp->getPayload();
|
||||
|
||||
$this->assertEquals(503, $resp->getStatusCode());
|
||||
$this->assertEquals('fail', $payload['status']);
|
||||
$this->assertEquals('1.2.3', $payload['version']);
|
||||
$this->assertEquals([
|
||||
'about' => 'https://shlink.io',
|
||||
'project' => 'https://github.com/shlinkio/shlink',
|
||||
], $payload['links']);
|
||||
$this->assertEquals('application/health+json', $resp->getHeaderLine('Content-type'));
|
||||
$ping->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user