Skip to content

Commit 57998ff

Browse files
test: Add tests for wrappers to integration tests
Signed-off-by: Si Beaumont <[email protected]>
1 parent eaf234b commit 57998ff

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

Tests/GRPCTests/AsyncAwaitSupport/AsyncIntegrationTests.swift

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ final class AsyncIntegrationTests: GRPCTestCase {
7373
}
7474
}
7575

76+
func testUnaryWrapper() {
77+
XCTAsyncTest {
78+
let response = try await self.echo.get(.with { $0.text = "hello" })
79+
XCTAssertEqual(response.text, "Swift echo get: hello")
80+
}
81+
}
82+
7683
func testClientStreaming() {
7784
XCTAsyncTest {
7885
let collect = self.echo.makeCollectCall()
@@ -96,15 +103,28 @@ final class AsyncIntegrationTests: GRPCTestCase {
96103
}
97104
}
98105

106+
func testClientStreamingWrapper() {
107+
XCTAsyncTest {
108+
let requests: [Echo_EchoRequest] = [
109+
.with { $0.text = "boyle" },
110+
.with { $0.text = "jeffers" },
111+
.with { $0.text = "holt" },
112+
]
113+
114+
let response = try await self.echo.collect(requests)
115+
XCTAssertEqual(response.text, "Swift echo collect: boyle jeffers holt")
116+
}
117+
}
118+
99119
func testServerStreaming() {
100120
XCTAsyncTest {
101121
let expand = self.echo.makeExpandCall(.with { $0.text = "boyle jeffers holt" })
102122

103123
let initialMetadata = try await expand.initialMetadata
104124
initialMetadata.assertFirst("200", forName: ":status")
105125

106-
let respones = try await expand.responses.map { $0.text }.collect()
107-
XCTAssertEqual(respones, [
126+
let responses = try await expand.responses.map { $0.text }.collect()
127+
XCTAssertEqual(responses, [
108128
"Swift echo expand (0): boyle",
109129
"Swift echo expand (1): jeffers",
110130
"Swift echo expand (2): holt",
@@ -118,6 +138,18 @@ final class AsyncIntegrationTests: GRPCTestCase {
118138
}
119139
}
120140

141+
func testServerStreamingWrapper() {
142+
XCTAsyncTest {
143+
let responseStream = self.echo.expand(.with { $0.text = "boyle jeffers holt" })
144+
let responses = try await responseStream.map { $0.text }.collect()
145+
XCTAssertEqual(responses, [
146+
"Swift echo expand (0): boyle",
147+
"Swift echo expand (1): jeffers",
148+
"Swift echo expand (2): holt",
149+
])
150+
}
151+
}
152+
121153
func testBidirectionalStreaming() {
122154
XCTAsyncTest {
123155
let update = self.echo.makeUpdateCall()
@@ -145,6 +177,24 @@ final class AsyncIntegrationTests: GRPCTestCase {
145177
XCTAssertTrue(status.isOk)
146178
}
147179
}
180+
181+
func testBidirectionalStreamingWrapper() {
182+
XCTAsyncTest {
183+
let requests: [Echo_EchoRequest] = [
184+
.with { $0.text = "boyle" },
185+
.with { $0.text = "jeffers" },
186+
.with { $0.text = "holt" },
187+
]
188+
189+
let responseStream = self.echo.update(requests)
190+
let responses = try await responseStream.map { $0.text }.collect()
191+
XCTAssertEqual(responses, [
192+
"Swift echo update (0): boyle",
193+
"Swift echo update (1): jeffers",
194+
"Swift echo update (2): holt",
195+
])
196+
}
197+
}
148198
}
149199

150200
extension HPACKHeaders {

0 commit comments

Comments
 (0)