From f440264e406ab86b8673892744b59dcb0d1cfeb8 Mon Sep 17 00:00:00 2001 From: Gayathri Sairamkrishnan Date: Fri, 13 Dec 2024 21:46:58 +0000 Subject: [PATCH] Confirm RuntimeErrors to HTTPResponseConvertible --- .../Errors/Test_RuntimeError.swift | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/Tests/OpenAPIRuntimeTests/Errors/Test_RuntimeError.swift b/Tests/OpenAPIRuntimeTests/Errors/Test_RuntimeError.swift index a3234369..cf41627b 100644 --- a/Tests/OpenAPIRuntimeTests/Errors/Test_RuntimeError.swift +++ b/Tests/OpenAPIRuntimeTests/Errors/Test_RuntimeError.swift @@ -29,24 +29,6 @@ struct MockRuntimeErrorHandler: Sendable { } final class Test_RuntimeError: XCTestCase { - func testRuntimeError_returnsCorrectStatusCode() async throws { - - let server = UniversalServer(handler: MockRuntimeErrorHandler(failWithError: RuntimeError.invalidServerURL("Invalid server URL")), - middlewares: [ErrorHandlingMiddleware()]) - let response = try await server.handle( - request: .init(soar_path: "/", method: .post), - requestBody: MockHandler.requestBody, - metadata: .init(), - forOperation: "op", - using: { MockRuntimeErrorHandler.greet($0) }, - deserializer: { request, body, metadata in - let body = try XCTUnwrap(body) - return try await String(collecting: body, upTo: 10) - }, - serializer: { output, _ in fatalError() } - ) - XCTAssertEqual(response.0.status, .notFound) - } func testRuntimeError_withUnderlyingErrorNotConfirming_returns500() async throws { @@ -67,7 +49,7 @@ final class Test_RuntimeError: XCTestCase { XCTAssertEqual(response.0.status, .internalServerError) } - func testRuntimeError_withUnderlyingErrorConfirming_returns500() async throws { + func testRuntimeError_withUnderlyingErrorConfirming_returnsCorrectStatusCode() async throws { let server = UniversalServer(handler: MockRuntimeErrorHandler(failWithError: TestErrorConvertible.testError("Test Error")), middlewares: [ErrorHandlingMiddleware()]) @@ -90,6 +72,7 @@ final class Test_RuntimeError: XCTestCase { enum TestErrorConvertible: Error, HTTPResponseConvertible { case testError(String) + /// HTTP status code for error cases public var httpStatus: HTTPTypes.HTTPResponse.Status { .badGateway }