From b8b9feafa016fa876b5343db1cb64b92d516d73c Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 23 Aug 2022 00:04:20 +0000 Subject: [PATCH] fix: better support for fallback mode (#683) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 468790263 Source-Link: https://github.com/googleapis/googleapis/commit/873ab456273d105245df0fb82a6c17a814553b80 Source-Link: https://github.com/googleapis/googleapis-gen/commit/cb6f37aeff2a3472e40a7bbace8c67d75e24bee5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2I2ZjM3YWVmZjJhMzQ3MmU0MGE3YmJhY2U4YzY3ZDc1ZTI0YmVlNSJ9 --- .../v1/language_service.analyze_entities.js | 3 + ...nguage_service.analyze_entity_sentiment.js | 3 + .../v1/language_service.analyze_sentiment.js | 3 + .../v1/language_service.analyze_syntax.js | 3 + .../v1/language_service.annotate_text.js | 3 + .../v1/language_service.classify_text.js | 3 + ...pet_metadata.google.cloud.language.v1.json | 12 +- .../language_service.analyze_entities.js | 3 + ...nguage_service.analyze_entity_sentiment.js | 3 + .../language_service.analyze_sentiment.js | 3 + .../language_service.analyze_syntax.js | 3 + .../v1beta2/language_service.annotate_text.js | 3 + .../v1beta2/language_service.classify_text.js | 3 + ...etadata.google.cloud.language.v1beta2.json | 12 +- .../src/v1/language_service_client.ts | 3 +- .../src/v1beta2/language_service_client.ts | 3 +- .../test/gapic_language_service_v1.ts | 164 +++++++++--------- .../test/gapic_language_service_v1beta2.ts | 164 +++++++++--------- 18 files changed, 218 insertions(+), 176 deletions(-) diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entities.js b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entities.js index c51b14831dc..5bc14a05ef7 100644 --- a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entities.js +++ b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entities.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1_generated_LanguageService_AnalyzeEntities_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entity_sentiment.js b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entity_sentiment.js index 59d0340906d..b005b23992c 100644 --- a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entity_sentiment.js +++ b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_entity_sentiment.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1_generated_LanguageService_AnalyzeEntitySentiment_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_sentiment.js b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_sentiment.js index e16a69be3fa..cf8c1b63199 100644 --- a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_sentiment.js +++ b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_sentiment.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1_generated_LanguageService_AnalyzeSentiment_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_syntax.js b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_syntax.js index 89bc540ec7e..5d32c85b6b6 100644 --- a/packages/google-cloud-language/samples/generated/v1/language_service.analyze_syntax.js +++ b/packages/google-cloud-language/samples/generated/v1/language_service.analyze_syntax.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1_generated_LanguageService_AnalyzeSyntax_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.annotate_text.js b/packages/google-cloud-language/samples/generated/v1/language_service.annotate_text.js index fb978dde245..b17c4a774d4 100644 --- a/packages/google-cloud-language/samples/generated/v1/language_service.annotate_text.js +++ b/packages/google-cloud-language/samples/generated/v1/language_service.annotate_text.js @@ -23,6 +23,9 @@ function main(document, features) { // [START language_v1_generated_LanguageService_AnnotateText_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1/language_service.classify_text.js b/packages/google-cloud-language/samples/generated/v1/language_service.classify_text.js index 81a04f8cd99..befda5943f4 100644 --- a/packages/google-cloud-language/samples/generated/v1/language_service.classify_text.js +++ b/packages/google-cloud-language/samples/generated/v1/language_service.classify_text.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1_generated_LanguageService_ClassifyText_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json b/packages/google-cloud-language/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json index 80c0fd38934..0d407c6c11c 100644 --- a/packages/google-cloud-language/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json +++ b/packages/google-cloud-language/samples/generated/v1/snippet_metadata.google.cloud.language.v1.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 57, "type": "FULL" } ], @@ -66,7 +66,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 57, "type": "FULL" } ], @@ -110,7 +110,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 57, "type": "FULL" } ], @@ -154,7 +154,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 57, "type": "FULL" } ], @@ -198,7 +198,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -238,7 +238,7 @@ "segments": [ { "start": 25, - "end": 59, + "end": 62, "type": "FULL" } ], diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entities.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entities.js index 61da1c26131..dc4f7a1bee0 100644 --- a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entities.js +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entities.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1beta2_generated_LanguageService_AnalyzeEntities_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js index f7fbf3b4d56..86b5cd381b1 100644 --- a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_entity_sentiment.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1beta2_generated_LanguageService_AnalyzeEntitySentiment_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_sentiment.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_sentiment.js index 8bf110baa0a..77bf2ffe86d 100644 --- a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_sentiment.js +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_sentiment.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1beta2_generated_LanguageService_AnalyzeSentiment_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_syntax.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_syntax.js index 2d928214fb6..e96c0865bba 100644 --- a/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_syntax.js +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.analyze_syntax.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1beta2_generated_LanguageService_AnalyzeSyntax_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.annotate_text.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.annotate_text.js index b8b0239aed2..96ab5ea0913 100644 --- a/packages/google-cloud-language/samples/generated/v1beta2/language_service.annotate_text.js +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.annotate_text.js @@ -23,6 +23,9 @@ function main(document, features) { // [START language_v1beta2_generated_LanguageService_AnnotateText_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1beta2/language_service.classify_text.js b/packages/google-cloud-language/samples/generated/v1beta2/language_service.classify_text.js index e7b868ca67c..cbb8e1e70a0 100644 --- a/packages/google-cloud-language/samples/generated/v1beta2/language_service.classify_text.js +++ b/packages/google-cloud-language/samples/generated/v1beta2/language_service.classify_text.js @@ -23,6 +23,9 @@ function main(document) { // [START language_v1beta2_generated_LanguageService_ClassifyText_async] /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. * TODO(developer): Uncomment these variables before running the sample. */ /** diff --git a/packages/google-cloud-language/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json b/packages/google-cloud-language/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json index 94e3d4d93d2..441db929ca6 100644 --- a/packages/google-cloud-language/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json +++ b/packages/google-cloud-language/samples/generated/v1beta2/snippet_metadata.google.cloud.language.v1beta2.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 55, + "end": 58, "type": "FULL" } ], @@ -66,7 +66,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 57, "type": "FULL" } ], @@ -110,7 +110,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 57, "type": "FULL" } ], @@ -154,7 +154,7 @@ "segments": [ { "start": 25, - "end": 54, + "end": 57, "type": "FULL" } ], @@ -198,7 +198,7 @@ "segments": [ { "start": 25, - "end": 50, + "end": 53, "type": "FULL" } ], @@ -238,7 +238,7 @@ "segments": [ { "start": 25, - "end": 59, + "end": 62, "type": "FULL" } ], diff --git a/packages/google-cloud-language/src/v1/language_service_client.ts b/packages/google-cloud-language/src/v1/language_service_client.ts index 37a8960fa35..a599e7007fd 100644 --- a/packages/google-cloud-language/src/v1/language_service_client.ts +++ b/packages/google-cloud-language/src/v1/language_service_client.ts @@ -226,7 +226,8 @@ export class LanguageServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; diff --git a/packages/google-cloud-language/src/v1beta2/language_service_client.ts b/packages/google-cloud-language/src/v1beta2/language_service_client.ts index 9116a66b835..7589d3b2e0a 100644 --- a/packages/google-cloud-language/src/v1beta2/language_service_client.ts +++ b/packages/google-cloud-language/src/v1beta2/language_service_client.ts @@ -226,7 +226,8 @@ export class LanguageServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; diff --git a/packages/google-cloud-language/test/gapic_language_service_v1.ts b/packages/google-cloud-language/test/gapic_language_service_v1.ts index e109c2e543c..64650cef39c 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v1.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v1.ts @@ -50,101 +50,103 @@ function stubSimpleCallWithCallback( } describe('v1.LanguageServiceClient', () => { - it('has servicePath', () => { - const servicePath = - languageserviceModule.v1.LanguageServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - languageserviceModule.v1.LanguageServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = languageserviceModule.v1.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + languageserviceModule.v1.LanguageServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with no option', () => { - const client = new languageserviceModule.v1.LanguageServiceClient(); - assert(client); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + languageserviceModule.v1.LanguageServiceClient.apiEndpoint; + assert(apiEndpoint); + }); - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - fallback: true, + it('has port', () => { + const port = languageserviceModule.v1.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new languageserviceModule.v1.LanguageServiceClient(); + assert(client); }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with gRPC fallback', () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + fallback: true, + }); + assert(client); }); - client.initialize(); - assert(client.languageServiceStub); - client.close().then(() => { - done(); + + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); }); - }); - it('has close method for the non-initialized client', done => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.languageServiceStub); + client.close().then(() => { + done(); + }); }); - assert.strictEqual(client.languageServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the non-initialized client', done => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); }); describe('analyzeSentiment', () => { diff --git a/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts b/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts index 75993cffeed..b5d374b89f5 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts @@ -50,101 +50,103 @@ function stubSimpleCallWithCallback( } describe('v1beta2.LanguageServiceClient', () => { - it('has servicePath', () => { - const servicePath = - languageserviceModule.v1beta2.LanguageServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - languageserviceModule.v1beta2.LanguageServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = languageserviceModule.v1beta2.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + languageserviceModule.v1beta2.LanguageServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with no option', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient(); - assert(client); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + languageserviceModule.v1beta2.LanguageServiceClient.apiEndpoint; + assert(apiEndpoint); + }); - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - fallback: true, + it('has port', () => { + const port = languageserviceModule.v1beta2.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient(); + assert(client); }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with gRPC fallback', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + fallback: true, + }); + assert(client); }); - client.initialize(); - assert(client.languageServiceStub); - client.close().then(() => { - done(); + + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); }); - }); - it('has close method for the non-initialized client', done => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.languageServiceStub); + client.close().then(() => { + done(); + }); }); - assert.strictEqual(client.languageServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the non-initialized client', done => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon - .stub() - .callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error | null, projectId?: string | null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); }); describe('analyzeSentiment', () => {