diff options
author | 2015-05-20 12:16:24 -0700 | |
---|---|---|
committer | 2015-05-20 12:16:24 -0700 | |
commit | 0e6cd6c624dd9be7543e9f4c1ea4168ecb622a59 (patch) | |
tree | 4cb039be6578433c48cb2ff7818f0e1592fd84cf | |
parent | a42c1fe8aeddff6e1fe13b7ee2d990999f2867c6 (diff) | |
parent | 8166675a214c73a077c68ae3e860bf9f6a440008 (diff) |
Merge pull request #1678 from murgatroid99/objective_c_more_interop
Added cancel_after_first_response test
-rw-r--r-- | src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m index 7e063fddb4..8e0e11d23d 100644 --- a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m +++ b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m @@ -269,4 +269,37 @@ [self waitForExpectationsWithTimeout:1 handler:nil]; } +- (void)testCancelAfterFirstResponseRPC { + __weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterFirstResponse"]; + + // A buffered pipe to which we write a single value but never close + GRXBufferedPipe *requestsBuffer = [[GRXBufferedPipe alloc] init]; + + __block BOOL receivedResponse = NO; + + id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 + requestedResponseSize:@31415]; + + [requestsBuffer writeValue:request]; + + __block ProtoRPC *call = [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer + handler:^(BOOL done, + RMTStreamingOutputCallResponse *response, + NSError *error) { + if (receivedResponse) { + XCTAssert(done, @"Unexpected extra response %@", response); + XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED); + [expectation fulfill]; + } else { + XCTAssertNil(error, @"Finished with unexpected error: %@", error); + XCTAssertFalse(done, @"Finished without response"); + XCTAssertNotNil(response); + receivedResponse = YES; + [call cancel]; + } + }]; + [call start]; + [self waitForExpectationsWithTimeout:4 handler:nil]; +} + @end |