diff --git a/packages/google-cloud-webrisk/src/v1/web_risk_service_client.ts b/packages/google-cloud-webrisk/src/v1/web_risk_service_client.ts index 21c9841004f..c68144c020c 100644 --- a/packages/google-cloud-webrisk/src/v1/web_risk_service_client.ts +++ b/packages/google-cloud-webrisk/src/v1/web_risk_service_client.ts @@ -17,8 +17,13 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, +} from 'google-gax'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); @@ -28,7 +33,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './web_risk_service_client_config.json'; - const version = require('../../../package.json').version; /** @@ -89,8 +93,18 @@ export class WebRiskServiceClient { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new WebRiskServiceClient({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof WebRiskServiceClient; const servicePath = @@ -110,8 +124,13 @@ export class WebRiskServiceClient { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -174,7 +193,7 @@ export class WebRiskServiceClient { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** @@ -663,8 +682,8 @@ export class WebRiskServiceClient { options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = - gax.routingHeader.fromParams({ - parent: request.parent || '', + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createSubmission(request, options, callback); diff --git a/packages/google-cloud-webrisk/src/v1beta1/web_risk_service_v1_beta1_client.ts b/packages/google-cloud-webrisk/src/v1beta1/web_risk_service_v1_beta1_client.ts index e5fd483cc86..7a0434ce418 100644 --- a/packages/google-cloud-webrisk/src/v1beta1/web_risk_service_v1_beta1_client.ts +++ b/packages/google-cloud-webrisk/src/v1beta1/web_risk_service_v1_beta1_client.ts @@ -17,8 +17,13 @@ // ** All changes to this file may be overwritten. ** /* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; +import type * as gax from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, +} from 'google-gax'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); @@ -28,7 +33,6 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './web_risk_service_v1_beta1_client_config.json'; - const version = require('../../../package.json').version; /** @@ -88,8 +92,18 @@ export class WebRiskServiceV1Beta1Client { * Pass "rest" to use HTTP/1.1 REST API instead of gRPC. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. + * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you + * need to avoid loading the default gRPC version and want to use the fallback + * HTTP implementation. Load only fallback version and pass it to the constructor: + * ``` + * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC + * const client = new WebRiskServiceV1Beta1Client({fallback: 'rest'}, gax); + * ``` */ - constructor(opts?: ClientOptions) { + constructor( + opts?: ClientOptions, + gaxInstance?: typeof gax | typeof gax.fallback + ) { // Ensure that options include all the required fields. const staticMembers = this .constructor as typeof WebRiskServiceV1Beta1Client; @@ -110,8 +124,13 @@ export class WebRiskServiceV1Beta1Client { opts['scopes'] = staticMembers.scopes; } + // Load google-gax module synchronously if needed + if (!gaxInstance) { + gaxInstance = require('google-gax') as typeof gax; + } + // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; + this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. this._gaxGrpc = new this._gaxModule.GrpcClient(opts); @@ -165,7 +184,7 @@ export class WebRiskServiceV1Beta1Client { this.innerApiCalls = {}; // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; + this.warn = this._gaxModule.warn; } /** diff --git a/packages/google-cloud-webrisk/system-test/header.ts b/packages/google-cloud-webrisk/system-test/header.ts index faecf39226f..5c288c4771f 100644 --- a/packages/google-cloud-webrisk/system-test/header.ts +++ b/packages/google-cloud-webrisk/system-test/header.ts @@ -15,20 +15,19 @@ import * as protoTypes from '../protos/protos'; import {assert} from 'chai'; import {describe, it} from 'mocha'; +import {WebRiskServiceClient} from '../src/index'; // eslint-disable-next-line @typescript-eslint/no-var-requires const http2spy = require('http2spy'); -const {WebRiskServiceV1Beta1Client} = http2spy.require( - require.resolve('../src/v1beta1') -); +const gax = http2spy.require('google-gax'); describe('header', () => { it('populates x-goog-api-client header', async () => { - const client = new WebRiskServiceV1Beta1Client(); + const client = new WebRiskServiceClient({}, gax); const request = { uri: 'http://testsafebrowsing.appspot.com/s/malware.html', threatTypes: ['MALWARE'], }; await client.searchUris( - request as unknown as protoTypes.google.cloud.webrisk.v1beta1.SearchUrisRequest + request as unknown as protoTypes.google.cloud.webrisk.v1.SearchUrisRequest ); assert.ok( /^gax\/[\w.-]+ gapic\/[\w.-]+ gl-node\/[0-9]+\.[\w.-]+ grpc\/[\w.-]+$/.test( diff --git a/packages/google-cloud-webrisk/test/gapic_web_risk_service_v1.ts b/packages/google-cloud-webrisk/test/gapic_web_risk_service_v1.ts index 30bce996b35..76f95e68efa 100644 --- a/packages/google-cloud-webrisk/test/gapic_web_risk_service_v1.ts +++ b/packages/google-cloud-webrisk/test/gapic_web_risk_service_v1.ts @@ -25,6 +25,21 @@ import * as webriskserviceModule from '../src'; import {protobuf} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -159,7 +174,6 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1.ComputeThreatListDiffResponse() ); @@ -167,11 +181,6 @@ describe('v1.WebRiskServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.computeThreatListDiff(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes computeThreatListDiff without error using callback', async () => { @@ -183,7 +192,6 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1.ComputeThreatListDiffResponse() ); @@ -206,11 +214,6 @@ describe('v1.WebRiskServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes computeThreatListDiff with error', async () => { @@ -222,7 +225,6 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.ComputeThreatListDiffRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.computeThreatListDiff = stubSimpleCall( undefined, @@ -232,11 +234,6 @@ describe('v1.WebRiskServiceClient', () => { client.computeThreatListDiff(request), expectedError ); - assert( - (client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes computeThreatListDiff with closed client', async () => { @@ -267,18 +264,12 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchUrisRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchUrisResponse() ); client.innerApiCalls.searchUris = stubSimpleCall(expectedResponse); const [response] = await client.searchUris(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchUris as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes searchUris without error using callback', async () => { @@ -290,7 +281,6 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchUrisRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchUrisResponse() ); @@ -313,11 +303,6 @@ describe('v1.WebRiskServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchUris as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes searchUris with error', async () => { @@ -329,18 +314,12 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchUrisRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.searchUris = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.searchUris(request), expectedError); - assert( - (client.innerApiCalls.searchUris as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes searchUris with closed client', async () => { @@ -368,18 +347,12 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchHashesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchHashesResponse() ); client.innerApiCalls.searchHashes = stubSimpleCall(expectedResponse); const [response] = await client.searchHashes(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchHashes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes searchHashes without error using callback', async () => { @@ -391,7 +364,6 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchHashesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchHashesResponse() ); @@ -414,11 +386,6 @@ describe('v1.WebRiskServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchHashes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes searchHashes with error', async () => { @@ -430,18 +397,12 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.SearchHashesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.searchHashes = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.searchHashes(request), expectedError); - assert( - (client.innerApiCalls.searchHashes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes searchHashes with closed client', async () => { @@ -469,26 +430,25 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.CreateSubmissionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSubmissionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1.Submission() ); client.innerApiCalls.createSubmission = stubSimpleCall(expectedResponse); const [response] = await client.createSubmission(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createSubmission as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSubmission as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSubmission as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSubmission without error using callback', async () => { @@ -500,15 +460,11 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.CreateSubmissionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSubmissionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1.Submission() ); @@ -531,11 +487,14 @@ describe('v1.WebRiskServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createSubmission as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createSubmission as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSubmission as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSubmission with error', async () => { @@ -547,26 +506,25 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.CreateSubmissionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSubmissionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createSubmission = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createSubmission(request), expectedError); - assert( - (client.innerApiCalls.createSubmission as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSubmission as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSubmission as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSubmission with closed client', async () => { @@ -578,7 +536,10 @@ describe('v1.WebRiskServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1.CreateSubmissionRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateSubmissionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createSubmission(request), expectedError); diff --git a/packages/google-cloud-webrisk/test/gapic_web_risk_service_v1_beta1_v1beta1.ts b/packages/google-cloud-webrisk/test/gapic_web_risk_service_v1_beta1_v1beta1.ts index 5a69d105250..0a5ac8b9168 100644 --- a/packages/google-cloud-webrisk/test/gapic_web_risk_service_v1_beta1_v1beta1.ts +++ b/packages/google-cloud-webrisk/test/gapic_web_risk_service_v1_beta1_v1beta1.ts @@ -25,6 +25,21 @@ import * as webriskservicev1beta1Module from '../src'; import {protobuf} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -170,7 +185,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse() ); @@ -178,11 +192,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { stubSimpleCall(expectedResponse); const [response] = await client.computeThreatListDiff(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes computeThreatListDiff without error using callback', async () => { @@ -195,7 +204,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffResponse() ); @@ -218,11 +226,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes computeThreatListDiff with error', async () => { @@ -235,7 +238,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.ComputeThreatListDiffRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.computeThreatListDiff = stubSimpleCall( undefined, @@ -245,11 +247,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { client.computeThreatListDiff(request), expectedError ); - assert( - (client.innerApiCalls.computeThreatListDiff as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes computeThreatListDiff with closed client', async () => { @@ -282,18 +279,12 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchUrisResponse() ); client.innerApiCalls.searchUris = stubSimpleCall(expectedResponse); const [response] = await client.searchUris(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchUris as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes searchUris without error using callback', async () => { @@ -306,7 +297,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchUrisResponse() ); @@ -329,11 +319,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchUris as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes searchUris with error', async () => { @@ -346,18 +331,12 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchUrisRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.searchUris = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.searchUris(request), expectedError); - assert( - (client.innerApiCalls.searchUris as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes searchUris with closed client', async () => { @@ -387,18 +366,12 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchHashesResponse() ); client.innerApiCalls.searchHashes = stubSimpleCall(expectedResponse); const [response] = await client.searchHashes(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchHashes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes searchHashes without error using callback', async () => { @@ -411,7 +384,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchHashesResponse() ); @@ -434,11 +406,6 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchHashes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes searchHashes with error', async () => { @@ -451,18 +418,12 @@ describe('v1beta1.WebRiskServiceV1Beta1Client', () => { const request = generateSampleMessage( new protos.google.cloud.webrisk.v1beta1.SearchHashesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.searchHashes = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.searchHashes(request), expectedError); - assert( - (client.innerApiCalls.searchHashes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes searchHashes with closed client', async () => {