diff --git a/packages/google-maps-routing/src/v2/routes_client.ts b/packages/google-maps-routing/src/v2/routes_client.ts index 1db4d9b849b..24abdd457aa 100644 --- a/packages/google-maps-routing/src/v2/routes_client.ts +++ b/packages/google-maps-routing/src/v2/routes_client.ts @@ -198,7 +198,7 @@ export class RoutesClient { computeRouteMatrix: new this._gaxModule.StreamDescriptor( this._gaxModule.StreamType.SERVER_STREAMING, !!opts.fallback, - /* gaxStreamingRetries: */ false + !!opts.gaxServerStreamingRetries ), }; diff --git a/packages/google-maps-routing/test/gapic_routes_v2.ts b/packages/google-maps-routing/test/gapic_routes_v2.ts index 9f1eca2d124..55dbe6475db 100644 --- a/packages/google-maps-routing/test/gapic_routes_v2.ts +++ b/packages/google-maps-routing/test/gapic_routes_v2.ts @@ -377,6 +377,35 @@ describe('v2.RoutesClient', () => { assert.deepStrictEqual(response, expectedResponse); }); + it('invokes computeRouteMatrix without error and gaxServerStreamingRetries enabled', async () => { + const client = new routesModule.v2.RoutesClient({ + gaxServerStreamingRetries: true, + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.maps.routing.v2.ComputeRouteMatrixRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.maps.routing.v2.RouteMatrixElement() + ); + client.innerApiCalls.computeRouteMatrix = + stubServerStreamingCall(expectedResponse); + const stream = client.computeRouteMatrix(request); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + (response: protos.google.maps.routing.v2.RouteMatrixElement) => { + resolve(response); + } + ); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); + it('invokes computeRouteMatrix with error', async () => { const client = new routesModule.v2.RoutesClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, @@ -433,5 +462,11 @@ describe('v2.RoutesClient', () => { }); await assert.rejects(promise, expectedError); }); + it('should create a client with gaxServerStreamingRetries enabled', () => { + const client = new routesModule.v2.RoutesClient({ + gaxServerStreamingRetries: true, + }); + assert(client); + }); }); });