diff options
author | Muxi Yan <mxyan@google.com> | 2018-11-28 11:22:33 -0800 |
---|---|---|
committer | Muxi Yan <mxyan@google.com> | 2018-11-28 11:22:33 -0800 |
commit | a7c41346d8470e7eb5f10234daa08d09a48fa779 (patch) | |
tree | e84a9ff9668bd6ea579cd68d8a7b5d694eb43df2 /src/objective-c | |
parent | fd69f74b2091ae66b609ec7592905d9b20dddf88 (diff) |
Add one more cancel test
Diffstat (limited to 'src/objective-c')
-rw-r--r-- | src/objective-c/tests/InteropTests.m | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m index a9f33aab6f..2492718046 100644 --- a/src/objective-c/tests/InteropTests.m +++ b/src/objective-c/tests/InteropTests.m @@ -655,6 +655,37 @@ BOOL isRemoteInteropTest(NSString *host) { [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; } +- (void)testCancelAfterFirstRequestWithV2API { + XCTAssertNotNil([[self class] host]); + __weak XCTestExpectation *completionExpectation = + [self expectationWithDescription:@"Call completed."]; + + GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; + options.transportType = self.class.transportType; + options.PEMRootCertificates = self.class.PEMRootCertificates; + options.hostNameOverride = [[self class] hostNameOverride]; + + id request = + [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415]; + + __block GRPCStreamingProtoCall *call = [_service + fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc] + initWithInitialMetadataCallback:nil + messageCallback:^(id message) { + XCTFail(@"Received unexpected response."); + } + closeCallback:^(NSDictionary *trailingMetadata, + NSError *error) { + XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED); + [completionExpectation fulfill]; + }] + callOptions:options]; + + [call writeMessage:request]; + [call cancel]; + [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; +} + - (void)testRPCAfterClosingOpenConnections { XCTAssertNotNil([[self class] host]); __weak XCTestExpectation *expectation = |