-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: propagate clickhouse error code to ServerError (#266)
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SimPod\ClickHouseClient\Tests\Exception; | ||
|
||
use Nyholm\Psr7\Factory\Psr17Factory; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use SimPod\ClickHouseClient\Exception\ServerError; | ||
use SimPod\ClickHouseClient\Tests\TestCaseBase; | ||
|
||
#[CoversClass(ServerError::class)] | ||
final class ServerErrorTest extends TestCaseBase | ||
{ | ||
public function testParseCode(): void | ||
{ | ||
$psr17Factory = new Psr17Factory(); | ||
$response = $psr17Factory->createResponse(501) | ||
->withBody( | ||
$psr17Factory->createStream( | ||
// phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | ||
"Code: 48. DB::Exception: Table engine Distributed doesn't support mutations. (NOT_IMPLEMENTED) (version 24.3.12.75 (official build))", | ||
), | ||
); | ||
|
||
$serverError = ServerError::fromResponse($response); | ||
|
||
self::assertSame(48, $serverError->getCode()); | ||
} | ||
} |