From 9656eca5102c6ee99f7cff227226a8c927eda722 Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 18 Feb 2016 14:47:22 -0800 Subject: Added tests for code coverage --- src/objective-c/tests/GRPCClientTests.m | 45 +++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'src/objective-c/tests/GRPCClientTests.m') diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 00c4b8830d..1a82993955 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -41,11 +41,11 @@ #import #import #import - +#import static NSString * const kHostAddress = @"localhost:5050"; static NSString * const kPackage = @"grpc.testing"; static NSString * const kService = @"TestService"; - +static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; static ProtoMethod *kInexistentMethod; static ProtoMethod *kEmptyCallMethod; static ProtoMethod *kUnaryCallMethod; @@ -127,8 +127,8 @@ static ProtoMethod *kUnaryCallMethod; XCTFail(@"Received unexpected response: %@", value); } completionHandler:^(NSError *errorOrNil) { XCTAssertNotNil(errorOrNil, @"Finished without error!"); - // TODO(jcanizales): The server should return code 12 UNIMPLEMENTED, not 5 NOT FOUND. - XCTAssertEqual(errorOrNil.code, 5, @"Finished with unexpected error: %@", errorOrNil); + // + XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil); [expectation fulfill]; }]; @@ -200,7 +200,7 @@ static ProtoMethod *kUnaryCallMethod; request.fillOauthScope = YES; GRXWriter *requestsWriter = [GRXWriter writerWithValue:[request data]]; - GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress + GRPCCall *call = [[GRPCCall alloc] initWithHost:kRemoteSSLHost path:kUnaryCallMethod.HTTPPath requestsWriter:requestsWriter]; @@ -257,4 +257,39 @@ static ProtoMethod *kUnaryCallMethod; [self waitForExpectationsWithTimeout:8 handler:nil]; } +- (void)testExceptions { + // Try to set userAgentPrefix for host that is nil. This should cause + // an exception. + @try { + [GRPCCall setUserAgentPrefix:@"Foo" forHost:nil]; + XCTFail(@"Did not receive an exception when host is nil"); + } @catch(NSException *theException) { + NSLog(@"Received exception as expected: %@", theException.name); + } + + // Try to set parameters to nil for GRPCCall. This should cause an exception + @try { + GRPCCall *call = [[GRPCCall alloc] initWithHost:nil + path:nil + requestsWriter:nil]; + XCTFail(@"Did not receive an exception when parameters are nil"); + } @catch(NSException *theException) { + NSLog(@"Received exception as expected: %@", theException.name); + } + + + // Set state to Finished by force + GRXWriter *requestsWriter = [GRXWriter emptyWriter]; + [requestsWriter finishWithError:nil]; + @try { + GRPCCall *call = [[GRPCCall alloc] initWithHost:kHostAddress + path:kUnaryCallMethod.HTTPPath + requestsWriter:requestsWriter]; + XCTFail(@"Did not receive an exception when GRXWriter has incorrect state."); + } @catch(NSException *theException) { + NSLog(@"Received exception as expected: %@", theException.name); + } + +} + @end -- cgit v1.2.3 From a0414ee12f81db97deaef691563ee98d9e286680 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Tue, 23 Feb 2016 16:58:46 -0800 Subject: Addressed feedback from @jcanizales --- src/objective-c/tests/GRPCClientTests.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/objective-c/tests/GRPCClientTests.m') diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 1a82993955..8ee6ffa1ec 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -42,10 +42,12 @@ #import #import #import + static NSString * const kHostAddress = @"localhost:5050"; static NSString * const kPackage = @"grpc.testing"; static NSString * const kService = @"TestService"; static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; + static ProtoMethod *kInexistentMethod; static ProtoMethod *kEmptyCallMethod; static ProtoMethod *kUnaryCallMethod; @@ -127,7 +129,6 @@ static ProtoMethod *kUnaryCallMethod; XCTFail(@"Received unexpected response: %@", value); } completionHandler:^(NSError *errorOrNil) { XCTAssertNotNil(errorOrNil, @"Finished without error!"); - // XCTAssertEqual(errorOrNil.code, 12, @"Finished with unexpected error: %@", errorOrNil); [expectation fulfill]; }]; @@ -257,6 +258,7 @@ static ProtoMethod *kUnaryCallMethod; [self waitForExpectationsWithTimeout:8 handler:nil]; } +// todo(makaradd): Move to a different file that contains only unit tests - (void)testExceptions { // Try to set userAgentPrefix for host that is nil. This should cause // an exception. -- cgit v1.2.3 From 63f2b5b2d04404687b20c0728a226d8296542ba2 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Wed, 24 Feb 2016 13:54:48 -0800 Subject: Fixed nits. --- src/objective-c/tests/GRPCClientTests.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/objective-c/tests/GRPCClientTests.m') diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 8ee6ffa1ec..6554f06e90 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -192,7 +192,6 @@ static ProtoMethod *kUnaryCallMethod; [self waitForExpectationsWithTimeout:8 handler:nil]; } -// TODO(jcanizales): Activate this test against the remote server. - (void)testMetadata { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"RPC unauthorized."]; @@ -258,7 +257,7 @@ static ProtoMethod *kUnaryCallMethod; [self waitForExpectationsWithTimeout:8 handler:nil]; } -// todo(makaradd): Move to a different file that contains only unit tests +// TODO(makarandd): Move to a different file that contains only unit tests - (void)testExceptions { // Try to set userAgentPrefix for host that is nil. This should cause // an exception. -- cgit v1.2.3 From 1c2890d6fb559282692daffa5b3c2e65220cd5e3 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Wed, 24 Feb 2016 14:35:46 -0800 Subject: Order change of includes. --- src/objective-c/tests/GRPCClientTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/objective-c/tests/GRPCClientTests.m') diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 6554f06e90..619f2cf56d 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -35,13 +35,13 @@ #import #import +#import #import #import #import #import #import #import -#import static NSString * const kHostAddress = @"localhost:5050"; static NSString * const kPackage = @"grpc.testing"; -- cgit v1.2.3 From 7204010c05f1e9ac6c053fd2ad03c39302ba8472 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Thu, 25 Feb 2016 02:55:16 +0100 Subject: Fixing format and copyright. --- package.xml | 4 ++-- src/objective-c/tests/GRPCClientTests.m | 2 +- src/objective-c/tests/InteropTestsLocalSSL.m | 2 +- src/objective-c/tests/RxLibraryUnitTests.m | 2 +- test/cpp/util/test_credentials_provider.cc | 4 +--- test/distrib/php/distribtest.php | 32 ++++++++++++++++++++++++++++ tools/buildgen/mako_renderer.py | 2 +- 7 files changed, 39 insertions(+), 9 deletions(-) (limited to 'src/objective-c/tests/GRPCClientTests.m') diff --git a/package.xml b/package.xml index 7e987d91c4..ba9f9a09f6 100644 --- a/package.xml +++ b/package.xml @@ -10,7 +10,7 @@ grpc-packages@google.com yes - 2016-02-24 + 2016-02-25 0.8.0 @@ -989,7 +989,7 @@ Update to wrap gRPC C Core version 0.10.0 beta beta - 2016-02-24 + 2016-02-25 BSD - Simplify gRPC PHP installation #4517 diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 619f2cf56d..9a3e5b5009 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/objective-c/tests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTestsLocalSSL.m index f0f4b1d71f..155e334ecb 100644 --- a/src/objective-c/tests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTestsLocalSSL.m @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/objective-c/tests/RxLibraryUnitTests.m b/src/objective-c/tests/RxLibraryUnitTests.m index c94dcf533a..d342662814 100644 --- a/src/objective-c/tests/RxLibraryUnitTests.m +++ b/src/objective-c/tests/RxLibraryUnitTests.m @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc index cfd3ebbb11..7e1eb0d501 100644 --- a/test/cpp/util/test_credentials_provider.cc +++ b/test/cpp/util/test_credentials_provider.cc @@ -95,9 +95,7 @@ gpr_once g_once_init_provider_mu = GPR_ONCE_INIT; grpc::mutex* g_provider_mu = nullptr; CredentialsProvider* g_provider = nullptr; -void InitProviderMu() { - g_provider_mu = new grpc::mutex; -} +void InitProviderMu() { g_provider_mu = new grpc::mutex; } grpc::mutex& GetMu() { gpr_once_init(&g_once_init_provider_mu, &InitProviderMu); diff --git a/test/distrib/php/distribtest.php b/test/distrib/php/distribtest.php index 318c6f9cf0..4c34cd674b 100644 --- a/test/distrib/php/distribtest.php +++ b/test/distrib/php/distribtest.php @@ -1,4 +1,36 @@ Grpc\ChannelCredentials::createInsecure() diff --git a/tools/buildgen/mako_renderer.py b/tools/buildgen/mako_renderer.py index f629e68eb9..5f23f123c2 100755 --- a/tools/buildgen/mako_renderer.py +++ b/tools/buildgen/mako_renderer.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2.7 -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without -- cgit v1.2.3