From 068a4e9fdf9f0631ce3b29302c0328ada763c398 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:06:27 +0000 Subject: [PATCH] fix: better support for fallback mode (#558) - [ ] 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 --- ...data_transfer_service.check_valid_creds.js | 3 + ...transfer_service.create_transfer_config.js | 3 + ...transfer_service.delete_transfer_config.js | 3 + ...ta_transfer_service.delete_transfer_run.js | 3 + ...ta_transfer_service.enroll_data_sources.js | 3 + .../data_transfer_service.get_data_source.js | 3 + ...ta_transfer_service.get_transfer_config.js | 3 + .../data_transfer_service.get_transfer_run.js | 3 + ...data_transfer_service.list_data_sources.js | 3 + ..._transfer_service.list_transfer_configs.js | 3 + ...ata_transfer_service.list_transfer_logs.js | 3 + ...ata_transfer_service.list_transfer_runs.js | 3 + ...transfer_service.schedule_transfer_runs.js | 3 + ...sfer_service.start_manual_transfer_runs.js | 3 + ...transfer_service.update_transfer_config.js | 3 + ...google.cloud.bigquery.datatransfer.v1.json | 30 +-- .../src/v1/data_transfer_service_client.ts | 20 +- .../test/gapic_data_transfer_service_v1.ts | 171 ++++++++++-------- 18 files changed, 163 insertions(+), 103 deletions(-) diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.check_valid_creds.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.check_valid_creds.js index a8f2ecef31d..91dd765c211 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.check_valid_creds.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.check_valid_creds.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerydatatransfer_v1_generated_DataTransferService_CheckValidCreds_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.create_transfer_config.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.create_transfer_config.js index 0042acae475..a2ddfb165b1 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.create_transfer_config.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.create_transfer_config.js @@ -23,6 +23,9 @@ function main(parent, transferConfig) { // [START bigquerydatatransfer_v1_generated_DataTransferService_CreateTransferConfig_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_config.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_config.js index 77df800d904..40dd46f8912 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_config.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_config.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerydatatransfer_v1_generated_DataTransferService_DeleteTransferConfig_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_run.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_run.js index 4ff90689b08..3b280391e6c 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_run.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.delete_transfer_run.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerydatatransfer_v1_generated_DataTransferService_DeleteTransferRun_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.enroll_data_sources.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.enroll_data_sources.js index bc192ae98cd..e0553ce148a 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.enroll_data_sources.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.enroll_data_sources.js @@ -23,6 +23,9 @@ function main() { // [START bigquerydatatransfer_v1_generated_DataTransferService_EnrollDataSources_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_data_source.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_data_source.js index 58bc44bd825..da7418e8ae4 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_data_source.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_data_source.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerydatatransfer_v1_generated_DataTransferService_GetDataSource_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_config.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_config.js index 8699047242c..bf650372409 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_config.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_config.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerydatatransfer_v1_generated_DataTransferService_GetTransferConfig_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_run.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_run.js index 918dfa3a575..698698e38a5 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_run.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.get_transfer_run.js @@ -23,6 +23,9 @@ function main(name) { // [START bigquerydatatransfer_v1_generated_DataTransferService_GetTransferRun_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_data_sources.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_data_sources.js index d03a368a7aa..516866b4bc9 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_data_sources.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_data_sources.js @@ -23,6 +23,9 @@ function main(parent) { // [START bigquerydatatransfer_v1_generated_DataTransferService_ListDataSources_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_configs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_configs.js index f1e94531ae8..9e4f144680a 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_configs.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_configs.js @@ -23,6 +23,9 @@ function main(parent) { // [START bigquerydatatransfer_v1_generated_DataTransferService_ListTransferConfigs_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_logs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_logs.js index 59d7510c22f..e6828957ffb 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_logs.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_logs.js @@ -23,6 +23,9 @@ function main(parent) { // [START bigquerydatatransfer_v1_generated_DataTransferService_ListTransferLogs_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_runs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_runs.js index 47f0c3ac7fa..a16ee7806ce 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_runs.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.list_transfer_runs.js @@ -23,6 +23,9 @@ function main(parent) { // [START bigquerydatatransfer_v1_generated_DataTransferService_ListTransferRuns_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.schedule_transfer_runs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.schedule_transfer_runs.js index 60e2a1213a8..a7ab3cccdae 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.schedule_transfer_runs.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.schedule_transfer_runs.js @@ -23,6 +23,9 @@ function main(parent, startTime, endTime) { // [START bigquerydatatransfer_v1_generated_DataTransferService_ScheduleTransferRuns_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.start_manual_transfer_runs.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.start_manual_transfer_runs.js index 604032f4b7e..acff4f9bfb2 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.start_manual_transfer_runs.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.start_manual_transfer_runs.js @@ -23,6 +23,9 @@ function main() { // [START bigquerydatatransfer_v1_generated_DataTransferService_StartManualTransferRuns_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-bigquery-datatransfer/samples/generated/v1/data_transfer_service.update_transfer_config.js b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.update_transfer_config.js index 2b7b26cc47e..f6e55317a09 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.update_transfer_config.js +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/data_transfer_service.update_transfer_config.js @@ -23,6 +23,9 @@ function main(transferConfig, updateMask) { // [START bigquerydatatransfer_v1_generated_DataTransferService_UpdateTransferConfig_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-bigquery-datatransfer/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datatransfer.v1.json b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datatransfer.v1.json index 99c4a9f5024..06baed45ca4 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datatransfer.v1.json +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated/v1/snippet_metadata.google.cloud.bigquery.datatransfer.v1.json @@ -22,7 +22,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -62,7 +62,7 @@ "segments": [ { "start": 25, - "end": 66, + "end": 69, "type": "FULL" } ], @@ -110,7 +110,7 @@ "segments": [ { "start": 25, - "end": 92, + "end": 95, "type": "FULL" } ], @@ -166,7 +166,7 @@ "segments": [ { "start": 25, - "end": 90, + "end": 93, "type": "FULL" } ], @@ -222,7 +222,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -262,7 +262,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -302,7 +302,7 @@ "segments": [ { "start": 25, - "end": 70, + "end": 73, "type": "FULL" } ], @@ -354,7 +354,7 @@ "segments": [ { "start": 25, - "end": 64, + "end": 67, "type": "FULL" } ], @@ -402,7 +402,7 @@ "segments": [ { "start": 25, - "end": 60, + "end": 63, "type": "FULL" } ], @@ -450,7 +450,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -490,7 +490,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -530,7 +530,7 @@ "segments": [ { "start": 25, - "end": 75, + "end": 78, "type": "FULL" } ], @@ -586,7 +586,7 @@ "segments": [ { "start": 25, - "end": 71, + "end": 74, "type": "FULL" } ], @@ -638,7 +638,7 @@ "segments": [ { "start": 25, - "end": 52, + "end": 55, "type": "FULL" } ], @@ -678,7 +678,7 @@ "segments": [ { "start": 25, - "end": 55, + "end": 58, "type": "FULL" } ], diff --git a/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.ts b/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.ts index c2d17d42204..bc9fde1bff2 100644 --- a/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.ts +++ b/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.ts @@ -28,7 +28,6 @@ import { } from 'google-gax'; import {Transform} from 'stream'; -import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -300,7 +299,8 @@ export class DataTransferServiceClient { const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], - descriptor + descriptor, + this._opts.fallback ); this.innerApiCalls[methodName] = apiCall; @@ -1701,7 +1701,7 @@ export class DataTransferServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listDataSources.createStream( - this.innerApiCalls.listDataSources as gax.GaxCall, + this.innerApiCalls.listDataSources as GaxCall, request, callSettings ); @@ -1755,7 +1755,7 @@ export class DataTransferServiceClient { this.initialize(); return this.descriptors.page.listDataSources.asyncIterate( this.innerApiCalls['listDataSources'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -1913,7 +1913,7 @@ export class DataTransferServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferConfigs.createStream( - this.innerApiCalls.listTransferConfigs as gax.GaxCall, + this.innerApiCalls.listTransferConfigs as GaxCall, request, callSettings ); @@ -1969,7 +1969,7 @@ export class DataTransferServiceClient { this.initialize(); return this.descriptors.page.listTransferConfigs.asyncIterate( this.innerApiCalls['listTransferConfigs'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -2132,7 +2132,7 @@ export class DataTransferServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferRuns.createStream( - this.innerApiCalls.listTransferRuns as gax.GaxCall, + this.innerApiCalls.listTransferRuns as GaxCall, request, callSettings ); @@ -2191,7 +2191,7 @@ export class DataTransferServiceClient { this.initialize(); return this.descriptors.page.listTransferRuns.asyncIterate( this.innerApiCalls['listTransferRuns'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } @@ -2350,7 +2350,7 @@ export class DataTransferServiceClient { const callSettings = defaultCallSettings.merge(options); this.initialize(); return this.descriptors.page.listTransferLogs.createStream( - this.innerApiCalls.listTransferLogs as gax.GaxCall, + this.innerApiCalls.listTransferLogs as GaxCall, request, callSettings ); @@ -2407,7 +2407,7 @@ export class DataTransferServiceClient { this.initialize(); return this.descriptors.page.listTransferLogs.asyncIterate( this.innerApiCalls['listTransferLogs'] as GaxCall, - request as unknown as RequestType, + request as {}, callSettings ) as AsyncIterable; } diff --git a/packages/google-cloud-bigquery-datatransfer/test/gapic_data_transfer_service_v1.ts b/packages/google-cloud-bigquery-datatransfer/test/gapic_data_transfer_service_v1.ts index e297489d0dd..0dd794699bd 100644 --- a/packages/google-cloud-bigquery-datatransfer/test/gapic_data_transfer_service_v1.ts +++ b/packages/google-cloud-bigquery-datatransfer/test/gapic_data_transfer_service_v1.ts @@ -113,101 +113,116 @@ function stubAsyncIterationCall( } describe('v1.DataTransferServiceClient', () => { - it('has servicePath', () => { - const servicePath = - datatransferserviceModule.v1.DataTransferServiceClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = - datatransferserviceModule.v1.DataTransferServiceClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = datatransferserviceModule.v1.DataTransferServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has servicePath', () => { + const servicePath = + datatransferserviceModule.v1.DataTransferServiceClient.servicePath; + assert(servicePath); + }); - it('should create a client with no option', () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient(); - assert(client); - }); + it('has apiEndpoint', () => { + const apiEndpoint = + datatransferserviceModule.v1.DataTransferServiceClient.apiEndpoint; + assert(apiEndpoint); + }); - it('should create a client with gRPC fallback', () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - fallback: true, + it('has port', () => { + const port = datatransferserviceModule.v1.DataTransferServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - assert(client); - }); - it('has initialize method and supports deferred initialization', async () => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with no option', () => { + const client = + new datatransferserviceModule.v1.DataTransferServiceClient(); + assert(client); }); - assert.strictEqual(client.dataTransferServiceStub, undefined); - await client.initialize(); - assert(client.dataTransferServiceStub); - }); - it('has close method for the initialized client', done => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('should create a client with gRPC fallback', () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + fallback: true, + } + ); + assert(client); }); - client.initialize(); - assert(client.dataTransferServiceStub); - client.close().then(() => { - done(); + + it('has initialize method and supports deferred initialization', async () => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.dataTransferServiceStub, undefined); + await client.initialize(); + assert(client.dataTransferServiceStub); }); - }); - it('has close method for the non-initialized client', done => { - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has close method for the initialized client', done => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + client.initialize(); + assert(client.dataTransferServiceStub); + client.close().then(() => { + done(); + }); }); - assert.strictEqual(client.dataTransferServiceStub, undefined); - client.close().then(() => { - done(); + + it('has close method for the non-initialized client', done => { + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + } + ); + assert.strictEqual(client.dataTransferServiceStub, undefined); + client.close().then(() => { + done(); + }); }); - }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new datatransferserviceModule.v1.DataTransferServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + 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 datatransferserviceModule.v1.DataTransferServiceClient({ - 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); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datatransferserviceModule.v1.DataTransferServiceClient( + { + 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); }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); }); describe('getDataSource', () => {