@@ -29,7 +29,7 @@ final class FunctionsClientTests: XCTestCase {
29
29
func testInvoke( ) async throws {
30
30
let url = URL ( string: " http://localhost:5432/functions/v1/hello_world " ) !
31
31
32
- let http = HTTPClientMock ( )
32
+ let http = await HTTPClientMock ( )
33
33
. when {
34
34
$0. url. pathComponents. contains ( " hello_world " )
35
35
} return: { _ in
@@ -49,7 +49,7 @@ final class FunctionsClientTests: XCTestCase {
49
49
options: . init( headers: [ " X-Custom-Key " : " value " ] , body: body)
50
50
)
51
51
52
- let request = http. receivedRequests. last
52
+ let request = await http. receivedRequests. last
53
53
54
54
XCTAssertEqual ( request? . url, url)
55
55
XCTAssertEqual ( request? . method, . post)
@@ -59,7 +59,7 @@ final class FunctionsClientTests: XCTestCase {
59
59
}
60
60
61
61
func testInvokeWithCustomMethod( ) async throws {
62
- let http = HTTPClientMock ( ) . any { _ in try . stub( body: Empty ( ) ) }
62
+ let http = await HTTPClientMock ( ) . any { _ in try . stub( body: Empty ( ) ) }
63
63
64
64
let sut = FunctionsClient (
65
65
url: url,
@@ -70,12 +70,12 @@ final class FunctionsClientTests: XCTestCase {
70
70
71
71
try await sut. invoke ( " hello-world " , options: . init( method: . delete) )
72
72
73
- let request = http. receivedRequests. last
73
+ let request = await http. receivedRequests. last
74
74
XCTAssertEqual ( request? . method, . delete)
75
75
}
76
76
77
77
func testInvokeWithQuery( ) async throws {
78
- let http = HTTPClientMock ( ) . any { _ in try . stub( body: Empty ( ) ) }
78
+ let http = await HTTPClientMock ( ) . any { _ in try . stub( body: Empty ( ) ) }
79
79
80
80
let sut = FunctionsClient (
81
81
url: url,
@@ -91,12 +91,12 @@ final class FunctionsClientTests: XCTestCase {
91
91
)
92
92
)
93
93
94
- let request = http. receivedRequests. last
94
+ let request = await http. receivedRequests. last
95
95
XCTAssertEqual ( request? . urlRequest. url? . query, " key=value " )
96
96
}
97
97
98
98
func testInvokeWithRegionDefinedInClient( ) async throws {
99
- let http = HTTPClientMock ( )
99
+ let http = await HTTPClientMock ( )
100
100
. any { _ in try . stub( body: Empty ( ) ) }
101
101
102
102
let sut = FunctionsClient (
@@ -108,11 +108,12 @@ final class FunctionsClientTests: XCTestCase {
108
108
109
109
try await sut. invoke ( " hello-world " )
110
110
111
- XCTAssertEqual ( http. receivedRequests. last? . headers [ " x-region " ] , " ca-central-1 " )
111
+ let request = await http. receivedRequests. last
112
+ XCTAssertEqual ( request? . headers [ " x-region " ] , " ca-central-1 " )
112
113
}
113
114
114
115
func testInvokeWithRegion( ) async throws {
115
- let http = HTTPClientMock ( )
116
+ let http = await HTTPClientMock ( )
116
117
. any { _ in try . stub( body: Empty ( ) ) }
117
118
118
119
let sut = FunctionsClient (
@@ -124,11 +125,12 @@ final class FunctionsClientTests: XCTestCase {
124
125
125
126
try await sut. invoke ( " hello-world " , options: . init( region: . caCentral1) )
126
127
127
- XCTAssertEqual ( http. receivedRequests. last? . headers [ " x-region " ] , " ca-central-1 " )
128
+ let request = await http. receivedRequests. last
129
+ XCTAssertEqual ( request? . headers [ " x-region " ] , " ca-central-1 " )
128
130
}
129
131
130
132
func testInvokeWithoutRegion( ) async throws {
131
- let http = HTTPClientMock ( )
133
+ let http = await HTTPClientMock ( )
132
134
. any { _ in try . stub( body: Empty ( ) ) }
133
135
134
136
let sut = FunctionsClient (
@@ -140,11 +142,12 @@ final class FunctionsClientTests: XCTestCase {
140
142
141
143
try await sut. invoke ( " hello-world " )
142
144
143
- XCTAssertNil ( http. receivedRequests. last? . headers [ " x-region " ] )
145
+ let request = await http. receivedRequests. last
146
+ XCTAssertNil ( request? . headers [ " x-region " ] )
144
147
}
145
148
146
149
func testInvoke_shouldThrow_URLError_badServerResponse( ) async {
147
- let sut = FunctionsClient (
150
+ let sut = await FunctionsClient (
148
151
url: url,
149
152
headers: [ " Apikey " : apiKey] ,
150
153
region: nil ,
@@ -162,7 +165,7 @@ final class FunctionsClientTests: XCTestCase {
162
165
}
163
166
164
167
func testInvoke_shouldThrow_FunctionsError_httpError( ) async {
165
- let sut = FunctionsClient (
168
+ let sut = await FunctionsClient (
166
169
url: url,
167
170
headers: [ " Apikey " : apiKey] ,
168
171
region: nil ,
@@ -180,9 +183,7 @@ final class FunctionsClientTests: XCTestCase {
180
183
}
181
184
182
185
func testInvoke_shouldThrow_FunctionsError_relayError( ) async {
183
- let url = URL ( string: " http://localhost:5432/functions/v1/hello_world " ) !
184
-
185
- let sut = FunctionsClient (
186
+ let sut = await FunctionsClient (
186
187
url: self . url,
187
188
headers: [ " Apikey " : apiKey] ,
188
189
region: nil ,
0 commit comments