@@ -53,7 +53,7 @@ final class ClientResponseTests: XCTestCase {
53
53
XCTAssertEqual ( response. trailingMetadata, [ " bar " : " baz " ] )
54
54
}
55
55
56
- func testAcceptedStreamResponseConvenienceMethods ( ) async throws {
56
+ func testAcceptedStreamResponseConvenienceMethods_Messages ( ) async throws {
57
57
let response = StreamingClientResponse (
58
58
of: String . self,
59
59
metadata: [ " foo " : " bar " ] ,
@@ -73,6 +73,29 @@ final class ClientResponseTests: XCTestCase {
73
73
XCTAssertEqual ( messages, [ " foo " , " bar " , " baz " ] )
74
74
}
75
75
76
+ func testAcceptedStreamResponseConvenienceMethods_BodyParts( ) async throws {
77
+ let response = StreamingClientResponse (
78
+ of: String . self,
79
+ metadata: [ " foo " : " bar " ] ,
80
+ bodyParts: RPCAsyncSequence (
81
+ wrapping: AsyncThrowingStream {
82
+ $0. yield ( . message( " foo " ) )
83
+ $0. yield ( . message( " bar " ) )
84
+ $0. yield ( . message( " baz " ) )
85
+ $0. yield ( . trailingMetadata( [ " baz " : " baz " ] ) )
86
+ $0. finish ( )
87
+ }
88
+ )
89
+ )
90
+
91
+ XCTAssertEqual ( response. metadata, [ " foo " : " bar " ] )
92
+ let bodyParts = try await response. bodyParts. collect ( )
93
+ XCTAssertEqual (
94
+ bodyParts,
95
+ [ . message( " foo " ) , . message( " bar " ) , . message( " baz " ) , . trailingMetadata( [ " baz " : " baz " ] ) ]
96
+ )
97
+ }
98
+
76
99
func testRejectedStreamResponseConvenienceMethods( ) async throws {
77
100
let error = RPCError ( code: . aborted, message: " error message " , metadata: [ " bar " : " baz " ] )
78
101
let response = StreamingClientResponse ( of: String . self, error: error)
@@ -83,6 +106,11 @@ final class ClientResponseTests: XCTestCase {
83
106
} errorHandler: {
84
107
XCTAssertEqual ( $0, error)
85
108
}
109
+ await XCTAssertThrowsRPCErrorAsync {
110
+ try await response. bodyParts. collect ( )
111
+ } errorHandler: {
112
+ XCTAssertEqual ( $0, error)
113
+ }
86
114
}
87
115
88
116
func testStreamToSingleConversionForValidStream( ) async throws {
0 commit comments