Skip to content

Commit

Permalink
add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
crwilcox committed Oct 25, 2018
1 parent ace4223 commit 817c9e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,15 @@ export class GrpcClient {
return this._getCredentials(options).then(credentials => {
const grpcOptions: {[index: string]: {}} = {};
Object.keys(options).forEach(key => {
if (key.indexOf('grpc.') === 0 || key.indexOf('grpcgcp.') === 0) {
if (key.indexOf('grpc.') === 0){
grpcOptions[key] = options[key];
}
if (key.indexOf('grpc_gcp.') === 0) {
// This prefix is used to pass additional arguments that aren't
// options for grpc. Strip the prefix before passing.
const prefixLength = 'grpc_gcp.'.length;
grpcOptions[key.substr(prefixLength)] = options[key];
}
});
return new CreateStub(serviceAddress, credentials, grpcOptions);
});
Expand Down
6 changes: 4 additions & 2 deletions test/grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ describe('grpc', () => {
port: 443,
'grpc.max_send_message_length': 10 * 1024 * 1024,
'grpc.initial_reconnect_backoff_ms': 10000,
'grpc_gcp.non_grpc_option': 1,
other_dummy_options: 'test',
};
return grpcClient.createStub(DummyStub, opts).then(stub => {
Expand All @@ -188,8 +189,9 @@ describe('grpc', () => {
expect(stub.creds).to.deep.eq(dummyChannelCreds);
// tslint:disable-next-line no-any
(expect(stub.options).has as any).key([
'max_send_message_length',
'initial_reconnect_backoff_ms',
'grpc.max_send_message_length',
'grpc.initial_reconnect_backoff_ms',
'non_grpc_option'
]);
// tslint:disable-next-line no-any
(expect(stub.options).to.not.have as any).key([
Expand Down

0 comments on commit 817c9e6

Please sign in to comment.