@@ -53,7 +53,7 @@ final class ClientResponseTests: XCTestCase {
5353 XCTAssertEqual ( response. trailingMetadata, [ " bar " : " baz " ] )
5454 }
5555
56- func testAcceptedStreamResponseConvenienceMethods ( ) async throws {
56+ func testAcceptedStreamResponseConvenienceMethods_Messages ( ) async throws {
5757 let response = StreamingClientResponse (
5858 of: String . self,
5959 metadata: [ " foo " : " bar " ] ,
@@ -73,6 +73,29 @@ final class ClientResponseTests: XCTestCase {
7373 XCTAssertEqual ( messages, [ " foo " , " bar " , " baz " ] )
7474 }
7575
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+
7699 func testRejectedStreamResponseConvenienceMethods( ) async throws {
77100 let error = RPCError ( code: . aborted, message: " error message " , metadata: [ " bar " : " baz " ] )
78101 let response = StreamingClientResponse ( of: String . self, error: error)
@@ -83,6 +106,11 @@ final class ClientResponseTests: XCTestCase {
83106 } errorHandler: {
84107 XCTAssertEqual ( $0, error)
85108 }
109+ await XCTAssertThrowsRPCErrorAsync {
110+ try await response. bodyParts. collect ( )
111+ } errorHandler: {
112+ XCTAssertEqual ( $0, error)
113+ }
86114 }
87115
88116 func testStreamToSingleConversionForValidStream( ) async throws {
0 commit comments