From a612a492a4d4016b913b97431a741c95a0cdd09d 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:34:11 +0000 Subject: [PATCH] fix: preserve default values in x-goog-request-params header (#65) - [ ] 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/v1/livestream_service_client.ts | 44 +- test/gapic_livestream_service_v1.ts | 1744 +++++++++++++-------------- 2 files changed, 885 insertions(+), 903 deletions(-) diff --git a/src/v1/livestream_service_client.ts b/src/v1/livestream_service_client.ts index 4dfe2b7..c86a71f 100644 --- a/src/v1/livestream_service_client.ts +++ b/src/v1/livestream_service_client.ts @@ -593,7 +593,7 @@ export class LivestreamServiceClient { 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.getChannel(request, options, callback); @@ -685,7 +685,7 @@ export class LivestreamServiceClient { 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.getInput(request, options, callback); @@ -797,7 +797,7 @@ export class LivestreamServiceClient { 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.createEvent(request, options, callback); @@ -889,7 +889,7 @@ export class LivestreamServiceClient { 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.getEvent(request, options, callback); @@ -995,7 +995,7 @@ export class LivestreamServiceClient { 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.deleteEvent(request, options, callback); @@ -1121,7 +1121,7 @@ export class LivestreamServiceClient { 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.createChannel(request, options, callback); @@ -1279,7 +1279,7 @@ export class LivestreamServiceClient { 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.deleteChannel(request, options, callback); @@ -1444,7 +1444,7 @@ export class LivestreamServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'channel.name': request.channel!.name || '', + 'channel.name': request.channel!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateChannel(request, options, callback); @@ -1598,7 +1598,7 @@ export class LivestreamServiceClient { 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.startChannel(request, options, callback); @@ -1752,7 +1752,7 @@ export class LivestreamServiceClient { 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.stopChannel(request, options, callback); @@ -1911,7 +1911,7 @@ export class LivestreamServiceClient { 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.createInput(request, options, callback); @@ -2064,7 +2064,7 @@ export class LivestreamServiceClient { 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.deleteInput(request, options, callback); @@ -2225,7 +2225,7 @@ export class LivestreamServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'input.name': request.input!.name || '', + 'input.name': request.input!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateInput(request, options, callback); @@ -2368,7 +2368,7 @@ export class LivestreamServiceClient { 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.listChannels(request, options, callback); @@ -2416,7 +2416,7 @@ export class LivestreamServiceClient { 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['listChannels']; const callSettings = defaultCallSettings.merge(options); @@ -2473,7 +2473,7 @@ export class LivestreamServiceClient { 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['listChannels']; const callSettings = defaultCallSettings.merge(options); @@ -2587,7 +2587,7 @@ export class LivestreamServiceClient { 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.listInputs(request, options, callback); @@ -2635,7 +2635,7 @@ export class LivestreamServiceClient { 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['listInputs']; const callSettings = defaultCallSettings.merge(options); @@ -2692,7 +2692,7 @@ export class LivestreamServiceClient { 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['listInputs']; const callSettings = defaultCallSettings.merge(options); @@ -2806,7 +2806,7 @@ export class LivestreamServiceClient { 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.listEvents(request, options, callback); @@ -2854,7 +2854,7 @@ export class LivestreamServiceClient { 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['listEvents']; const callSettings = defaultCallSettings.merge(options); @@ -2911,7 +2911,7 @@ export class LivestreamServiceClient { 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['listEvents']; const callSettings = defaultCallSettings.merge(options); diff --git a/test/gapic_livestream_service_v1.ts b/test/gapic_livestream_service_v1.ts index 117ddea..c878bb3 100644 --- a/test/gapic_livestream_service_v1.ts +++ b/test/gapic_livestream_service_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} 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 @@ -254,26 +269,23 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetChannelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.video.livestream.v1.Channel() ); client.innerApiCalls.getChannel = stubSimpleCall(expectedResponse); const [response] = await client.getChannel(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getChannel without error using callback', async () => { @@ -285,15 +297,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetChannelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.video.livestream.v1.Channel() ); @@ -316,11 +322,14 @@ describe('v1.LivestreamServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getChannel with error', async () => { @@ -332,26 +341,23 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetChannelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getChannel = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getChannel(request), expectedError); - assert( - (client.innerApiCalls.getChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getChannel with closed client', async () => { @@ -363,7 +369,8 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetChannelRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetChannelRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getChannel(request), expectedError); @@ -380,26 +387,23 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetInputRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInputRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.video.livestream.v1.Input() ); client.innerApiCalls.getInput = stubSimpleCall(expectedResponse); const [response] = await client.getInput(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInput without error using callback', async () => { @@ -411,15 +415,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetInputRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInputRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.video.livestream.v1.Input() ); @@ -442,11 +440,14 @@ describe('v1.LivestreamServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInput with error', async () => { @@ -458,23 +459,20 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetInputRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetInputRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getInput = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getInput(request), expectedError); - assert( - (client.innerApiCalls.getInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getInput with closed client', async () => { @@ -486,7 +484,8 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetInputRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetInputRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getInput(request), expectedError); @@ -503,26 +502,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateEventRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEventRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.video.livestream.v1.Event() ); client.innerApiCalls.createEvent = stubSimpleCall(expectedResponse); const [response] = await client.createEvent(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEvent without error using callback', async () => { @@ -534,15 +532,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateEventRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEventRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.video.livestream.v1.Event() ); @@ -565,11 +559,14 @@ describe('v1.LivestreamServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEvent with error', async () => { @@ -581,26 +578,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateEventRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEventRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEvent = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createEvent(request), expectedError); - assert( - (client.innerApiCalls.createEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEvent with closed client', async () => { @@ -612,7 +608,10 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateEventRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateEventRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createEvent(request), expectedError); @@ -629,26 +628,23 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetEventRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.video.livestream.v1.Event() ); client.innerApiCalls.getEvent = stubSimpleCall(expectedResponse); const [response] = await client.getEvent(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEvent without error using callback', async () => { @@ -660,15 +656,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetEventRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.video.livestream.v1.Event() ); @@ -691,11 +681,14 @@ describe('v1.LivestreamServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEvent with error', async () => { @@ -707,23 +700,20 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetEventRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getEvent = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getEvent(request), expectedError); - assert( - (client.innerApiCalls.getEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEvent with closed client', async () => { @@ -735,7 +725,8 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.GetEventRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetEventRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getEvent(request), expectedError); @@ -752,26 +743,23 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteEventRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteEvent = stubSimpleCall(expectedResponse); const [response] = await client.deleteEvent(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEvent without error using callback', async () => { @@ -783,15 +771,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteEventRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -814,11 +796,14 @@ describe('v1.LivestreamServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEvent with error', async () => { @@ -830,26 +815,23 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteEventRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEventRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEvent = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteEvent(request), expectedError); - assert( - (client.innerApiCalls.deleteEvent as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEvent with closed client', async () => { @@ -861,7 +843,8 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteEventRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteEventRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteEvent(request), expectedError); @@ -878,15 +861,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateChannelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateChannelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -895,11 +874,14 @@ describe('v1.LivestreamServiceClient', () => { const [operation] = await client.createChannel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createChannel without error using callback', async () => { @@ -911,15 +893,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateChannelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateChannelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -949,11 +927,14 @@ describe('v1.LivestreamServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createChannel with call error', async () => { @@ -965,26 +946,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateChannelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateChannelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createChannel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createChannel(request), expectedError); - assert( - (client.innerApiCalls.createChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createChannel with LRO error', async () => { @@ -996,15 +976,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateChannelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateChannelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createChannel = stubLongRunningCall( undefined, @@ -1013,11 +989,14 @@ describe('v1.LivestreamServiceClient', () => { ); const [operation] = await client.createChannel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateChannelProgress without error', async () => { @@ -1072,15 +1051,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteChannelRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1089,11 +1064,14 @@ describe('v1.LivestreamServiceClient', () => { const [operation] = await client.deleteChannel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteChannel without error using callback', async () => { @@ -1105,15 +1083,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteChannelRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1143,11 +1117,14 @@ describe('v1.LivestreamServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteChannel with call error', async () => { @@ -1159,26 +1136,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteChannelRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteChannel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteChannel(request), expectedError); - assert( - (client.innerApiCalls.deleteChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteChannel with LRO error', async () => { @@ -1190,15 +1166,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteChannelRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteChannel = stubLongRunningCall( undefined, @@ -1207,11 +1179,14 @@ describe('v1.LivestreamServiceClient', () => { ); const [operation] = await client.deleteChannel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteChannelProgress without error', async () => { @@ -1266,16 +1241,13 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.UpdateChannelRequest() ); - request.channel = {}; - request.channel.name = ''; - const expectedHeaderRequestParams = 'channel.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.channel ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateChannelRequest', [ + 'channel', + 'name', + ]); + request.channel.name = defaultValue1; + const expectedHeaderRequestParams = `channel.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1284,11 +1256,14 @@ describe('v1.LivestreamServiceClient', () => { const [operation] = await client.updateChannel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateChannel without error using callback', async () => { @@ -1300,16 +1275,13 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.UpdateChannelRequest() ); - request.channel = {}; - request.channel.name = ''; - const expectedHeaderRequestParams = 'channel.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.channel ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateChannelRequest', [ + 'channel', + 'name', + ]); + request.channel.name = defaultValue1; + const expectedHeaderRequestParams = `channel.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1339,11 +1311,14 @@ describe('v1.LivestreamServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateChannel with call error', async () => { @@ -1355,27 +1330,27 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.UpdateChannelRequest() ); - request.channel = {}; - request.channel.name = ''; - const expectedHeaderRequestParams = 'channel.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.channel ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateChannelRequest', [ + 'channel', + 'name', + ]); + request.channel.name = defaultValue1; + const expectedHeaderRequestParams = `channel.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateChannel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateChannel(request), expectedError); - assert( - (client.innerApiCalls.updateChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateChannel with LRO error', async () => { @@ -1387,16 +1362,13 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.UpdateChannelRequest() ); - request.channel = {}; - request.channel.name = ''; - const expectedHeaderRequestParams = 'channel.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.channel ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateChannelRequest', [ + 'channel', + 'name', + ]); + request.channel.name = defaultValue1; + const expectedHeaderRequestParams = `channel.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateChannel = stubLongRunningCall( undefined, @@ -1405,11 +1377,14 @@ describe('v1.LivestreamServiceClient', () => { ); const [operation] = await client.updateChannel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateChannelProgress without error', async () => { @@ -1464,15 +1439,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.StartChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StartChannelRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1480,11 +1451,14 @@ describe('v1.LivestreamServiceClient', () => { const [operation] = await client.startChannel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.startChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.startChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startChannel without error using callback', async () => { @@ -1496,15 +1470,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.StartChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StartChannelRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1534,11 +1504,14 @@ describe('v1.LivestreamServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.startChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.startChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startChannel with call error', async () => { @@ -1550,26 +1523,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.StartChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StartChannelRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.startChannel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.startChannel(request), expectedError); - assert( - (client.innerApiCalls.startChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.startChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes startChannel with LRO error', async () => { @@ -1581,15 +1553,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.StartChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StartChannelRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.startChannel = stubLongRunningCall( undefined, @@ -1598,11 +1566,14 @@ describe('v1.LivestreamServiceClient', () => { ); const [operation] = await client.startChannel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.startChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.startChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkStartChannelProgress without error', async () => { @@ -1654,15 +1625,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.StopChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StopChannelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1670,11 +1635,14 @@ describe('v1.LivestreamServiceClient', () => { const [operation] = await client.stopChannel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.stopChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.stopChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopChannel without error using callback', async () => { @@ -1686,15 +1654,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.StopChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StopChannelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1724,11 +1686,14 @@ describe('v1.LivestreamServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.stopChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.stopChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopChannel with call error', async () => { @@ -1740,26 +1705,23 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.StopChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StopChannelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.stopChannel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.stopChannel(request), expectedError); - assert( - (client.innerApiCalls.stopChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.stopChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopChannel with LRO error', async () => { @@ -1771,15 +1733,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.StopChannelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StopChannelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.stopChannel = stubLongRunningCall( undefined, @@ -1788,11 +1744,14 @@ describe('v1.LivestreamServiceClient', () => { ); const [operation] = await client.stopChannel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.stopChannel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.stopChannel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopChannel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkStopChannelProgress without error', async () => { @@ -1844,15 +1803,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateInputRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateInputRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1860,11 +1815,14 @@ describe('v1.LivestreamServiceClient', () => { const [operation] = await client.createInput(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createInput without error using callback', async () => { @@ -1876,15 +1834,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateInputRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateInputRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1914,11 +1868,14 @@ describe('v1.LivestreamServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createInput with call error', async () => { @@ -1930,26 +1887,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateInputRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateInputRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createInput = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createInput(request), expectedError); - assert( - (client.innerApiCalls.createInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createInput with LRO error', async () => { @@ -1961,15 +1917,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.CreateInputRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateInputRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createInput = stubLongRunningCall( undefined, @@ -1978,11 +1930,14 @@ describe('v1.LivestreamServiceClient', () => { ); const [operation] = await client.createInput(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateInputProgress without error', async () => { @@ -2034,15 +1989,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteInputRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteInputRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2050,11 +1999,14 @@ describe('v1.LivestreamServiceClient', () => { const [operation] = await client.deleteInput(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteInput without error using callback', async () => { @@ -2066,15 +2018,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteInputRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteInputRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2104,11 +2050,14 @@ describe('v1.LivestreamServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteInput with call error', async () => { @@ -2120,26 +2069,23 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteInputRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteInputRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteInput = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteInput(request), expectedError); - assert( - (client.innerApiCalls.deleteInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteInput with LRO error', async () => { @@ -2151,15 +2097,9 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.DeleteInputRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteInputRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteInput = stubLongRunningCall( undefined, @@ -2168,11 +2108,14 @@ describe('v1.LivestreamServiceClient', () => { ); const [operation] = await client.deleteInput(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteInputProgress without error', async () => { @@ -2224,16 +2167,13 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.UpdateInputRequest() ); - request.input = {}; - request.input.name = ''; - const expectedHeaderRequestParams = 'input.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.input ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInputRequest', [ + 'input', + 'name', + ]); + request.input.name = defaultValue1; + const expectedHeaderRequestParams = `input.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2241,11 +2181,14 @@ describe('v1.LivestreamServiceClient', () => { const [operation] = await client.updateInput(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateInput without error using callback', async () => { @@ -2257,16 +2200,13 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.UpdateInputRequest() ); - request.input = {}; - request.input.name = ''; - const expectedHeaderRequestParams = 'input.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.input ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInputRequest', [ + 'input', + 'name', + ]); + request.input.name = defaultValue1; + const expectedHeaderRequestParams = `input.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2296,11 +2236,14 @@ describe('v1.LivestreamServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateInput with call error', async () => { @@ -2312,27 +2255,27 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.UpdateInputRequest() ); - request.input = {}; - request.input.name = ''; - const expectedHeaderRequestParams = 'input.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.input ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInputRequest', [ + 'input', + 'name', + ]); + request.input.name = defaultValue1; + const expectedHeaderRequestParams = `input.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateInput = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateInput(request), expectedError); - assert( - (client.innerApiCalls.updateInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateInput with LRO error', async () => { @@ -2344,16 +2287,13 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.UpdateInputRequest() ); - request.input = {}; - request.input.name = ''; - const expectedHeaderRequestParams = 'input.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.input ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateInputRequest', [ + 'input', + 'name', + ]); + request.input.name = defaultValue1; + const expectedHeaderRequestParams = `input.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateInput = stubLongRunningCall( undefined, @@ -2362,11 +2302,14 @@ describe('v1.LivestreamServiceClient', () => { ); const [operation] = await client.updateInput(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateInput as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateInput as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateInput as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateInputProgress without error', async () => { @@ -2418,15 +2361,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListChannelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListChannelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Channel() @@ -2441,11 +2380,14 @@ describe('v1.LivestreamServiceClient', () => { client.innerApiCalls.listChannels = stubSimpleCall(expectedResponse); const [response] = await client.listChannels(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listChannels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listChannels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listChannels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listChannels without error using callback', async () => { @@ -2457,15 +2399,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListChannelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListChannelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Channel() @@ -2496,11 +2434,14 @@ describe('v1.LivestreamServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listChannels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listChannels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listChannels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listChannels with error', async () => { @@ -2512,26 +2453,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListChannelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListChannelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listChannels = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listChannels(request), expectedError); - assert( - (client.innerApiCalls.listChannels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listChannels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listChannels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listChannelsStream without error', async () => { @@ -2543,8 +2483,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListChannelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListChannelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Channel() @@ -2581,11 +2524,12 @@ describe('v1.LivestreamServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listChannels, request) ); - assert.strictEqual( - ( - client.descriptors.page.listChannels.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listChannels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2598,8 +2542,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListChannelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListChannelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listChannels.createStream = stubPageStreamingCall( undefined, @@ -2627,11 +2574,12 @@ describe('v1.LivestreamServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listChannels, request) ); - assert.strictEqual( - ( - client.descriptors.page.listChannels.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listChannels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2644,8 +2592,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListChannelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListChannelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Channel() @@ -2671,11 +2622,12 @@ describe('v1.LivestreamServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listChannels.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listChannels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2688,8 +2640,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListChannelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListChannelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listChannels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2707,11 +2662,12 @@ describe('v1.LivestreamServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listChannels.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listChannels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2726,15 +2682,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListInputsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInputsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Input() @@ -2749,11 +2701,14 @@ describe('v1.LivestreamServiceClient', () => { client.innerApiCalls.listInputs = stubSimpleCall(expectedResponse); const [response] = await client.listInputs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listInputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listInputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInputs without error using callback', async () => { @@ -2765,15 +2720,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListInputsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInputsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Input() @@ -2804,11 +2755,14 @@ describe('v1.LivestreamServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listInputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listInputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInputs with error', async () => { @@ -2820,26 +2774,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListInputsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListInputsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listInputs = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listInputs(request), expectedError); - assert( - (client.innerApiCalls.listInputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listInputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listInputsStream without error', async () => { @@ -2851,8 +2804,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListInputsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInputsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Input() @@ -2889,11 +2845,12 @@ describe('v1.LivestreamServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listInputs, request) ); - assert.strictEqual( - (client.descriptors.page.listInputs.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInputs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2906,8 +2863,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListInputsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInputsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listInputs.createStream = stubPageStreamingCall( undefined, @@ -2935,11 +2895,12 @@ describe('v1.LivestreamServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listInputs, request) ); - assert.strictEqual( - (client.descriptors.page.listInputs.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInputs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2952,8 +2913,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListInputsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInputsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Input() @@ -2979,11 +2943,12 @@ describe('v1.LivestreamServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listInputs.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInputs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2996,8 +2961,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListInputsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListInputsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listInputs.asyncIterate = stubAsyncIterationCall( undefined, @@ -3016,11 +2984,12 @@ describe('v1.LivestreamServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listInputs.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listInputs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3035,15 +3004,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListEventsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEventsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Event() @@ -3058,11 +3023,14 @@ describe('v1.LivestreamServiceClient', () => { client.innerApiCalls.listEvents = stubSimpleCall(expectedResponse); const [response] = await client.listEvents(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEvents without error using callback', async () => { @@ -3074,15 +3042,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListEventsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEventsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Event() @@ -3113,11 +3077,14 @@ describe('v1.LivestreamServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEvents with error', async () => { @@ -3129,26 +3096,25 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListEventsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEventsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listEvents = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listEvents(request), expectedError); - assert( - (client.innerApiCalls.listEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEventsStream without error', async () => { @@ -3160,8 +3126,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListEventsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEventsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Event() @@ -3198,11 +3167,12 @@ describe('v1.LivestreamServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEvents, request) ); - assert.strictEqual( - (client.descriptors.page.listEvents.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEvents.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3215,8 +3185,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListEventsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEventsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEvents.createStream = stubPageStreamingCall( undefined, @@ -3244,11 +3217,12 @@ describe('v1.LivestreamServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEvents, request) ); - assert.strictEqual( - (client.descriptors.page.listEvents.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEvents.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3261,8 +3235,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListEventsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEventsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.video.livestream.v1.Event() @@ -3288,11 +3265,12 @@ describe('v1.LivestreamServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listEvents.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEvents.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3305,8 +3283,11 @@ describe('v1.LivestreamServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.video.livestream.v1.ListEventsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEventsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEvents.asyncIterate = stubAsyncIterationCall( undefined, @@ -3325,11 +3306,12 @@ describe('v1.LivestreamServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listEvents.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEvents.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); });