11import ConcurrencyExtras
22@testable import Functions
33import Helpers
4+ import HTTPTypes
45import TestHelpers
56import XCTest
67
@@ -22,8 +23,8 @@ final class FunctionsClientTests: XCTestCase {
2223 )
2324 XCTAssertEqual ( client. region, " sa-east-1 " )
2425
25- XCTAssertEqual ( client. headers [ " Apikey " ] , apiKey)
26- XCTAssertNotNil ( client. headers [ " X-Client-Info " ] )
26+ XCTAssertEqual ( client. headers [ . init ( " Apikey " ) ! ] , apiKey)
27+ XCTAssertNotNil ( client. headers [ . init ( " X-Client-Info " ) ! ] )
2728 }
2829
2930 func testInvoke( ) async throws {
@@ -53,9 +54,9 @@ final class FunctionsClientTests: XCTestCase {
5354
5455 XCTAssertEqual ( request? . url, url)
5556 XCTAssertEqual ( request? . method, . post)
56- XCTAssertEqual ( request? . headers [ " Apikey " ] , apiKey)
57- XCTAssertEqual ( request? . headers [ " X-Custom-Key " ] , " value " )
58- XCTAssertEqual ( request? . headers [ " X-Client-Info " ] , " functions-swift/ \( Functions . version) " )
57+ XCTAssertEqual ( request? . headers [ . init ( " Apikey " ) ! ] , apiKey)
58+ XCTAssertEqual ( request? . headers [ . init ( " X-Custom-Key " ) ! ] , " value " )
59+ XCTAssertEqual ( request? . headers [ . init ( " X-Client-Info " ) ! ] , " functions-swift/ \( Functions . version) " )
5960 }
6061
6162 func testInvokeWithCustomMethod( ) async throws {
@@ -109,7 +110,7 @@ final class FunctionsClientTests: XCTestCase {
109110 try await sut. invoke ( " hello-world " )
110111
111112 let request = await http. receivedRequests. last
112- XCTAssertEqual ( request? . headers [ " x-region " ] , " ca-central-1 " )
113+ XCTAssertEqual ( request? . headers [ . xRegion ] , " ca-central-1 " )
113114 }
114115
115116 func testInvokeWithRegion( ) async throws {
@@ -126,7 +127,7 @@ final class FunctionsClientTests: XCTestCase {
126127 try await sut. invoke ( " hello-world " , options: . init( region: . caCentral1) )
127128
128129 let request = await http. receivedRequests. last
129- XCTAssertEqual ( request? . headers [ " x-region " ] , " ca-central-1 " )
130+ XCTAssertEqual ( request? . headers [ . xRegion ] , " ca-central-1 " )
130131 }
131132
132133 func testInvokeWithoutRegion( ) async throws {
@@ -143,7 +144,7 @@ final class FunctionsClientTests: XCTestCase {
143144 try await sut. invoke ( " hello-world " )
144145
145146 let request = await http. receivedRequests. last
146- XCTAssertNil ( request? . headers [ " x-region " ] )
147+ XCTAssertNil ( request? . headers [ . xRegion ] )
147148 }
148149
149150 func testInvoke_shouldThrow_URLError_badServerResponse( ) async {
@@ -190,7 +191,7 @@ final class FunctionsClientTests: XCTestCase {
190191 http: HTTPClientMock ( ) . any { _ in
191192 try . stub(
192193 body: Empty ( ) ,
193- headers: [ " x-relay-error " : " true " ]
194+ headers: [ . xRelayError : " true " ]
194195 )
195196 }
196197 )
@@ -206,16 +207,16 @@ final class FunctionsClientTests: XCTestCase {
206207
207208 func test_setAuth( ) {
208209 sut. setAuth ( token: " access.token " )
209- XCTAssertEqual ( sut. headers [ " Authorization " ] , " Bearer access.token " )
210+ XCTAssertEqual ( sut. headers [ . authorization ] , " Bearer access.token " )
210211 }
211212}
212213
213- extension HTTPResponse {
214+ extension Helpers . HTTPResponse {
214215 static func stub(
215216 body: any Encodable ,
216217 statusCode: Int = 200 ,
217- headers: HTTPHeaders = . init( )
218- ) throws -> HTTPResponse {
218+ headers: HTTPFields = . init( )
219+ ) throws -> Helpers . HTTPResponse {
219220 let data = try JSONEncoder ( ) . encode ( body)
220221 let response = HTTPURLResponse (
221222 url: URL ( string: " http://127.0.0.1 " ) !,
0 commit comments