Skip to content

Commit

Permalink
Add test for HttpErrorException
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Aug 20, 2023
1 parent 8016e15 commit 4af11bf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Amp\Http\HttpStatus;
use Amp\Http\Server\DefaultErrorHandler;
use Amp\Http\Server\ErrorHandler;
use Amp\Http\Server\HttpErrorException;
use Amp\Http\Server\Request;
use Amp\Http\Server\RequestHandler;
use Amp\Http\Server\RequestHandler\ClosureRequestHandler;
Expand Down Expand Up @@ -143,4 +144,16 @@ public function testError(): void

self::assertSame(HttpStatus::INTERNAL_SERVER_ERROR, $response->getStatus());
}

public function testHttpError(): void
{
$this->httpServer->start(new ClosureRequestHandler(function (Request $req) {
throw new HttpErrorException(401, 'test');
}), new DefaultErrorHandler());

$response = $this->httpClient->request(new ClientRequest($this->getAuthority() . "/foo"));

self::assertSame(401, $response->getStatus());
self::assertSame('test', $response->getReason());
}
}

0 comments on commit 4af11bf

Please sign in to comment.