From 64baf4baec5e6805283f02c90cb47cb0567199ad Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 14 Sep 2022 22:32:19 +0000 Subject: [PATCH] fix: preserve default values in x-goog-request-params header (#17) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 474338479 Source-Link: https://github.com/googleapis/googleapis/commit/d5d35e0353b59719e8917103b1bc7df2782bf6ba Source-Link: https://github.com/googleapis/googleapis-gen/commit/efcd3f93962a103f68f003e2a1eecde6fa216a27 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWZjZDNmOTM5NjJhMTAzZjY4ZjAwM2UyYTFlZWNkZTZmYTIxNmEyNyJ9 --- src/v2/migration_service_client.ts | 22 +- src/v2alpha/migration_service_client.ts | 22 +- test/gapic_migration_service_v2.ts | 761 +++++++++++++----------- test/gapic_migration_service_v2alpha.ts | 761 +++++++++++++----------- 4 files changed, 866 insertions(+), 700 deletions(-) diff --git a/src/v2/migration_service_client.ts b/src/v2/migration_service_client.ts index c43d8fe..fb5015c 100644 --- a/src/v2/migration_service_client.ts +++ b/src/v2/migration_service_client.ts @@ -438,7 +438,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createMigrationWorkflow( @@ -542,7 +542,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getMigrationWorkflow(request, options, callback); @@ -640,7 +640,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteMigrationWorkflow( @@ -745,7 +745,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.startMigrationWorkflow( @@ -849,7 +849,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getMigrationSubtask(request, options, callback); @@ -956,7 +956,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listMigrationWorkflows( @@ -1006,7 +1006,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMigrationWorkflows']; const callSettings = defaultCallSettings.merge(options); @@ -1061,7 +1061,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMigrationWorkflows']; const callSettings = defaultCallSettings.merge(options); @@ -1177,7 +1177,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listMigrationSubtasks(request, options, callback); @@ -1227,7 +1227,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMigrationSubtasks']; const callSettings = defaultCallSettings.merge(options); @@ -1286,7 +1286,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMigrationSubtasks']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v2alpha/migration_service_client.ts b/src/v2alpha/migration_service_client.ts index 86e252d..2ea0aa5 100644 --- a/src/v2alpha/migration_service_client.ts +++ b/src/v2alpha/migration_service_client.ts @@ -438,7 +438,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createMigrationWorkflow( @@ -542,7 +542,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getMigrationWorkflow(request, options, callback); @@ -640,7 +640,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteMigrationWorkflow( @@ -745,7 +745,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.startMigrationWorkflow( @@ -849,7 +849,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getMigrationSubtask(request, options, callback); @@ -956,7 +956,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listMigrationWorkflows( @@ -1006,7 +1006,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMigrationWorkflows']; const callSettings = defaultCallSettings.merge(options); @@ -1061,7 +1061,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMigrationWorkflows']; const callSettings = defaultCallSettings.merge(options); @@ -1177,7 +1177,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listMigrationSubtasks(request, options, callback); @@ -1227,7 +1227,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMigrationSubtasks']; const callSettings = defaultCallSettings.merge(options); @@ -1286,7 +1286,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMigrationSubtasks']; const callSettings = defaultCallSettings.merge(options); diff --git a/test/gapic_migration_service_v2.ts b/test/gapic_migration_service_v2.ts index 6b034cf..689860c 100644 --- a/test/gapic_migration_service_v2.ts +++ b/test/gapic_migration_service_v2.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; 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 @@ -222,15 +237,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.CreateMigrationWorkflowRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateMigrationWorkflowRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationWorkflow() ); @@ -238,11 +250,14 @@ describe('v2.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createMigrationWorkflow(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMigrationWorkflow without error using callback', async () => { @@ -254,15 +269,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.CreateMigrationWorkflowRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateMigrationWorkflowRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationWorkflow() ); @@ -285,11 +297,14 @@ describe('v2.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMigrationWorkflow with error', async () => { @@ -301,15 +316,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.CreateMigrationWorkflowRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateMigrationWorkflowRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMigrationWorkflow = stubSimpleCall( undefined, @@ -319,11 +331,14 @@ describe('v2.MigrationServiceClient', () => { client.createMigrationWorkflow(request), expectedError ); - assert( - (client.innerApiCalls.createMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMigrationWorkflow with closed client', async () => { @@ -335,7 +350,11 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.CreateMigrationWorkflowRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateMigrationWorkflowRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -355,15 +374,11 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.GetMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationWorkflowRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationWorkflow() ); @@ -371,11 +386,14 @@ describe('v2.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getMigrationWorkflow(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationWorkflow without error using callback', async () => { @@ -387,15 +405,11 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.GetMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationWorkflowRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationWorkflow() ); @@ -418,11 +432,14 @@ describe('v2.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationWorkflow with error', async () => { @@ -434,26 +451,25 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.GetMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationWorkflowRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getMigrationWorkflow = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getMigrationWorkflow(request), expectedError); - assert( - (client.innerApiCalls.getMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationWorkflow with closed client', async () => { @@ -465,7 +481,10 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.GetMigrationWorkflowRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetMigrationWorkflowRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getMigrationWorkflow(request), expectedError); @@ -482,15 +501,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.DeleteMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -498,11 +514,14 @@ describe('v2.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.deleteMigrationWorkflow(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMigrationWorkflow without error using callback', async () => { @@ -514,15 +533,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.DeleteMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -545,11 +561,14 @@ describe('v2.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMigrationWorkflow with error', async () => { @@ -561,15 +580,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.DeleteMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteMigrationWorkflow = stubSimpleCall( undefined, @@ -579,11 +595,14 @@ describe('v2.MigrationServiceClient', () => { client.deleteMigrationWorkflow(request), expectedError ); - assert( - (client.innerApiCalls.deleteMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMigrationWorkflow with closed client', async () => { @@ -595,7 +614,11 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.DeleteMigrationWorkflowRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'DeleteMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -615,15 +638,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.StartMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StartMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -631,11 +651,14 @@ describe('v2.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.startMigrationWorkflow(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.startMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startMigrationWorkflow without error using callback', async () => { @@ -647,15 +670,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.StartMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StartMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -678,11 +698,14 @@ describe('v2.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.startMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startMigrationWorkflow with error', async () => { @@ -694,15 +717,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.StartMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StartMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.startMigrationWorkflow = stubSimpleCall( undefined, @@ -712,11 +732,14 @@ describe('v2.MigrationServiceClient', () => { client.startMigrationWorkflow(request), expectedError ); - assert( - (client.innerApiCalls.startMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startMigrationWorkflow with closed client', async () => { @@ -728,7 +751,11 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.StartMigrationWorkflowRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'StartMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -748,15 +775,11 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.GetMigrationSubtaskRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationSubtaskRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationSubtask() ); @@ -764,11 +787,14 @@ describe('v2.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getMigrationSubtask(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMigrationSubtask as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationSubtask without error using callback', async () => { @@ -780,15 +806,11 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.GetMigrationSubtaskRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationSubtaskRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationSubtask() ); @@ -811,11 +833,14 @@ describe('v2.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMigrationSubtask as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationSubtask with error', async () => { @@ -827,26 +852,25 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.GetMigrationSubtaskRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationSubtaskRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getMigrationSubtask = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getMigrationSubtask(request), expectedError); - assert( - (client.innerApiCalls.getMigrationSubtask as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationSubtask with closed client', async () => { @@ -858,7 +882,10 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.GetMigrationSubtaskRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetMigrationSubtaskRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getMigrationSubtask(request), expectedError); @@ -875,15 +902,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationWorkflow() @@ -899,11 +923,14 @@ describe('v2.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listMigrationWorkflows(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMigrationWorkflows as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationWorkflows without error using callback', async () => { @@ -915,15 +942,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationWorkflow() @@ -956,11 +980,14 @@ describe('v2.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMigrationWorkflows as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationWorkflows with error', async () => { @@ -972,15 +999,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listMigrationWorkflows = stubSimpleCall( undefined, @@ -990,11 +1014,14 @@ describe('v2.MigrationServiceClient', () => { client.listMigrationWorkflows(request), expectedError ); - assert( - (client.innerApiCalls.listMigrationWorkflows as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationWorkflowsStream without error', async () => { @@ -1006,8 +1033,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationWorkflow() @@ -1050,12 +1081,15 @@ describe('v2.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMigrationWorkflows, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationWorkflows .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1068,8 +1102,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMigrationWorkflows.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1101,12 +1139,15 @@ describe('v2.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMigrationWorkflows, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationWorkflows .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1119,8 +1160,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationWorkflow() @@ -1148,12 +1193,15 @@ describe('v2.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationWorkflows .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1166,8 +1214,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMigrationWorkflows.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1186,12 +1238,15 @@ describe('v2.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationWorkflows .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1206,15 +1261,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationSubtask() @@ -1230,11 +1282,14 @@ describe('v2.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listMigrationSubtasks(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMigrationSubtasks as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationSubtasks without error using callback', async () => { @@ -1246,15 +1301,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationSubtask() @@ -1287,11 +1339,14 @@ describe('v2.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMigrationSubtasks as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationSubtasks with error', async () => { @@ -1303,15 +1358,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listMigrationSubtasks = stubSimpleCall( undefined, @@ -1321,11 +1373,14 @@ describe('v2.MigrationServiceClient', () => { client.listMigrationSubtasks(request), expectedError ); - assert( - (client.innerApiCalls.listMigrationSubtasks as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationSubtasksStream without error', async () => { @@ -1337,8 +1392,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationSubtask() @@ -1381,12 +1440,15 @@ describe('v2.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMigrationSubtasks, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationSubtasks .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1399,8 +1461,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMigrationSubtasks.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1432,12 +1498,15 @@ describe('v2.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMigrationSubtasks, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationSubtasks .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1450,8 +1519,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.MigrationSubtask() @@ -1479,12 +1552,15 @@ describe('v2.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationSubtasks .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1497,8 +1573,12 @@ describe('v2.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMigrationSubtasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1517,12 +1597,15 @@ describe('v2.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationSubtasks .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_migration_service_v2alpha.ts b/test/gapic_migration_service_v2alpha.ts index 0fdc0f1..bb4cc40 100644 --- a/test/gapic_migration_service_v2alpha.ts +++ b/test/gapic_migration_service_v2alpha.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; 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 @@ -223,15 +238,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.CreateMigrationWorkflowRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateMigrationWorkflowRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationWorkflow() ); @@ -239,11 +251,14 @@ describe('v2alpha.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createMigrationWorkflow(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMigrationWorkflow without error using callback', async () => { @@ -255,15 +270,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.CreateMigrationWorkflowRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateMigrationWorkflowRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationWorkflow() ); @@ -286,11 +298,14 @@ describe('v2alpha.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMigrationWorkflow with error', async () => { @@ -302,15 +317,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.CreateMigrationWorkflowRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateMigrationWorkflowRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMigrationWorkflow = stubSimpleCall( undefined, @@ -320,11 +332,14 @@ describe('v2alpha.MigrationServiceClient', () => { client.createMigrationWorkflow(request), expectedError ); - assert( - (client.innerApiCalls.createMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMigrationWorkflow with closed client', async () => { @@ -336,7 +351,11 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.CreateMigrationWorkflowRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateMigrationWorkflowRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -356,15 +375,11 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.GetMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationWorkflowRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationWorkflow() ); @@ -372,11 +387,14 @@ describe('v2alpha.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getMigrationWorkflow(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationWorkflow without error using callback', async () => { @@ -388,15 +406,11 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.GetMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationWorkflowRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationWorkflow() ); @@ -419,11 +433,14 @@ describe('v2alpha.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationWorkflow with error', async () => { @@ -435,26 +452,25 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.GetMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationWorkflowRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getMigrationWorkflow = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getMigrationWorkflow(request), expectedError); - assert( - (client.innerApiCalls.getMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationWorkflow with closed client', async () => { @@ -466,7 +482,10 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.GetMigrationWorkflowRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetMigrationWorkflowRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getMigrationWorkflow(request), expectedError); @@ -483,15 +502,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.DeleteMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -499,11 +515,14 @@ describe('v2alpha.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.deleteMigrationWorkflow(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMigrationWorkflow without error using callback', async () => { @@ -515,15 +534,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.DeleteMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -546,11 +562,14 @@ describe('v2alpha.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMigrationWorkflow with error', async () => { @@ -562,15 +581,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.DeleteMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteMigrationWorkflow = stubSimpleCall( undefined, @@ -580,11 +596,14 @@ describe('v2alpha.MigrationServiceClient', () => { client.deleteMigrationWorkflow(request), expectedError ); - assert( - (client.innerApiCalls.deleteMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMigrationWorkflow with closed client', async () => { @@ -596,7 +615,11 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.DeleteMigrationWorkflowRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'DeleteMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -616,15 +639,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.StartMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StartMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -632,11 +652,14 @@ describe('v2alpha.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.startMigrationWorkflow(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.startMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startMigrationWorkflow without error using callback', async () => { @@ -648,15 +671,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.StartMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StartMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -679,11 +699,14 @@ describe('v2alpha.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.startMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startMigrationWorkflow with error', async () => { @@ -695,15 +718,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.StartMigrationWorkflowRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StartMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.startMigrationWorkflow = stubSimpleCall( undefined, @@ -713,11 +733,14 @@ describe('v2alpha.MigrationServiceClient', () => { client.startMigrationWorkflow(request), expectedError ); - assert( - (client.innerApiCalls.startMigrationWorkflow as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startMigrationWorkflow as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startMigrationWorkflow with closed client', async () => { @@ -729,7 +752,11 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.StartMigrationWorkflowRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'StartMigrationWorkflowRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -749,15 +776,11 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.GetMigrationSubtaskRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationSubtaskRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationSubtask() ); @@ -765,11 +788,14 @@ describe('v2alpha.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getMigrationSubtask(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMigrationSubtask as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationSubtask without error using callback', async () => { @@ -781,15 +807,11 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.GetMigrationSubtaskRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationSubtaskRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationSubtask() ); @@ -812,11 +834,14 @@ describe('v2alpha.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMigrationSubtask as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationSubtask with error', async () => { @@ -828,26 +853,25 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.GetMigrationSubtaskRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMigrationSubtaskRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getMigrationSubtask = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getMigrationSubtask(request), expectedError); - assert( - (client.innerApiCalls.getMigrationSubtask as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMigrationSubtask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMigrationSubtask with closed client', async () => { @@ -859,7 +883,10 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.GetMigrationSubtaskRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetMigrationSubtaskRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getMigrationSubtask(request), expectedError); @@ -876,15 +903,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationWorkflow() @@ -900,11 +924,14 @@ describe('v2alpha.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listMigrationWorkflows(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMigrationWorkflows as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationWorkflows without error using callback', async () => { @@ -916,15 +943,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationWorkflow() @@ -957,11 +981,14 @@ describe('v2alpha.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMigrationWorkflows as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationWorkflows with error', async () => { @@ -973,15 +1000,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listMigrationWorkflows = stubSimpleCall( undefined, @@ -991,11 +1015,14 @@ describe('v2alpha.MigrationServiceClient', () => { client.listMigrationWorkflows(request), expectedError ); - assert( - (client.innerApiCalls.listMigrationWorkflows as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationWorkflows as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationWorkflowsStream without error', async () => { @@ -1007,8 +1034,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationWorkflow() @@ -1051,12 +1082,15 @@ describe('v2alpha.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMigrationWorkflows, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationWorkflows .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1069,8 +1103,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMigrationWorkflows.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1102,12 +1140,15 @@ describe('v2alpha.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMigrationWorkflows, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationWorkflows .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1120,8 +1161,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationWorkflow() @@ -1149,12 +1194,15 @@ describe('v2alpha.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationWorkflows .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1167,8 +1215,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationWorkflowsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationWorkflowsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMigrationWorkflows.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1187,12 +1239,15 @@ describe('v2alpha.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationWorkflows .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1207,15 +1262,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationSubtask() @@ -1231,11 +1283,14 @@ describe('v2alpha.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listMigrationSubtasks(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMigrationSubtasks as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationSubtasks without error using callback', async () => { @@ -1247,15 +1302,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationSubtask() @@ -1288,11 +1340,14 @@ describe('v2alpha.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMigrationSubtasks as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationSubtasks with error', async () => { @@ -1304,15 +1359,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listMigrationSubtasks = stubSimpleCall( undefined, @@ -1322,11 +1374,14 @@ describe('v2alpha.MigrationServiceClient', () => { client.listMigrationSubtasks(request), expectedError ); - assert( - (client.innerApiCalls.listMigrationSubtasks as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMigrationSubtasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMigrationSubtasksStream without error', async () => { @@ -1338,8 +1393,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationSubtask() @@ -1382,12 +1441,15 @@ describe('v2alpha.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMigrationSubtasks, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationSubtasks .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1400,8 +1462,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMigrationSubtasks.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1433,12 +1499,15 @@ describe('v2alpha.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMigrationSubtasks, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationSubtasks .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1451,8 +1520,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.MigrationSubtask() @@ -1480,12 +1553,15 @@ describe('v2alpha.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationSubtasks .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1498,8 +1574,12 @@ describe('v2alpha.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.bigquery.migration.v2alpha.ListMigrationSubtasksRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListMigrationSubtasksRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMigrationSubtasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1518,12 +1598,15 @@ describe('v2alpha.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listMigrationSubtasks .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); });