From de2447bd2a3d250cfd906f4d074c97face23f155 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 11 May 2021 16:03:30 -0700 Subject: [PATCH] chore: new owl bot post processor docker image (#745) gcr.io/repo-automation-bots/owlbot-nodejs:latest@sha256:f93bb861d6f12574437bb9aee426b71eafd63b419669ff0ed029f4b7e7162e3f Co-authored-by: Owl Bot --- .../google-cloud-speech/protos/protos.d.ts | 24 +-- packages/google-cloud-speech/protos/protos.js | 48 ++--- .../src/v1/speech_client.ts | 15 +- .../src/v1p1beta1/adaptation_client.ts | 145 +++++++------- .../src/v1p1beta1/speech_client.ts | 15 +- .../test/gapic_adaptation_v1p1beta1.ts | 186 ++++++++---------- .../test/gapic_speech_v1.ts | 37 ++-- .../test/gapic_speech_v1p1beta1.ts | 37 ++-- .../google-cloud-speech/test/helpers.test.ts | 7 +- 9 files changed, 233 insertions(+), 281 deletions(-) diff --git a/packages/google-cloud-speech/protos/protos.d.ts b/packages/google-cloud-speech/protos/protos.d.ts index f0e69f05ce3..b8f925ee87b 100644 --- a/packages/google-cloud-speech/protos/protos.d.ts +++ b/packages/google-cloud-speech/protos/protos.d.ts @@ -328,7 +328,7 @@ export namespace google { public streamingConfig?: (google.cloud.speech.v1.IStreamingRecognitionConfig|null); /** StreamingRecognizeRequest audioContent. */ - public audioContent: (Uint8Array|string); + public audioContent?: (Uint8Array|string|null); /** StreamingRecognizeRequest streamingRequest. */ public streamingRequest?: ("streamingConfig"|"audioContent"); @@ -1081,10 +1081,10 @@ export namespace google { constructor(properties?: google.cloud.speech.v1.IRecognitionAudio); /** RecognitionAudio content. */ - public content: (Uint8Array|string); + public content?: (Uint8Array|string|null); /** RecognitionAudio uri. */ - public uri: string; + public uri?: (string|null); /** RecognitionAudio audioSource. */ public audioSource?: ("content"|"uri"); @@ -2285,7 +2285,7 @@ export namespace google { constructor(properties?: google.cloud.speech.v1p1beta1.ITranscriptOutputConfig); /** TranscriptOutputConfig gcsUri. */ - public gcsUri: string; + public gcsUri?: (string|null); /** TranscriptOutputConfig outputType. */ public outputType?: "gcsUri"; @@ -2384,7 +2384,7 @@ export namespace google { public streamingConfig?: (google.cloud.speech.v1p1beta1.IStreamingRecognitionConfig|null); /** StreamingRecognizeRequest audioContent. */ - public audioContent: (Uint8Array|string); + public audioContent?: (Uint8Array|string|null); /** StreamingRecognizeRequest streamingRequest. */ public streamingRequest?: ("streamingConfig"|"audioContent"); @@ -3193,10 +3193,10 @@ export namespace google { constructor(properties?: google.cloud.speech.v1p1beta1.IRecognitionAudio); /** RecognitionAudio content. */ - public content: (Uint8Array|string); + public content?: (Uint8Array|string|null); /** RecognitionAudio uri. */ - public uri: string; + public uri?: (string|null); /** RecognitionAudio audioSource. */ public audioSource?: ("content"|"uri"); @@ -6160,19 +6160,19 @@ export namespace google { public selector: string; /** HttpRule get. */ - public get: string; + public get?: (string|null); /** HttpRule put. */ - public put: string; + public put?: (string|null); /** HttpRule post. */ - public post: string; + public post?: (string|null); /** HttpRule delete. */ - public delete: string; + public delete?: (string|null); /** HttpRule patch. */ - public patch: string; + public patch?: (string|null); /** HttpRule custom. */ public custom?: (google.api.ICustomHttpPattern|null); diff --git a/packages/google-cloud-speech/protos/protos.js b/packages/google-cloud-speech/protos/protos.js index 575cb00c985..b69c2765432 100644 --- a/packages/google-cloud-speech/protos/protos.js +++ b/packages/google-cloud-speech/protos/protos.js @@ -675,11 +675,11 @@ /** * StreamingRecognizeRequest audioContent. - * @member {Uint8Array} audioContent + * @member {Uint8Array|null|undefined} audioContent * @memberof google.cloud.speech.v1.StreamingRecognizeRequest * @instance */ - StreamingRecognizeRequest.prototype.audioContent = $util.newBuffer([]); + StreamingRecognizeRequest.prototype.audioContent = null; // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -2733,19 +2733,19 @@ /** * RecognitionAudio content. - * @member {Uint8Array} content + * @member {Uint8Array|null|undefined} content * @memberof google.cloud.speech.v1.RecognitionAudio * @instance */ - RecognitionAudio.prototype.content = $util.newBuffer([]); + RecognitionAudio.prototype.content = null; /** * RecognitionAudio uri. - * @member {string} uri + * @member {string|null|undefined} uri * @memberof google.cloud.speech.v1.RecognitionAudio * @instance */ - RecognitionAudio.prototype.uri = ""; + RecognitionAudio.prototype.uri = null; // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -5599,11 +5599,11 @@ /** * TranscriptOutputConfig gcsUri. - * @member {string} gcsUri + * @member {string|null|undefined} gcsUri * @memberof google.cloud.speech.v1p1beta1.TranscriptOutputConfig * @instance */ - TranscriptOutputConfig.prototype.gcsUri = ""; + TranscriptOutputConfig.prototype.gcsUri = null; // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -5813,11 +5813,11 @@ /** * StreamingRecognizeRequest audioContent. - * @member {Uint8Array} audioContent + * @member {Uint8Array|null|undefined} audioContent * @memberof google.cloud.speech.v1p1beta1.StreamingRecognizeRequest * @instance */ - StreamingRecognizeRequest.prototype.audioContent = $util.newBuffer([]); + StreamingRecognizeRequest.prototype.audioContent = null; // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -8130,19 +8130,19 @@ /** * RecognitionAudio content. - * @member {Uint8Array} content + * @member {Uint8Array|null|undefined} content * @memberof google.cloud.speech.v1p1beta1.RecognitionAudio * @instance */ - RecognitionAudio.prototype.content = $util.newBuffer([]); + RecognitionAudio.prototype.content = null; /** * RecognitionAudio uri. - * @member {string} uri + * @member {string|null|undefined} uri * @memberof google.cloud.speech.v1p1beta1.RecognitionAudio * @instance */ - RecognitionAudio.prototype.uri = ""; + RecognitionAudio.prototype.uri = null; // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -14948,43 +14948,43 @@ /** * HttpRule get. - * @member {string} get + * @member {string|null|undefined} get * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.get = ""; + HttpRule.prototype.get = null; /** * HttpRule put. - * @member {string} put + * @member {string|null|undefined} put * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.put = ""; + HttpRule.prototype.put = null; /** * HttpRule post. - * @member {string} post + * @member {string|null|undefined} post * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.post = ""; + HttpRule.prototype.post = null; /** * HttpRule delete. - * @member {string} delete + * @member {string|null|undefined} delete * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype["delete"] = ""; + HttpRule.prototype["delete"] = null; /** * HttpRule patch. - * @member {string} patch + * @member {string|null|undefined} patch * @memberof google.api.HttpRule * @instance */ - HttpRule.prototype.patch = ""; + HttpRule.prototype.patch = null; /** * HttpRule custom. diff --git a/packages/google-cloud-speech/src/v1/speech_client.ts b/packages/google-cloud-speech/src/v1/speech_client.ts index 0710158f2ce..1ffefa59624 100644 --- a/packages/google-cloud-speech/src/v1/speech_client.ts +++ b/packages/google-cloud-speech/src/v1/speech_client.ts @@ -250,13 +250,14 @@ export class SpeechClient { ]; for (const methodName of speechStubMethods) { const callPromise = this.speechStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, (err: Error | null | undefined) => () => { throw err; } diff --git a/packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts b/packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts index f97a167cbc3..4febac9a459 100644 --- a/packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts +++ b/packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts @@ -255,13 +255,14 @@ export class AdaptationClient { ]; for (const methodName of adaptationStubMethods) { const callPromise = this.adaptationStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, (err: Error | null | undefined) => () => { throw err; } @@ -429,11 +430,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createPhraseSet(request, options, callback); } @@ -523,11 +523,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getPhraseSet(request, options, callback); } @@ -621,11 +620,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'phrase_set.name': request.phraseSet!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'phrase_set.name': request.phraseSet!.name || '', + }); this.initialize(); return this.innerApiCalls.updatePhraseSet(request, options, callback); } @@ -715,11 +713,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deletePhraseSet(request, options, callback); } @@ -823,11 +820,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createCustomClass(request, options, callback); } @@ -917,11 +913,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getCustomClass(request, options, callback); } @@ -1021,11 +1016,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'custom_class.name': request.customClass!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'custom_class.name': request.customClass!.name || '', + }); this.initialize(); return this.innerApiCalls.updateCustomClass(request, options, callback); } @@ -1121,11 +1115,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - name: request.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteCustomClass(request, options, callback); } @@ -1230,11 +1223,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listPhraseSet(request, options, callback); } @@ -1278,11 +1270,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listPhraseSet.createStream( @@ -1337,17 +1328,16 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listPhraseSet.asyncIterate( this.innerApiCalls['listPhraseSet'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } @@ -1451,11 +1441,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listCustomClasses(request, options, callback); } @@ -1499,11 +1488,10 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listCustomClasses.createStream( @@ -1558,17 +1546,16 @@ export class AdaptationClient { options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - parent: request.parent || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); options = options || {}; const callSettings = new gax.CallSettings(options); this.initialize(); return this.descriptors.page.listCustomClasses.asyncIterate( this.innerApiCalls['listCustomClasses'] as GaxCall, - (request as unknown) as RequestType, + request as unknown as RequestType, callSettings ) as AsyncIterable; } diff --git a/packages/google-cloud-speech/src/v1p1beta1/speech_client.ts b/packages/google-cloud-speech/src/v1p1beta1/speech_client.ts index 77b56048128..5786ad63169 100644 --- a/packages/google-cloud-speech/src/v1p1beta1/speech_client.ts +++ b/packages/google-cloud-speech/src/v1p1beta1/speech_client.ts @@ -263,13 +263,14 @@ export class SpeechClient { ]; for (const methodName of speechStubMethods) { const callPromise = this.speechStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, (err: Error | null | undefined) => () => { throw err; } diff --git a/packages/google-cloud-speech/test/gapic_adaptation_v1p1beta1.ts b/packages/google-cloud-speech/test/gapic_adaptation_v1p1beta1.ts index be19a43938b..584721fc7ff 100644 --- a/packages/google-cloud-speech/test/gapic_adaptation_v1p1beta1.ts +++ b/packages/google-cloud-speech/test/gapic_adaptation_v1p1beta1.ts @@ -28,10 +28,9 @@ import {PassThrough} from 'stream'; import {protobuf} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( filledObject ) as T; @@ -247,9 +246,8 @@ describe('v1p1beta1.AdaptationClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); - client.innerApiCalls.createPhraseSet = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.createPhraseSet = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.createPhraseSet( request, @@ -359,9 +357,8 @@ describe('v1p1beta1.AdaptationClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); - client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getPhraseSet = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getPhraseSet( request, @@ -473,9 +470,8 @@ describe('v1p1beta1.AdaptationClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.PhraseSet() ); - client.innerApiCalls.updatePhraseSet = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.updatePhraseSet = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.updatePhraseSet( request, @@ -586,9 +582,8 @@ describe('v1p1beta1.AdaptationClient', () => { const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); - client.innerApiCalls.deletePhraseSet = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.deletePhraseSet = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.deletePhraseSet( request, @@ -698,9 +693,8 @@ describe('v1p1beta1.AdaptationClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); - client.innerApiCalls.createCustomClass = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.createCustomClass = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.createCustomClass( request, @@ -810,9 +804,8 @@ describe('v1p1beta1.AdaptationClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); - client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.getCustomClass = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.getCustomClass( request, @@ -924,9 +917,8 @@ describe('v1p1beta1.AdaptationClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.CustomClass() ); - client.innerApiCalls.updateCustomClass = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.updateCustomClass = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.updateCustomClass( request, @@ -1037,9 +1029,8 @@ describe('v1p1beta1.AdaptationClient', () => { const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); - client.innerApiCalls.deleteCustomClass = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.deleteCustomClass = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.deleteCustomClass( request, @@ -1165,9 +1156,8 @@ describe('v1p1beta1.AdaptationClient', () => { new protos.google.cloud.speech.v1p1beta1.PhraseSet() ), ]; - client.innerApiCalls.listPhraseSet = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listPhraseSet = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listPhraseSet( request, @@ -1245,9 +1235,8 @@ describe('v1p1beta1.AdaptationClient', () => { new protos.google.cloud.speech.v1p1beta1.PhraseSet() ), ]; - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listPhraseSet.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listPhraseSetStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; @@ -1272,10 +1261,9 @@ describe('v1p1beta1.AdaptationClient', () => { .calledWith(client.innerApiCalls.listPhraseSet, request) ); assert.strictEqual( - (client.descriptors.page.listPhraseSet - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listPhraseSet.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1292,10 +1280,8 @@ describe('v1p1beta1.AdaptationClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.listPhraseSet.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.listPhraseSetStream(request); const promise = new Promise((resolve, reject) => { const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; @@ -1319,10 +1305,9 @@ describe('v1p1beta1.AdaptationClient', () => { .calledWith(client.innerApiCalls.listPhraseSet, request) ); assert.strictEqual( - (client.descriptors.page.listPhraseSet - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listPhraseSet.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1349,9 +1334,8 @@ describe('v1p1beta1.AdaptationClient', () => { new protos.google.cloud.speech.v1p1beta1.PhraseSet() ), ]; - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listPhraseSet.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; const iterable = client.listPhraseSetAsync(request); for await (const resource of iterable) { @@ -1359,15 +1343,15 @@ describe('v1p1beta1.AdaptationClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listPhraseSet.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listPhraseSet - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listPhraseSet.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1384,10 +1368,8 @@ describe('v1p1beta1.AdaptationClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.listPhraseSet.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.listPhraseSetAsync(request); await assert.rejects(async () => { const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; @@ -1396,15 +1378,15 @@ describe('v1p1beta1.AdaptationClient', () => { } }); assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listPhraseSet.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listPhraseSet - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listPhraseSet.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1479,9 +1461,8 @@ describe('v1p1beta1.AdaptationClient', () => { new protos.google.cloud.speech.v1p1beta1.CustomClass() ), ]; - client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.listCustomClasses = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.listCustomClasses( request, @@ -1559,12 +1540,12 @@ describe('v1p1beta1.AdaptationClient', () => { new protos.google.cloud.speech.v1p1beta1.CustomClass() ), ]; - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall( - expectedResponse - ); + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(expectedResponse); const stream = client.listCustomClassesStream(request); const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; + const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = + []; stream.on( 'data', (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { @@ -1586,10 +1567,9 @@ describe('v1p1beta1.AdaptationClient', () => { .calledWith(client.innerApiCalls.listCustomClasses, request) ); assert.strictEqual( - (client.descriptors.page.listCustomClasses - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCustomClasses.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1606,13 +1586,12 @@ describe('v1p1beta1.AdaptationClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall( - undefined, - expectedError - ); + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(undefined, expectedError); const stream = client.listCustomClassesStream(request); const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; + const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = + []; stream.on( 'data', (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { @@ -1633,10 +1612,9 @@ describe('v1p1beta1.AdaptationClient', () => { .calledWith(client.innerApiCalls.listCustomClasses, request) ); assert.strictEqual( - (client.descriptors.page.listCustomClasses - .createStream as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCustomClasses.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1663,9 +1641,8 @@ describe('v1p1beta1.AdaptationClient', () => { new protos.google.cloud.speech.v1p1beta1.CustomClass() ), ]; - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall( - expectedResponse - ); + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(expectedResponse); const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; const iterable = client.listCustomClassesAsync(request); for await (const resource of iterable) { @@ -1673,15 +1650,15 @@ describe('v1p1beta1.AdaptationClient', () => { } assert.deepStrictEqual(responses, expectedResponse); assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listCustomClasses - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); @@ -1698,27 +1675,26 @@ describe('v1p1beta1.AdaptationClient', () => { request.parent = ''; const expectedHeaderRequestParams = 'parent='; const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall( - undefined, - expectedError - ); + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); const iterable = client.listCustomClassesAsync(request); await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; + const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = + []; for await (const resource of iterable) { responses.push(resource!); } }); assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses - .asyncIterate as SinonStub).getCall(0).args[1], + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], request ); assert.strictEqual( - (client.descriptors.page.listCustomClasses - .asyncIterate as SinonStub).getCall(0).args[2].otherArgs.headers[ - 'x-goog-request-params' - ], + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); diff --git a/packages/google-cloud-speech/test/gapic_speech_v1.ts b/packages/google-cloud-speech/test/gapic_speech_v1.ts index e6028055e0d..554dbd65e8d 100644 --- a/packages/google-cloud-speech/test/gapic_speech_v1.ts +++ b/packages/google-cloud-speech/test/gapic_speech_v1.ts @@ -28,10 +28,9 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( filledObject ) as T; @@ -216,9 +215,8 @@ describe('v1.SpeechClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.RecognizeResponse() ); - client.innerApiCalls.recognize = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.recognize = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.recognize( request, @@ -278,9 +276,8 @@ describe('v1.SpeechClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.longRunningRecognize = + stubLongRunningCall(expectedResponse); const [operation] = await client.longRunningRecognize(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -304,9 +301,8 @@ describe('v1.SpeechClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.longRunningRecognize = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.longRunningRecognize( request, @@ -441,9 +437,8 @@ describe('v1.SpeechClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1.StreamingRecognizeResponse() ); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall( - expectedResponse - ); + client.innerApiCalls.streamingRecognize = + stubBidiStreamingCall(expectedResponse); const stream = client._streamingRecognize(); const promise = new Promise((resolve, reject) => { stream.on( @@ -468,9 +463,8 @@ describe('v1.SpeechClient', () => { .calledWithExactly(undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -512,9 +506,8 @@ describe('v1.SpeechClient', () => { .calledWithExactly(undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); diff --git a/packages/google-cloud-speech/test/gapic_speech_v1p1beta1.ts b/packages/google-cloud-speech/test/gapic_speech_v1p1beta1.ts index 622b8bcad9e..3185f2c3732 100644 --- a/packages/google-cloud-speech/test/gapic_speech_v1p1beta1.ts +++ b/packages/google-cloud-speech/test/gapic_speech_v1p1beta1.ts @@ -28,10 +28,9 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message).toObject( - instance as protobuf.Message, - {defaults: true} - ); + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); return (instance.constructor as typeof protobuf.Message).fromObject( filledObject ) as T; @@ -216,9 +215,8 @@ describe('v1p1beta1.SpeechClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() ); - client.innerApiCalls.recognize = stubSimpleCallWithCallback( - expectedResponse - ); + client.innerApiCalls.recognize = + stubSimpleCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.recognize( request, @@ -278,9 +276,8 @@ describe('v1p1beta1.SpeechClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall( - expectedResponse - ); + client.innerApiCalls.longRunningRecognize = + stubLongRunningCall(expectedResponse); const [operation] = await client.longRunningRecognize(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); @@ -304,9 +301,8 @@ describe('v1p1beta1.SpeechClient', () => { const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCallWithCallback( - expectedResponse - ); + client.innerApiCalls.longRunningRecognize = + stubLongRunningCallWithCallback(expectedResponse); const promise = new Promise((resolve, reject) => { client.longRunningRecognize( request, @@ -441,9 +437,8 @@ describe('v1p1beta1.SpeechClient', () => { const expectedResponse = generateSampleMessage( new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse() ); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall( - expectedResponse - ); + client.innerApiCalls.streamingRecognize = + stubBidiStreamingCall(expectedResponse); const stream = client._streamingRecognize(); const promise = new Promise((resolve, reject) => { stream.on( @@ -468,9 +463,8 @@ describe('v1p1beta1.SpeechClient', () => { .calledWithExactly(undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); @@ -512,9 +506,8 @@ describe('v1p1beta1.SpeechClient', () => { .calledWithExactly(undefined) ); assert.deepStrictEqual( - (((stream as unknown) as PassThrough)._transform as SinonStub).getCall( - 0 - ).args[0], + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], request ); }); diff --git a/packages/google-cloud-speech/test/helpers.test.ts b/packages/google-cloud-speech/test/helpers.test.ts index 51752dcdd1a..84f18d8e69d 100644 --- a/packages/google-cloud-speech/test/helpers.test.ts +++ b/packages/google-cloud-speech/test/helpers.test.ts @@ -30,9 +30,10 @@ describe('Speech helper methods', () => { }); describe('streamingRecognize', () => { - const CONFIG: speech.protos.google.cloud.speech.v1.IStreamingRecognitionConfig = { - config: {encoding: 'LINEAR16', languageCode: 'en-us'}, - }; + const CONFIG: speech.protos.google.cloud.speech.v1.IStreamingRecognitionConfig = + { + config: {encoding: 'LINEAR16', languageCode: 'en-us'}, + }; const OPTIONS = {timeout: Infinity}; it('writes the config to the resulting stream', done => {