Skip to content

Commit f440264

Browse files
author
Gayathri Sairamkrishnan
committed
Confirm RuntimeErrors to HTTPResponseConvertible
1 parent cd80496 commit f440264

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

Tests/OpenAPIRuntimeTests/Errors/Test_RuntimeError.swift

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,6 @@ struct MockRuntimeErrorHandler: Sendable {
2929
}
3030

3131
final class Test_RuntimeError: XCTestCase {
32-
func testRuntimeError_returnsCorrectStatusCode() async throws {
33-
34-
let server = UniversalServer(handler: MockRuntimeErrorHandler(failWithError: RuntimeError.invalidServerURL("Invalid server URL")),
35-
middlewares: [ErrorHandlingMiddleware()])
36-
let response = try await server.handle(
37-
request: .init(soar_path: "/", method: .post),
38-
requestBody: MockHandler.requestBody,
39-
metadata: .init(),
40-
forOperation: "op",
41-
using: { MockRuntimeErrorHandler.greet($0) },
42-
deserializer: { request, body, metadata in
43-
let body = try XCTUnwrap(body)
44-
return try await String(collecting: body, upTo: 10)
45-
},
46-
serializer: { output, _ in fatalError() }
47-
)
48-
XCTAssertEqual(response.0.status, .notFound)
49-
}
5032

5133
func testRuntimeError_withUnderlyingErrorNotConfirming_returns500() async throws {
5234

@@ -67,7 +49,7 @@ final class Test_RuntimeError: XCTestCase {
6749
XCTAssertEqual(response.0.status, .internalServerError)
6850
}
6951

70-
func testRuntimeError_withUnderlyingErrorConfirming_returns500() async throws {
52+
func testRuntimeError_withUnderlyingErrorConfirming_returnsCorrectStatusCode() async throws {
7153

7254
let server = UniversalServer(handler: MockRuntimeErrorHandler(failWithError: TestErrorConvertible.testError("Test Error")),
7355
middlewares: [ErrorHandlingMiddleware()])
@@ -90,6 +72,7 @@ final class Test_RuntimeError: XCTestCase {
9072
enum TestErrorConvertible: Error, HTTPResponseConvertible {
9173
case testError(String)
9274

75+
/// HTTP status code for error cases
9376
public var httpStatus: HTTPTypes.HTTPResponse.Status {
9477
.badGateway
9578
}

0 commit comments

Comments
 (0)