@@ -454,7 +454,7 @@ final class RequestBagTests: XCTestCase {
454
454
XCTAssertEqual ( $0 as? HTTPClientError , . cancelled)
455
455
}
456
456
}
457
-
457
+
458
458
func testDidReceiveBodyPartFailedPromise( ) {
459
459
let embeddedEventLoop = EmbeddedEventLoop ( )
460
460
defer { XCTAssertNoThrow ( try embeddedEventLoop. syncShutdownGracefully ( ) ) }
@@ -468,21 +468,24 @@ final class RequestBagTests: XCTestCase {
468
468
body: . byteBuffer( . init( bytes: [ 1 ] ) )
469
469
) )
470
470
guard let request = maybeRequest else { return XCTFail ( " Expected to have a request " ) }
471
-
471
+
472
472
struct MyError : Error , Equatable { }
473
473
final class Delegate : HTTPClientResponseDelegate {
474
474
typealias Response = Void
475
475
let didFinishPromise : EventLoopPromise < Void >
476
476
init ( didFinishPromise: EventLoopPromise < Void > ) {
477
477
self . didFinishPromise = didFinishPromise
478
478
}
479
+
479
480
func didReceiveBodyPart( task: HTTPClient . Task < Void > , _ buffer: ByteBuffer ) -> EventLoopFuture < Void > {
480
481
task. eventLoop. makeFailedFuture ( MyError ( ) )
481
482
}
483
+
482
484
func didReceiveError( task: HTTPClient . Task < Void > , _ error: Error ) {
483
485
self . didFinishPromise. fail ( error)
484
486
}
485
- func didFinishRequest( task: AsyncHTTPClient . HTTPClient . Task < Void > ) throws -> Void {
487
+
488
+ func didFinishRequest( task: AsyncHTTPClient . HTTPClient . Task < Void > ) throws {
486
489
XCTFail ( " \( #function) should not be called " )
487
490
self . didFinishPromise. succeed ( ( ) )
488
491
}
@@ -506,11 +509,10 @@ final class RequestBagTests: XCTestCase {
506
509
507
510
bag. resumeRequestBodyStream ( )
508
511
XCTAssertNoThrow ( try executor. receiveRequestBody { XCTAssertEqual ( $0, ByteBuffer ( bytes: [ 1 ] ) ) } )
509
-
512
+
510
513
bag. receiveResponseHead ( . init( version: . http1_1, status: . ok) )
511
-
512
- bag. succeedRequest ( [ ByteBuffer ( [ 1 ] ) ] )
513
514
515
+ bag. succeedRequest ( [ ByteBuffer ( [ 1 ] ) ] )
514
516
515
517
XCTAssertThrowsError ( try delegate. didFinishPromise. futureResult. wait ( ) ) { error in
516
518
XCTAssertEqualTypeAndValue ( error, MyError ( ) )
0 commit comments