From cb2b28639ae1c0fd3a7dca88a15d97788e018f22 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Tue, 5 Mar 2024 17:29:40 +0000 Subject: [PATCH] Remove XCT from all symbols --- .../Benchmarks/Router/RouterBenchmarks.swift | 2 +- ...ation+XCT.swift => Application+Test.swift} | 24 ++++---- ...lication.swift => ApplicationTester.swift} | 28 ++++----- ...ift => AsyncHTTPClientTestFramework.swift} | 12 ++-- ...BXCTLive.swift => LiveTestFramework.swift} | 14 ++--- ...Router.swift => RouterTestFramework.swift} | 20 +++---- .../HummingbirdTesting/TestApplication.swift | 2 +- .../HummingbirdTesting/XCTClient+types.swift | 2 +- Sources/HummingbirdTesting/XCTClient.swift | 60 +++++++++---------- Tests/HummingbirdCoreTests/ClientTests.swift | 4 +- Tests/HummingbirdCoreTests/CoreTests.swift | 2 +- Tests/HummingbirdCoreTests/TestUtils.swift | 10 ++-- 12 files changed, 90 insertions(+), 90 deletions(-) rename Sources/HummingbirdTesting/{Application+XCT.swift => Application+Test.swift} (77%) rename Sources/HummingbirdTesting/{HBXCTApplication.swift => ApplicationTester.swift} (77%) rename Sources/HummingbirdTesting/{HBXCTAsyncHTTPClient.swift => AsyncHTTPClientTestFramework.swift} (95%) rename Sources/HummingbirdTesting/{HBXCTLive.swift => LiveTestFramework.swift} (83%) rename Sources/HummingbirdTesting/{HBXCTRouter.swift => RouterTestFramework.swift} (88%) diff --git a/Benchmarks/Benchmarks/Router/RouterBenchmarks.swift b/Benchmarks/Benchmarks/Router/RouterBenchmarks.swift index dd0a4b046..92910f8f2 100644 --- a/Benchmarks/Benchmarks/Router/RouterBenchmarks.swift +++ b/Benchmarks/Benchmarks/Router/RouterBenchmarks.swift @@ -16,7 +16,7 @@ import Benchmark import HTTPTypes import Hummingbird import NIOHTTPTypes -@_spi(HBXCT) import HummingbirdCore +@_spi(HBInternal) import HummingbirdCore import Logging import NIOCore import NIOPosix diff --git a/Sources/HummingbirdTesting/Application+XCT.swift b/Sources/HummingbirdTesting/Application+Test.swift similarity index 77% rename from Sources/HummingbirdTesting/Application+XCT.swift rename to Sources/HummingbirdTesting/Application+Test.swift index a985f8025..af639cacc 100644 --- a/Sources/HummingbirdTesting/Application+XCT.swift +++ b/Sources/HummingbirdTesting/Application+Test.swift @@ -17,27 +17,27 @@ import HummingbirdCore import NIOCore /// HTTP Scheme to use with AsyncHTTPClient test framework -public enum XCTScheme: String { +public enum HBTestHTTPScheme: String { case http case https } /// Type of test framework -public struct XCTTestingSetup { +public struct HBTestingSetup { enum Internal { case router case live - case ahc(XCTScheme) + case ahc(HBTestHTTPScheme) } let value: Internal /// Test writing requests directly to router. - public static var router: XCTTestingSetup { .init(value: .router) } + public static var router: HBTestingSetup { .init(value: .router) } /// Sets up a live server and execute tests using a HTTP client. Only supports HTTP1 - public static var live: XCTTestingSetup { .init(value: .live) } + public static var live: HBTestingSetup { .init(value: .live) } /// Sets up a live server and execute tests using a HTTP client. Does not support trailer headers - public static func ahc(_ scheme: XCTScheme) -> XCTTestingSetup { .init(value: .ahc(scheme)) } + public static func ahc(_ scheme: HBTestHTTPScheme) -> HBTestingSetup { .init(value: .ahc(scheme)) } } /// Extends `HBApplicationProtocol` to support testing of applications @@ -72,13 +72,13 @@ extension HBApplicationProtocol where Responder.Context: HBRequestContext { /// - testing: indicates which type of testing framework we want /// - configuration: configuration of application public func test( - _ testingSetup: XCTTestingSetup, - _ test: @escaping @Sendable (any HBXCTClientProtocol) async throws -> Value + _ testingSetup: HBTestingSetup, + _ test: @escaping @Sendable (any HBTestClientProtocol) async throws -> Value ) async throws -> Value { - let app: any HBXCTApplication = switch testingSetup.value { - case .router: try await HBXCTRouter(app: self) - case .live: HBXCTLive(app: self) - case .ahc(let scheme): HBXCTAsyncHTTPClient(app: self, scheme: scheme) + let app: any HBApplicationTestFramework = switch testingSetup.value { + case .router: try await HBRouterTestFramework(app: self) + case .live: HBLiveTestFramework(app: self) + case .ahc(let scheme): HBAsyncHTTPClientTestFramework(app: self, scheme: scheme) } return try await app.run(test) } diff --git a/Sources/HummingbirdTesting/HBXCTApplication.swift b/Sources/HummingbirdTesting/ApplicationTester.swift similarity index 77% rename from Sources/HummingbirdTesting/HBXCTApplication.swift rename to Sources/HummingbirdTesting/ApplicationTester.swift index 0f7911fb3..c21d9ab86 100644 --- a/Sources/HummingbirdTesting/HBXCTApplication.swift +++ b/Sources/HummingbirdTesting/ApplicationTester.swift @@ -17,8 +17,8 @@ import Hummingbird import NIOCore import ServiceLifecycle -/// Response structure returned by XCT testing framework -public struct HBXCTResponse: Sendable { +/// Response structure returned by testing framework +public struct HBTestResponse: Sendable { public let head: HTTPResponse /// response status public var status: HTTPResponse.Status { self.head.status } @@ -30,8 +30,8 @@ public struct HBXCTResponse: Sendable { public let trailerHeaders: HTTPFields? } -/// Errors thrown by XCT framework. -struct HBXCTError: Error, Equatable { +/// Errors thrown by testing framework. +struct HBTestError: Error, Equatable { private enum _Internal { case notStarted case noHead @@ -53,17 +53,17 @@ struct HBXCTError: Error, Equatable { } /// Protocol for client used by HummingbirdTesting -public protocol HBXCTClientProtocol: Sendable { +public protocol HBTestClientProtocol: Sendable { /// Execute URL request and provide response func execute( uri: String, method: HTTPRequest.Method, headers: HTTPFields, body: ByteBuffer? - ) async throws -> HBXCTResponse + ) async throws -> HBTestResponse } -extension HBXCTClientProtocol { +extension HBTestClientProtocol { /// Send request to associated test framework and call test callback on the response returned /// /// - Parameters: @@ -78,18 +78,18 @@ extension HBXCTClientProtocol { method: HTTPRequest.Method, headers: HTTPFields = [:], body: ByteBuffer? = nil, - testCallback: @escaping (HBXCTResponse) async throws -> Return = { $0 } + testCallback: @escaping (HBTestResponse) async throws -> Return = { $0 } ) async throws -> Return { let response = try await execute(uri: uri, method: method, headers: headers, body: body) return try await testCallback(response) } } -/// Protocol for Test application. -protocol HBXCTApplication { - /// Associated client with XCT server type - associatedtype Client: HBXCTClientProtocol +/// Protocol for application test framework +protocol HBApplicationTestFramework { + /// Associated client for application test + associatedtype Client: HBTestClientProtocol - /// Run XCT server - func run(_ test: @escaping @Sendable (any HBXCTClientProtocol) async throws -> Value) async throws -> Value + /// Run test server + func run(_ test: @escaping @Sendable (any HBTestClientProtocol) async throws -> Value) async throws -> Value } diff --git a/Sources/HummingbirdTesting/HBXCTAsyncHTTPClient.swift b/Sources/HummingbirdTesting/AsyncHTTPClientTestFramework.swift similarity index 95% rename from Sources/HummingbirdTesting/HBXCTAsyncHTTPClient.swift rename to Sources/HummingbirdTesting/AsyncHTTPClientTestFramework.swift index cab936632..df26afa20 100644 --- a/Sources/HummingbirdTesting/HBXCTAsyncHTTPClient.swift +++ b/Sources/HummingbirdTesting/AsyncHTTPClientTestFramework.swift @@ -25,8 +25,8 @@ import ServiceLifecycle import XCTest /// Test using a live server and AsyncHTTPClient as a client -final class HBXCTAsyncHTTPClient: HBXCTApplication { - struct Client: HBXCTClientProtocol { +final class HBAsyncHTTPClientTestFramework: HBApplicationTestFramework { + struct Client: HBTestClientProtocol { let client: HTTPClient let urlPrefix: String let timeout: TimeAmount @@ -37,7 +37,7 @@ final class HBXCTAsyncHTTPClient: HBXCTApplication { method: HTTPRequest.Method, headers: HTTPFields = [:], body: ByteBuffer? = nil - ) async throws -> HBXCTResponse { + ) async throws -> HBTestResponse { let url = "\(self.urlPrefix)\(uri.first == "/" ? "" : "/")\(uri)" var request = HTTPClientRequest(url: url) request.method = .init(method) @@ -49,14 +49,14 @@ final class HBXCTAsyncHTTPClient: HBXCTApplication { } } - init(app: App, scheme: XCTScheme) { + init(app: App, scheme: HBTestHTTPScheme) { self.timeout = .seconds(15) self.application = TestApplication(base: app) self.scheme = scheme } /// Start tests - func run(_ test: @escaping @Sendable (HBXCTClientProtocol) async throws -> Value) async throws -> Value { + func run(_ test: @escaping @Sendable (HBTestClientProtocol) async throws -> Value) async throws -> Value { try await withThrowingTaskGroup(of: Void.self) { group in let serviceGroup = ServiceGroup( configuration: .init( @@ -90,7 +90,7 @@ final class HBXCTAsyncHTTPClient: HBXCTApplication { } let application: TestApplication - let scheme: XCTScheme + let scheme: HBTestHTTPScheme let timeout: TimeAmount } diff --git a/Sources/HummingbirdTesting/HBXCTLive.swift b/Sources/HummingbirdTesting/LiveTestFramework.swift similarity index 83% rename from Sources/HummingbirdTesting/HBXCTLive.swift rename to Sources/HummingbirdTesting/LiveTestFramework.swift index ac7db79f0..5c794902f 100644 --- a/Sources/HummingbirdTesting/HBXCTLive.swift +++ b/Sources/HummingbirdTesting/LiveTestFramework.swift @@ -23,9 +23,9 @@ import ServiceLifecycle import XCTest /// Test using a live server -final class HBXCTLive: HBXCTApplication { - struct Client: HBXCTClientProtocol { - let client: HBXCTClient +final class HBLiveTestFramework: HBApplicationTestFramework { + struct Client: HBTestClientProtocol { + let client: HBTestClient /// Send request and call test callback on the response returned func execute( @@ -33,10 +33,10 @@ final class HBXCTLive: HBXCTApplication { method: HTTPRequest.Method, headers: HTTPFields = [:], body: ByteBuffer? = nil - ) async throws -> HBXCTResponse { + ) async throws -> HBTestResponse { var headers = headers headers[.connection] = "keep-alive" - let request = HBXCTClient.Request(uri, method: method, authority: "localhost", headers: headers, body: body) + let request = HBTestClient.Request(uri, method: method, authority: "localhost", headers: headers, body: body) let response = try await client.execute(request) return .init(head: response.head, body: response.body ?? ByteBuffer(), trailerHeaders: response.trailerHeaders) } @@ -48,7 +48,7 @@ final class HBXCTLive: HBXCTApplication { } /// Start tests - func run(_ test: @escaping @Sendable (HBXCTClientProtocol) async throws -> Value) async throws -> Value { + func run(_ test: @escaping @Sendable (HBTestClientProtocol) async throws -> Value) async throws -> Value { try await withThrowingTaskGroup(of: Void.self) { group in let serviceGroup = ServiceGroup( configuration: .init( @@ -61,7 +61,7 @@ final class HBXCTLive: HBXCTApplication { try await serviceGroup.run() } let port = await self.application.portPromise.wait() - let client = HBXCTClient( + let client = HBTestClient( host: "localhost", port: port, configuration: .init(timeout: self.timeout), diff --git a/Sources/HummingbirdTesting/HBXCTRouter.swift b/Sources/HummingbirdTesting/RouterTestFramework.swift similarity index 88% rename from Sources/HummingbirdTesting/HBXCTRouter.swift rename to Sources/HummingbirdTesting/RouterTestFramework.swift index 9c727234a..4806e6b45 100644 --- a/Sources/HummingbirdTesting/HBXCTRouter.swift +++ b/Sources/HummingbirdTesting/RouterTestFramework.swift @@ -15,8 +15,8 @@ import Atomics import HTTPTypes import NIOEmbedded -@_spi(HBXCT) import Hummingbird -@_spi(HBXCT) import HummingbirdCore +@_spi(HBInternal) import Hummingbird +@_spi(HBInternal) import HummingbirdCore import Logging import NIOConcurrencyHelpers import NIOCore @@ -25,7 +25,7 @@ import NIOPosix import ServiceLifecycle /// Test sending requests directly to router. This does not setup a live server -struct HBXCTRouter: HBXCTApplication where Responder.Context: HBBaseRequestContext { +struct HBRouterTestFramework: HBApplicationTestFramework where Responder.Context: HBBaseRequestContext { let responder: Responder let makeContext: @Sendable (Logger) -> Responder.Context let services: [any Service] @@ -46,7 +46,7 @@ struct HBXCTRouter: HBXCTApplication where Responder.Con } /// Run test - func run(_ test: @escaping @Sendable (HBXCTClientProtocol) async throws -> Value) async throws -> Value { + func run(_ test: @escaping @Sendable (HBTestClientProtocol) async throws -> Value) async throws -> Value { let client = Client( responder: self.responder, logger: self.logger, @@ -88,15 +88,15 @@ struct HBXCTRouter: HBXCTApplication where Responder.Con } } - /// HBXCTRouter client. Constructs an `HBRequest` sends it to the router and then converts - /// resulting response back to XCT response type - struct Client: HBXCTClientProtocol { + /// HBRouterTestFramework client. Constructs an `HBRequest` sends it to the router and then converts + /// resulting response back to test response type + struct Client: HBTestClientProtocol { let responder: Responder let logger: Logger let makeContext: @Sendable (Logger) -> Responder.Context - func execute(uri: String, method: HTTPRequest.Method, headers: HTTPFields, body: ByteBuffer?) async throws -> HBXCTResponse { - return try await withThrowingTaskGroup(of: HBXCTResponse.self) { group in + func execute(uri: String, method: HTTPRequest.Method, headers: HTTPFields, body: ByteBuffer?) async throws -> HBTestResponse { + return try await withThrowingTaskGroup(of: HBTestResponse.self) { group in let (stream, source) = HBRequestBody.makeStream() let request = HBRequest( head: .init(method: method, scheme: "http", authority: "localhost", path: uri, headerFields: headers), @@ -118,7 +118,7 @@ struct HBXCTRouter: HBXCTApplication where Responder.Con let responseWriter = RouterResponseWriter() let trailerHeaders = try await response.body.write(responseWriter) return responseWriter.collated.withLockedValue { collated in - HBXCTResponse(head: response.head, body: collated, trailerHeaders: trailerHeaders) + HBTestResponse(head: response.head, body: collated, trailerHeaders: trailerHeaders) } } diff --git a/Sources/HummingbirdTesting/TestApplication.swift b/Sources/HummingbirdTesting/TestApplication.swift index 663264ef4..eecccde65 100644 --- a/Sources/HummingbirdTesting/TestApplication.swift +++ b/Sources/HummingbirdTesting/TestApplication.swift @@ -21,7 +21,7 @@ import ServiceLifecycle /// TestApplication used to wrap HBApplication being tested. /// /// This is needed to override the `onServerRunning` function -struct TestApplication: HBApplicationProtocol, Service { +internal struct TestApplication: HBApplicationProtocol, Service { typealias Responder = BaseApp.Responder typealias ChildChannel = BaseApp.ChildChannel diff --git a/Sources/HummingbirdTesting/XCTClient+types.swift b/Sources/HummingbirdTesting/XCTClient+types.swift index db6909d85..968ff0fc0 100644 --- a/Sources/HummingbirdTesting/XCTClient+types.swift +++ b/Sources/HummingbirdTesting/XCTClient+types.swift @@ -17,7 +17,7 @@ import HTTPTypes import NIOCore /// HTTP client types -extension HBXCTClient { +extension HBTestClient { public enum Error: Swift.Error { case invalidURL case malformedResponse diff --git a/Sources/HummingbirdTesting/XCTClient.swift b/Sources/HummingbirdTesting/XCTClient.swift index 4f9c71b9e..1ac6ca630 100644 --- a/Sources/HummingbirdTesting/XCTClient.swift +++ b/Sources/HummingbirdTesting/XCTClient.swift @@ -23,7 +23,7 @@ import NIOSSL /// /// This HTTP client is used for internal testing of Hummingbird and is also /// the client used by `.live` testing framework. -public struct HBXCTClient: Sendable { +public struct HBTestClient: Sendable { public let channelPromise: EventLoopPromise let eventLoopGroup: EventLoopGroup let eventLoopGroupProvider: NIOEventLoopGroupProvider @@ -31,7 +31,7 @@ public struct HBXCTClient: Sendable { let port: Int let configuration: Configuration - /// HBXCT configuration + /// HBTestClient configuration public struct Configuration: Sendable { public init( tlsConfiguration: TLSConfiguration? = nil, @@ -51,7 +51,7 @@ public struct HBXCTClient: Sendable { public let serverName: String? } - /// Initialize HBXCTClient + /// Initialize HBTestClient /// - Parameters: /// - host: host to connect /// - port: port to connect to @@ -97,7 +97,7 @@ public struct HBXCTClient: Sendable { .connect(host: self.host, port: self.port) .cascade(to: self.channelPromise) } catch { - self.channelPromise.fail(HBXCTClient.Error.tlsSetupFailed) + self.channelPromise.fail(HBTestClient.Error.tlsSetupFailed) } } @@ -105,7 +105,7 @@ public struct HBXCTClient: Sendable { public func shutdown() async throws { do { try await self.close() - } catch HBXCTClient.Error.connectionNotOpen { + } catch HBTestClient.Error.connectionNotOpen { } catch ChannelError.alreadyClosed {} if case .createNew = self.eventLoopGroupProvider { try await self.eventLoopGroup.shutdownGracefully() @@ -113,45 +113,45 @@ public struct HBXCTClient: Sendable { } /// GET request - public func get(_ uri: String, headers: HTTPFields = [:]) async throws -> HBXCTClient.Response { - let request = HBXCTClient.Request(uri, method: .get, headers: headers) + public func get(_ uri: String, headers: HTTPFields = [:]) async throws -> HBTestClient.Response { + let request = HBTestClient.Request(uri, method: .get, headers: headers) return try await self.execute(request) } /// HEAD request - public func head(_ uri: String, headers: HTTPFields = [:]) async throws -> HBXCTClient.Response { - let request = HBXCTClient.Request(uri, method: .head, headers: headers) + public func head(_ uri: String, headers: HTTPFields = [:]) async throws -> HBTestClient.Response { + let request = HBTestClient.Request(uri, method: .head, headers: headers) return try await self.execute(request) } /// PUT request - public func put(_ uri: String, headers: HTTPFields = [:], body: ByteBuffer) async throws -> HBXCTClient.Response { - let request = HBXCTClient.Request(uri, method: .put, headers: headers, body: body) + public func put(_ uri: String, headers: HTTPFields = [:], body: ByteBuffer) async throws -> HBTestClient.Response { + let request = HBTestClient.Request(uri, method: .put, headers: headers, body: body) return try await self.execute(request) } /// POST request - public func post(_ uri: String, headers: HTTPFields = [:], body: ByteBuffer) async throws -> HBXCTClient.Response { - let request = HBXCTClient.Request(uri, method: .post, headers: headers, body: body) + public func post(_ uri: String, headers: HTTPFields = [:], body: ByteBuffer) async throws -> HBTestClient.Response { + let request = HBTestClient.Request(uri, method: .post, headers: headers, body: body) return try await self.execute(request) } /// DELETE request - public func delete(_ uri: String, headers: HTTPFields = [:], body: ByteBuffer) async throws -> HBXCTClient.Response { - let request = HBXCTClient.Request(uri, method: .delete, headers: headers, body: body) + public func delete(_ uri: String, headers: HTTPFields = [:], body: ByteBuffer) async throws -> HBTestClient.Response { + let request = HBTestClient.Request(uri, method: .delete, headers: headers, body: body) return try await self.execute(request) } /// Execute request to server. Return `EventLoopFuture` that will be fulfilled with HTTP response - public func execute(_ request: HBXCTClient.Request) async throws -> HBXCTClient.Response { + public func execute(_ request: HBTestClient.Request) async throws -> HBTestClient.Response { let channel = try await getChannel() - let response = try await withThrowingTaskGroup(of: HBXCTClient.Response.self) { group in + let response = try await withThrowingTaskGroup(of: HBTestClient.Response.self) { group in group.addTask { try await Task.sleep(for: self.configuration.timeout) throw Error.readTimeout } group.addTask { - let promise = self.eventLoopGroup.any().makePromise(of: HBXCTClient.Response.self) + let promise = self.eventLoopGroup.any().makePromise(of: HBTestClient.Response.self) let task = HTTPTask(request: self.cleanupRequest(request), responsePromise: promise) channel.writeAndFlush(task, promise: nil) return try await promise.futureResult.get() @@ -164,7 +164,7 @@ public struct HBXCTClient: Sendable { } public func close() async throws { - self.channelPromise.completeWith(.failure(HBXCTClient.Error.connectionNotOpen)) + self.channelPromise.completeWith(.failure(HBTestClient.Error.connectionNotOpen)) let channel = try await getChannel() return try await channel.close() } @@ -173,7 +173,7 @@ public struct HBXCTClient: Sendable { try await self.channelPromise.futureResult.get() } - private func cleanupRequest(_ request: HBXCTClient.Request) -> HBXCTClient.Request { + private func cleanupRequest(_ request: HBTestClient.Request) -> HBTestClient.Request { var request = request if let contentLength = request.body.map(\.readableBytes) { request.headers[.contentLength] = String(describing: contentLength) @@ -195,7 +195,7 @@ public struct HBXCTClient: Sendable { /// Channel Handler for serializing request header and data private class HTTPClientRequestSerializer: ChannelOutboundHandler { - typealias OutboundIn = HBXCTClient.Request + typealias OutboundIn = HBTestClient.Request typealias OutboundOut = HTTPRequestPart func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise?) { @@ -212,7 +212,7 @@ public struct HBXCTClient: Sendable { /// Channel Handler for parsing response from server private class HTTPClientResponseHandler: ChannelInboundHandler { typealias InboundIn = HTTPResponsePart - typealias InboundOut = HBXCTClient.Response + typealias InboundOut = HBTestClient.Response private enum ResponseState { /// Waiting to parse the next response. @@ -236,7 +236,7 @@ public struct HBXCTClient: Sendable { body.writeBuffer(&part) self.state = .body(head, body) case (.end(let trailerHeaders), .body(let head, let body)): - let response = HBXCTClient.Response( + let response = HBTestClient.Response( head: head, body: body, trailerHeaders: trailerHeaders @@ -246,7 +246,7 @@ public struct HBXCTClient: Sendable { } self.state = .idle case (.end(let trailerHeaders), .head(let head)): - let response = HBXCTClient.Response( + let response = HBTestClient.Response( head: head, body: nil, trailerHeaders: trailerHeaders @@ -256,22 +256,22 @@ public struct HBXCTClient: Sendable { } self.state = .idle default: - context.fireErrorCaught(HBXCTClient.Error.malformedResponse) + context.fireErrorCaught(HBTestClient.Error.malformedResponse) } } } /// HTTP Task structure private struct HTTPTask { - let request: HBXCTClient.Request - let responsePromise: EventLoopPromise + let request: HBTestClient.Request + let responsePromise: EventLoopPromise } /// HTTP Task handler. Kicks off HTTP Request and fulfills Response promise when response is returned private class HTTPTaskHandler: ChannelDuplexHandler { - typealias InboundIn = HBXCTClient.Response + typealias InboundIn = HBTestClient.Response typealias OutboundIn = HTTPTask - typealias OutboundOut = HBXCTClient.Request + typealias OutboundOut = HBTestClient.Request var queue: CircularBuffer @@ -311,7 +311,7 @@ public struct HBXCTClient: Sendable { switch event { case let evt as IdleStateHandler.IdleStateEvent where evt == .read: while let task = self.queue.popFirst() { - task.responsePromise.fail(HBXCTClient.Error.readTimeout) + task.responsePromise.fail(HBTestClient.Error.readTimeout) } default: diff --git a/Tests/HummingbirdCoreTests/ClientTests.swift b/Tests/HummingbirdCoreTests/ClientTests.swift index a603e3111..a37df5df3 100644 --- a/Tests/HummingbirdCoreTests/ClientTests.swift +++ b/Tests/HummingbirdCoreTests/ClientTests.swift @@ -201,7 +201,7 @@ struct HTTP1ClientChannel: HBClientChannel { struct InvalidHTTPPart: Error {} extension NIOAsyncChannelInboundStream.AsyncIterator { - mutating func readResponse() async throws -> HBXCTClient.Response { + mutating func readResponse() async throws -> HBTestClient.Response { let headPart = try await self.next() guard case .head(let head) = headPart else { throw InvalidHTTPPart() } var body = ByteBuffer() @@ -220,7 +220,7 @@ extension NIOAsyncChannelInboundStream.AsyncIterator { } extension NIOAsyncChannelOutboundWriter { - func writeRequest(_ request: HBXCTClient.Request) async throws { + func writeRequest(_ request: HBTestClient.Request) async throws { try await self.write(.head(request.head)) if let body = request.body, body.readableBytes > 0 { try await self.write(.body(body)) diff --git a/Tests/HummingbirdCoreTests/CoreTests.swift b/Tests/HummingbirdCoreTests/CoreTests.swift index 9f01969de..a750b80f0 100644 --- a/Tests/HummingbirdCoreTests/CoreTests.swift +++ b/Tests/HummingbirdCoreTests/CoreTests.swift @@ -281,7 +281,7 @@ class HummingBirdCoreTests: XCTestCase { do { _ = try await client.get("/", headers: [.connection: "keep-alive"]) XCTFail("Should not get here") - } catch HBXCTClient.Error.connectionClosing { + } catch HBTestClient.Error.connectionClosing { } catch { XCTFail("Unexpected error: \(error)") } diff --git a/Tests/HummingbirdCoreTests/TestUtils.swift b/Tests/HummingbirdCoreTests/TestUtils.swift index 258ade8bb..120643b14 100644 --- a/Tests/HummingbirdCoreTests/TestUtils.swift +++ b/Tests/HummingbirdCoreTests/TestUtils.swift @@ -74,8 +74,8 @@ public func testServer( configuration: HBServerConfiguration, eventLoopGroup: EventLoopGroup, logger: Logger, - clientConfiguration: HBXCTClient.Configuration = .init(), - _ test: @escaping @Sendable (HBServer, HBXCTClient) async throws -> Value + clientConfiguration: HBTestClient.Configuration = .init(), + _ test: @escaping @Sendable (HBServer, HBTestClient) async throws -> Value ) async throws -> Value { try await testServer( responder: responder, @@ -84,7 +84,7 @@ public func testServer( eventLoopGroup: eventLoopGroup, logger: logger ) { (server: HBServer, port: Int) in - let client = HBXCTClient( + let client = HBTestClient( host: "localhost", port: port, configuration: clientConfiguration, @@ -103,8 +103,8 @@ public func testServer( configuration: HBServerConfiguration, eventLoopGroup: EventLoopGroup, logger: Logger, - clientConfiguration: HBXCTClient.Configuration = .init(), - _ test: @escaping @Sendable (HBXCTClient) async throws -> Value + clientConfiguration: HBTestClient.Configuration = .init(), + _ test: @escaping @Sendable (HBTestClient) async throws -> Value ) async throws -> Value { try await testServer( responder: responder,