Skip to content

Commit

Permalink
fix: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Dec 19, 2019
1 parent 6730872 commit 6897a29
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/opentelemetry-plugin-grpc/test/grpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type TestGrpcClient = grpc.Client & {
// tslint:disable-next-line:no-any
unaryMethod: any;
// tslint:disable-next-line:no-any
UnaryMethod: any;
// tslint:disable-next-line:no-any
clientStreamMethod: any;
// tslint:disable-next-line:no-any
serverStreamMethod: any;
Expand Down Expand Up @@ -93,6 +95,24 @@ const grpcClient = {
});
},

UnaryMethod: (
client: TestGrpcClient,
request: TestRequestResponse
): Promise<TestRequestResponse> => {
return new Promise((resolve, reject) => {
return client.UnaryMethod(
request,
(err: grpc.ServiceError, response: TestRequestResponse) => {
if (err) {
reject(err);
} else {
resolve(response);
}
}
);
});
},

clientStreamMethod: (
client: TestGrpcClient,
request: TestRequestResponse[]
Expand Down Expand Up @@ -318,6 +338,13 @@ describe('GrpcPlugin', () => {
request: requestList[0],
result: requestList[0],
},
{
description: 'Unary call',
methodName: 'UnaryMethod',
method: grpcClient.UnaryMethod,
request: requestList[0],
result: requestList[0],
},
{
description: 'clientStream call',
methodName: 'ClientStreamMethod',
Expand Down

0 comments on commit 6897a29

Please sign in to comment.