From 6860cfded924648ef79706278b66d31736dbfe23 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 14 Sep 2022 23:06:13 +0000 Subject: [PATCH] fix: preserve default values in x-goog-request-params header (#370) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 474338479 Source-Link: https://github.com/googleapis/googleapis/commit/d5d35e0353b59719e8917103b1bc7df2782bf6ba Source-Link: https://github.com/googleapis/googleapis-gen/commit/efcd3f93962a103f68f003e2a1eecde6fa216a27 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZWZjZDNmOTM5NjJhMTAzZjY4ZjAwM2UyYTFlZWNkZTZmYTIxNmEyNyJ9 --- src/v1/dataset_service_client.ts | 38 +- src/v1/endpoint_service_client.ts | 18 +- ...turestore_online_serving_service_client.ts | 4 +- src/v1/featurestore_service_client.ts | 56 +- src/v1/index_endpoint_service_client.ts | 20 +- src/v1/index_service_client.ts | 18 +- src/v1/job_service_client.ts | 80 +- src/v1/metadata_service_client.ts | 82 +- src/v1/migration_service_client.ts | 8 +- src/v1/model_service_client.ts | 46 +- src/v1/pipeline_service_client.ts | 28 +- src/v1/prediction_service_client.ts | 6 +- src/v1/specialist_pool_service_client.ts | 14 +- src/v1/tensorboard_service_client.ts | 76 +- src/v1/vizier_service_client.ts | 38 +- src/v1beta1/dataset_service_client.ts | 38 +- ...deployment_resource_pool_service_client.ts | 18 +- src/v1beta1/endpoint_service_client.ts | 18 +- ...turestore_online_serving_service_client.ts | 6 +- src/v1beta1/featurestore_service_client.ts | 56 +- src/v1beta1/index_endpoint_service_client.ts | 20 +- src/v1beta1/index_service_client.ts | 18 +- src/v1beta1/job_service_client.ts | 80 +- src/v1beta1/metadata_service_client.ts | 82 +- src/v1beta1/migration_service_client.ts | 8 +- src/v1beta1/model_service_client.ts | 48 +- src/v1beta1/pipeline_service_client.ts | 28 +- src/v1beta1/prediction_service_client.ts | 6 +- src/v1beta1/specialist_pool_service_client.ts | 14 +- src/v1beta1/tensorboard_service_client.ts | 76 +- src/v1beta1/vizier_service_client.ts | 38 +- test/gapic_dataset_service_v1.ts | 1323 +++---- test/gapic_dataset_service_v1beta1.ts | 1323 +++---- ...eployment_resource_pool_service_v1beta1.ts | 652 ++-- test/gapic_endpoint_service_v1.ts | 794 ++-- test/gapic_endpoint_service_v1beta1.ts | 794 ++-- ..._featurestore_online_serving_service_v1.ts | 181 +- ...urestore_online_serving_service_v1beta1.ts | 267 +- test/gapic_featurestore_service_v1.ts | 2307 ++++++------ test/gapic_featurestore_service_v1beta1.ts | 2307 ++++++------ test/gapic_index_endpoint_service_v1.ts | 910 ++--- test/gapic_index_endpoint_service_v1beta1.ts | 910 ++--- test/gapic_index_service_v1.ts | 764 ++-- test/gapic_index_service_v1beta1.ts | 764 ++-- test/gapic_job_service_v1.ts | 3074 ++++++++-------- test/gapic_job_service_v1beta1.ts | 3074 ++++++++-------- test/gapic_metadata_service_v1.ts | 3248 +++++++++-------- test/gapic_metadata_service_v1beta1.ts | 3248 +++++++++-------- test/gapic_migration_service_v1.ts | 297 +- test/gapic_migration_service_v1beta1.ts | 297 +- test/gapic_model_service_v1.ts | 1690 ++++----- test/gapic_model_service_v1beta1.ts | 1802 ++++----- test/gapic_pipeline_service_v1.ts | 1082 +++--- test/gapic_pipeline_service_v1beta1.ts | 1082 +++--- test/gapic_prediction_service_v1.ts | 275 +- test/gapic_prediction_service_v1beta1.ts | 275 +- test/gapic_specialist_pool_service_v1.ts | 608 +-- test/gapic_specialist_pool_service_v1beta1.ts | 608 +-- test/gapic_tensorboard_service_v1.ts | 2977 ++++++++------- test/gapic_tensorboard_service_v1beta1.ts | 2977 ++++++++------- test/gapic_vizier_service_v1.ts | 1479 ++++---- test/gapic_vizier_service_v1beta1.ts | 1479 ++++---- 62 files changed, 22801 insertions(+), 21153 deletions(-) diff --git a/src/v1/dataset_service_client.ts b/src/v1/dataset_service_client.ts index 81407020..35f9703b 100644 --- a/src/v1/dataset_service_client.ts +++ b/src/v1/dataset_service_client.ts @@ -1552,7 +1552,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getDataset(request, options, callback); @@ -1651,7 +1651,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'dataset.name': request.dataset!.name || '', + 'dataset.name': request.dataset!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateDataset(request, options, callback); @@ -1746,7 +1746,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getAnnotationSpec(request, options, callback); @@ -1853,7 +1853,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createDataset(request, options, callback); @@ -1993,7 +1993,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteDataset(request, options, callback); @@ -2136,7 +2136,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.importData(request, options, callback); @@ -2278,7 +2278,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.exportData(request, options, callback); @@ -2437,7 +2437,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDatasets(request, options, callback); @@ -2501,7 +2501,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatasets']; const callSettings = defaultCallSettings.merge(options); @@ -2574,7 +2574,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatasets']; const callSettings = defaultCallSettings.merge(options); @@ -2687,7 +2687,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDataItems(request, options, callback); @@ -2734,7 +2734,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDataItems']; const callSettings = defaultCallSettings.merge(options); @@ -2790,7 +2790,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDataItems']; const callSettings = defaultCallSettings.merge(options); @@ -2903,7 +2903,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listSavedQueries(request, options, callback); @@ -2950,7 +2950,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listSavedQueries']; const callSettings = defaultCallSettings.merge(options); @@ -3006,7 +3006,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listSavedQueries']; const callSettings = defaultCallSettings.merge(options); @@ -3119,7 +3119,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listAnnotations(request, options, callback); @@ -3166,7 +3166,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listAnnotations']; const callSettings = defaultCallSettings.merge(options); @@ -3222,7 +3222,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listAnnotations']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/endpoint_service_client.ts b/src/v1/endpoint_service_client.ts index 49ef16d1..29f22efe 100644 --- a/src/v1/endpoint_service_client.ts +++ b/src/v1/endpoint_service_client.ts @@ -1532,7 +1532,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getEndpoint(request, options, callback); @@ -1625,7 +1625,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'endpoint.name': request.endpoint!.name || '', + 'endpoint.name': request.endpoint!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateEndpoint(request, options, callback); @@ -1741,7 +1741,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createEndpoint(request, options, callback); @@ -1881,7 +1881,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteEndpoint(request, options, callback); @@ -2038,7 +2038,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.deployModel(request, options, callback); @@ -2189,7 +2189,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.undeployModel(request, options, callback); @@ -2353,7 +2353,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listEndpoints(request, options, callback); @@ -2422,7 +2422,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listEndpoints']; const callSettings = defaultCallSettings.merge(options); @@ -2500,7 +2500,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listEndpoints']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/featurestore_online_serving_service_client.ts b/src/v1/featurestore_online_serving_service_client.ts index 49bde791..b9b6636f 100644 --- a/src/v1/featurestore_online_serving_service_client.ts +++ b/src/v1/featurestore_online_serving_service_client.ts @@ -1501,7 +1501,7 @@ export class FeaturestoreOnlineServingServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.readFeatureValues(request, options, callback); @@ -1548,7 +1548,7 @@ export class FeaturestoreOnlineServingServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.streamingReadFeatureValues(request, options); diff --git a/src/v1/featurestore_service_client.ts b/src/v1/featurestore_service_client.ts index 439a7a0e..27a46717 100644 --- a/src/v1/featurestore_service_client.ts +++ b/src/v1/featurestore_service_client.ts @@ -1648,7 +1648,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getFeaturestore(request, options, callback); @@ -1741,7 +1741,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getEntityType(request, options, callback); @@ -1855,7 +1855,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'entity_type.name': request.entityType!.name || '', + 'entity_type.name': request.entityType!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateEntityType(request, options, callback); @@ -1942,7 +1942,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getFeature(request, options, callback); @@ -2050,7 +2050,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'feature.name': request.feature!.name || '', + 'feature.name': request.feature!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateFeature(request, options, callback); @@ -2166,7 +2166,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createFeaturestore(request, options, callback); @@ -2321,7 +2321,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'featurestore.name': request.featurestore!.name || '', + 'featurestore.name': request.featurestore!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateFeaturestore(request, options, callback); @@ -2466,7 +2466,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteFeaturestore(request, options, callback); @@ -2616,7 +2616,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createEntityType(request, options, callback); @@ -2760,7 +2760,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteEntityType(request, options, callback); @@ -2910,7 +2910,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createFeature(request, options, callback); @@ -3055,7 +3055,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchCreateFeatures(request, options, callback); @@ -3195,7 +3195,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteFeature(request, options, callback); @@ -3383,7 +3383,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.importFeatureValues(request, options, callback); @@ -3571,7 +3571,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - featurestore: request.featurestore || '', + featurestore: request.featurestore ?? '', }); this.initialize(); return this.innerApiCalls.batchReadFeatureValues( @@ -3727,7 +3727,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.exportFeatureValues(request, options, callback); @@ -3901,7 +3901,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listFeaturestores(request, options, callback); @@ -3980,7 +3980,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listFeaturestores']; const callSettings = defaultCallSettings.merge(options); @@ -4068,7 +4068,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listFeaturestores']; const callSettings = defaultCallSettings.merge(options); @@ -4213,7 +4213,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listEntityTypes(request, options, callback); @@ -4292,7 +4292,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listEntityTypes']; const callSettings = defaultCallSettings.merge(options); @@ -4380,7 +4380,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listEntityTypes']; const callSettings = defaultCallSettings.merge(options); @@ -4532,7 +4532,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listFeatures(request, options, callback); @@ -4618,7 +4618,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listFeatures']; const callSettings = defaultCallSettings.merge(options); @@ -4713,7 +4713,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listFeatures']; const callSettings = defaultCallSettings.merge(options); @@ -4888,7 +4888,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - location: request.location || '', + location: request.location ?? '', }); this.initialize(); return this.innerApiCalls.searchFeatures(request, options, callback); @@ -4997,7 +4997,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - location: request.location || '', + location: request.location ?? '', }); const defaultCallSettings = this._defaults['searchFeatures']; const callSettings = defaultCallSettings.merge(options); @@ -5115,7 +5115,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - location: request.location || '', + location: request.location ?? '', }); const defaultCallSettings = this._defaults['searchFeatures']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/index_endpoint_service_client.ts b/src/v1/index_endpoint_service_client.ts index b104a081..5121cabe 100644 --- a/src/v1/index_endpoint_service_client.ts +++ b/src/v1/index_endpoint_service_client.ts @@ -1550,7 +1550,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getIndexEndpoint(request, options, callback); @@ -1643,7 +1643,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'index_endpoint.name': request.indexEndpoint!.name || '', + 'index_endpoint.name': request.indexEndpoint!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateIndexEndpoint(request, options, callback); @@ -1750,7 +1750,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createIndexEndpoint(request, options, callback); @@ -1890,7 +1890,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteIndexEndpoint(request, options, callback); @@ -2034,7 +2034,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index_endpoint: request.indexEndpoint || '', + index_endpoint: request.indexEndpoint ?? '', }); this.initialize(); return this.innerApiCalls.deployIndex(request, options, callback); @@ -2177,7 +2177,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index_endpoint: request.indexEndpoint || '', + index_endpoint: request.indexEndpoint ?? '', }); this.initialize(); return this.innerApiCalls.undeployIndex(request, options, callback); @@ -2321,7 +2321,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index_endpoint: request.indexEndpoint || '', + index_endpoint: request.indexEndpoint ?? '', }); this.initialize(); return this.innerApiCalls.mutateDeployedIndex(request, options, callback); @@ -2479,7 +2479,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listIndexEndpoints(request, options, callback); @@ -2542,7 +2542,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listIndexEndpoints']; const callSettings = defaultCallSettings.merge(options); @@ -2614,7 +2614,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listIndexEndpoints']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/index_service_client.ts b/src/v1/index_service_client.ts index 1737ae54..bb947da3 100644 --- a/src/v1/index_service_client.ts +++ b/src/v1/index_service_client.ts @@ -1519,7 +1519,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getIndex(request, options, callback); @@ -1614,7 +1614,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index: request.index || '', + index: request.index ?? '', }); this.initialize(); return this.innerApiCalls.upsertDatapoints(request, options, callback); @@ -1709,7 +1709,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index: request.index || '', + index: request.index ?? '', }); this.initialize(); return this.innerApiCalls.removeDatapoints(request, options, callback); @@ -1816,7 +1816,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createIndex(request, options, callback); @@ -1957,7 +1957,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'index.name': request.index!.name || '', + 'index.name': request.index!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateIndex(request, options, callback); @@ -2099,7 +2099,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteIndex(request, options, callback); @@ -2234,7 +2234,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listIndexes(request, options, callback); @@ -2280,7 +2280,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listIndexes']; const callSettings = defaultCallSettings.merge(options); @@ -2335,7 +2335,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listIndexes']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/job_service_client.ts b/src/v1/job_service_client.ts index 953c9f2a..21daa29b 100644 --- a/src/v1/job_service_client.ts +++ b/src/v1/job_service_client.ts @@ -1629,7 +1629,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createCustomJob(request, options, callback); @@ -1716,7 +1716,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getCustomJob(request, options, callback); @@ -1818,7 +1818,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelCustomJob(request, options, callback); @@ -1918,7 +1918,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createDataLabelingJob(request, options, callback); @@ -2011,7 +2011,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getDataLabelingJob(request, options, callback); @@ -2110,7 +2110,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelDataLabelingJob(request, options, callback); @@ -2210,7 +2210,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createHyperparameterTuningJob( @@ -2313,7 +2313,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getHyperparameterTuningJob( @@ -2425,7 +2425,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelHyperparameterTuningJob( @@ -2530,7 +2530,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createBatchPredictionJob( @@ -2633,7 +2633,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getBatchPredictionJob(request, options, callback); @@ -2741,7 +2741,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelBatchPredictionJob( @@ -2846,7 +2846,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createModelDeploymentMonitoringJob( @@ -2949,7 +2949,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getModelDeploymentMonitoringJob( @@ -3054,7 +3054,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.pauseModelDeploymentMonitoringJob( @@ -3159,7 +3159,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.resumeModelDeploymentMonitoringJob( @@ -3269,7 +3269,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteCustomJob(request, options, callback); @@ -3409,7 +3409,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteDataLabelingJob(request, options, callback); @@ -3549,7 +3549,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteHyperparameterTuningJob( @@ -3694,7 +3694,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteBatchPredictionJob( @@ -3866,7 +3866,7 @@ export class JobServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ 'model_deployment_monitoring_job.name': - request.modelDeploymentMonitoringJob!.name || '', + request.modelDeploymentMonitoringJob!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateModelDeploymentMonitoringJob( @@ -4010,7 +4010,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteModelDeploymentMonitoringJob( @@ -4169,7 +4169,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listCustomJobs(request, options, callback); @@ -4229,7 +4229,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listCustomJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4298,7 +4298,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listCustomJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4428,7 +4428,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDataLabelingJobs(request, options, callback); @@ -4492,7 +4492,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDataLabelingJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4565,7 +4565,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDataLabelingJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4691,7 +4691,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listHyperparameterTuningJobs( @@ -4755,7 +4755,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listHyperparameterTuningJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4824,7 +4824,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listHyperparameterTuningJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4951,7 +4951,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listBatchPredictionJobs( @@ -5016,7 +5016,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listBatchPredictionJobs']; const callSettings = defaultCallSettings.merge(options); @@ -5086,7 +5086,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listBatchPredictionJobs']; const callSettings = defaultCallSettings.merge(options); @@ -5211,7 +5211,7 @@ export class JobServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ model_deployment_monitoring_job: - request.modelDeploymentMonitoringJob || '', + request.modelDeploymentMonitoringJob ?? '', }); this.initialize(); return this.innerApiCalls.searchModelDeploymentMonitoringStatsAnomalies( @@ -5274,7 +5274,7 @@ export class JobServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ model_deployment_monitoring_job: - request.modelDeploymentMonitoringJob || '', + request.modelDeploymentMonitoringJob ?? '', }); const defaultCallSettings = this._defaults['searchModelDeploymentMonitoringStatsAnomalies']; @@ -5344,7 +5344,7 @@ export class JobServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ model_deployment_monitoring_job: - request.modelDeploymentMonitoringJob || '', + request.modelDeploymentMonitoringJob ?? '', }); const defaultCallSettings = this._defaults['searchModelDeploymentMonitoringStatsAnomalies']; @@ -5470,7 +5470,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listModelDeploymentMonitoringJobs( @@ -5531,7 +5531,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelDeploymentMonitoringJobs']; @@ -5598,7 +5598,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelDeploymentMonitoringJobs']; diff --git a/src/v1/metadata_service_client.ts b/src/v1/metadata_service_client.ts index 13b58977..60024f46 100644 --- a/src/v1/metadata_service_client.ts +++ b/src/v1/metadata_service_client.ts @@ -1629,7 +1629,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getMetadataStore(request, options, callback); @@ -1733,7 +1733,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createArtifact(request, options, callback); @@ -1820,7 +1820,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getArtifact(request, options, callback); @@ -1921,7 +1921,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'artifact.name': request.artifact!.name || '', + 'artifact.name': request.artifact!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateArtifact(request, options, callback); @@ -2025,7 +2025,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createContext(request, options, callback); @@ -2112,7 +2112,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getContext(request, options, callback); @@ -2213,7 +2213,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'context.name': request.context!.name || '', + 'context.name': request.context!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateContext(request, options, callback); @@ -2326,7 +2326,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - context: request.context || '', + context: request.context ?? '', }); this.initialize(); return this.innerApiCalls.addContextArtifactsAndExecutions( @@ -2430,7 +2430,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - context: request.context || '', + context: request.context ?? '', }); this.initialize(); return this.innerApiCalls.addContextChildren(request, options, callback); @@ -2535,7 +2535,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - context: request.context || '', + context: request.context ?? '', }); this.initialize(); return this.innerApiCalls.queryContextLineageSubgraph( @@ -2644,7 +2644,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createExecution(request, options, callback); @@ -2731,7 +2731,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getExecution(request, options, callback); @@ -2832,7 +2832,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'execution.name': request.execution!.name || '', + 'execution.name': request.execution!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateExecution(request, options, callback); @@ -2931,7 +2931,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - execution: request.execution || '', + execution: request.execution ?? '', }); this.initialize(); return this.innerApiCalls.addExecutionEvents(request, options, callback); @@ -3033,7 +3033,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - execution: request.execution || '', + execution: request.execution ?? '', }); this.initialize(); return this.innerApiCalls.queryExecutionInputsAndOutputs( @@ -3148,7 +3148,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createMetadataSchema(request, options, callback); @@ -3241,7 +3241,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getMetadataSchema(request, options, callback); @@ -3374,7 +3374,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - artifact: request.artifact || '', + artifact: request.artifact ?? '', }); this.initialize(); return this.innerApiCalls.queryArtifactLineageSubgraph( @@ -3495,7 +3495,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createMetadataStore(request, options, callback); @@ -3638,7 +3638,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteMetadataStore(request, options, callback); @@ -3782,7 +3782,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteArtifact(request, options, callback); @@ -3929,7 +3929,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.purgeArtifacts(request, options, callback); @@ -4076,7 +4076,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteContext(request, options, callback); @@ -4223,7 +4223,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.purgeContexts(request, options, callback); @@ -4367,7 +4367,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteExecution(request, options, callback); @@ -4514,7 +4514,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.purgeExecutions(request, options, callback); @@ -4657,7 +4657,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listMetadataStores(request, options, callback); @@ -4705,7 +4705,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMetadataStores']; const callSettings = defaultCallSettings.merge(options); @@ -4762,7 +4762,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMetadataStores']; const callSettings = defaultCallSettings.merge(options); @@ -4902,7 +4902,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listArtifacts(request, options, callback); @@ -4976,7 +4976,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listArtifacts']; const callSettings = defaultCallSettings.merge(options); @@ -5059,7 +5059,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listArtifacts']; const callSettings = defaultCallSettings.merge(options); @@ -5203,7 +5203,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listContexts(request, options, callback); @@ -5281,7 +5281,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listContexts']; const callSettings = defaultCallSettings.merge(options); @@ -5368,7 +5368,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listContexts']; const callSettings = defaultCallSettings.merge(options); @@ -5507,7 +5507,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listExecutions(request, options, callback); @@ -5580,7 +5580,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listExecutions']; const callSettings = defaultCallSettings.merge(options); @@ -5662,7 +5662,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listExecutions']; const callSettings = defaultCallSettings.merge(options); @@ -5778,7 +5778,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listMetadataSchemas(request, options, callback); @@ -5828,7 +5828,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMetadataSchemas']; const callSettings = defaultCallSettings.merge(options); @@ -5887,7 +5887,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMetadataSchemas']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/migration_service_client.ts b/src/v1/migration_service_client.ts index ec9a4c49..bba68cc1 100644 --- a/src/v1/migration_service_client.ts +++ b/src/v1/migration_service_client.ts @@ -1520,7 +1520,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchMigrateResources(request, options, callback); @@ -1673,7 +1673,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.searchMigratableResources( @@ -1733,7 +1733,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['searchMigratableResources']; const callSettings = defaultCallSettings.merge(options); @@ -1798,7 +1798,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['searchMigratableResources']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/model_service_client.ts b/src/v1/model_service_client.ts index 06ac3cce..dbe7797d 100644 --- a/src/v1/model_service_client.ts +++ b/src/v1/model_service_client.ts @@ -1562,7 +1562,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getModel(request, options, callback); @@ -1667,7 +1667,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'model.name': request.model!.name || '', + 'model.name': request.model!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateModel(request, options, callback); @@ -1774,7 +1774,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.mergeVersionAliases(request, options, callback); @@ -1874,7 +1874,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.importModelEvaluation(request, options, callback); @@ -1975,7 +1975,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchImportModelEvaluationSlices( @@ -2072,7 +2072,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getModelEvaluation(request, options, callback); @@ -2171,7 +2171,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getModelEvaluationSlice( @@ -2291,7 +2291,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.uploadModel(request, options, callback); @@ -2434,7 +2434,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteModel(request, options, callback); @@ -2579,7 +2579,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteModelVersion(request, options, callback); @@ -2723,7 +2723,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.exportModel(request, options, callback); @@ -2883,7 +2883,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listModels(request, options, callback); @@ -2954,7 +2954,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModels']; const callSettings = defaultCallSettings.merge(options); @@ -3034,7 +3034,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModels']; const callSettings = defaultCallSettings.merge(options); @@ -3155,7 +3155,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.listModelVersions(request, options, callback); @@ -3210,7 +3210,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listModelVersions']; const callSettings = defaultCallSettings.merge(options); @@ -3274,7 +3274,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listModelVersions']; const callSettings = defaultCallSettings.merge(options); @@ -3386,7 +3386,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listModelEvaluations(request, options, callback); @@ -3432,7 +3432,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelEvaluations']; const callSettings = defaultCallSettings.merge(options); @@ -3487,7 +3487,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelEvaluations']; const callSettings = defaultCallSettings.merge(options); @@ -3602,7 +3602,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listModelEvaluationSlices( @@ -3655,7 +3655,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelEvaluationSlices']; const callSettings = defaultCallSettings.merge(options); @@ -3713,7 +3713,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelEvaluationSlices']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/pipeline_service_client.ts b/src/v1/pipeline_service_client.ts index 29111dec..ceb88dcb 100644 --- a/src/v1/pipeline_service_client.ts +++ b/src/v1/pipeline_service_client.ts @@ -1538,7 +1538,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTrainingPipeline( @@ -1635,7 +1635,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTrainingPipeline(request, options, callback); @@ -1743,7 +1743,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelTrainingPipeline( @@ -1848,7 +1848,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createPipelineJob(request, options, callback); @@ -1941,7 +1941,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getPipelineJob(request, options, callback); @@ -2043,7 +2043,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelPipelineJob(request, options, callback); @@ -2149,7 +2149,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTrainingPipeline( @@ -2293,7 +2293,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deletePipelineJob(request, options, callback); @@ -2450,7 +2450,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTrainingPipelines(request, options, callback); @@ -2512,7 +2512,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTrainingPipelines']; const callSettings = defaultCallSettings.merge(options); @@ -2583,7 +2583,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTrainingPipelines']; const callSettings = defaultCallSettings.merge(options); @@ -2742,7 +2742,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listPipelineJobs(request, options, callback); @@ -2835,7 +2835,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listPipelineJobs']; const callSettings = defaultCallSettings.merge(options); @@ -2937,7 +2937,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listPipelineJobs']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/prediction_service_client.ts b/src/v1/prediction_service_client.ts index d7d49033..3c31bb66 100644 --- a/src/v1/prediction_service_client.ts +++ b/src/v1/prediction_service_client.ts @@ -1472,7 +1472,7 @@ export class PredictionServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.predict(request, options, callback); @@ -1581,7 +1581,7 @@ export class PredictionServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.rawPredict(request, options, callback); @@ -1702,7 +1702,7 @@ export class PredictionServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.explain(request, options, callback); diff --git a/src/v1/specialist_pool_service_client.ts b/src/v1/specialist_pool_service_client.ts index 6120cf3e..66ab0597 100644 --- a/src/v1/specialist_pool_service_client.ts +++ b/src/v1/specialist_pool_service_client.ts @@ -1532,7 +1532,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getSpecialistPool(request, options, callback); @@ -1639,7 +1639,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createSpecialistPool(request, options, callback); @@ -1782,7 +1782,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteSpecialistPool(request, options, callback); @@ -1922,7 +1922,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'specialist_pool.name': request.specialistPool!.name || '', + 'specialist_pool.name': request.specialistPool!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateSpecialistPool(request, options, callback); @@ -2061,7 +2061,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listSpecialistPools(request, options, callback); @@ -2105,7 +2105,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listSpecialistPools']; const callSettings = defaultCallSettings.merge(options); @@ -2158,7 +2158,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listSpecialistPools']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1/tensorboard_service_client.ts b/src/v1/tensorboard_service_client.ts index a4e56831..a96220ba 100644 --- a/src/v1/tensorboard_service_client.ts +++ b/src/v1/tensorboard_service_client.ts @@ -1637,7 +1637,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTensorboard(request, options, callback); @@ -1744,7 +1744,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTensorboardExperiment( @@ -1847,7 +1847,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTensorboardExperiment( @@ -1958,7 +1958,7 @@ export class TensorboardServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ 'tensorboard_experiment.name': - request.tensorboardExperiment!.name || '', + request.tensorboardExperiment!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateTensorboardExperiment( @@ -2069,7 +2069,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTensorboardRun(request, options, callback); @@ -2173,7 +2173,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchCreateTensorboardRuns( @@ -2270,7 +2270,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTensorboardRun(request, options, callback); @@ -2376,7 +2376,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'tensorboard_run.name': request.tensorboardRun!.name || '', + 'tensorboard_run.name': request.tensorboardRun!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateTensorboardRun(request, options, callback); @@ -2482,7 +2482,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchCreateTensorboardTimeSeries( @@ -2593,7 +2593,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTensorboardTimeSeries( @@ -2696,7 +2696,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTensorboardTimeSeries( @@ -2808,7 +2808,7 @@ export class TensorboardServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ 'tensorboard_time_series.name': - request.tensorboardTimeSeries!.name || '', + request.tensorboardTimeSeries!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateTensorboardTimeSeries( @@ -2920,7 +2920,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard: request.tensorboard || '', + tensorboard: request.tensorboard ?? '', }); this.initialize(); return this.innerApiCalls.batchReadTensorboardTimeSeriesData( @@ -3034,7 +3034,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_time_series: request.tensorboardTimeSeries || '', + tensorboard_time_series: request.tensorboardTimeSeries ?? '', }); this.initialize(); return this.innerApiCalls.readTensorboardTimeSeriesData( @@ -3141,7 +3141,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_experiment: request.tensorboardExperiment || '', + tensorboard_experiment: request.tensorboardExperiment ?? '', }); this.initialize(); return this.innerApiCalls.writeTensorboardExperimentData( @@ -3252,7 +3252,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_run: request.tensorboardRun || '', + tensorboard_run: request.tensorboardRun ?? '', }); this.initialize(); return this.innerApiCalls.writeTensorboardRunData( @@ -3296,7 +3296,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - time_series: request.timeSeries || '', + time_series: request.timeSeries ?? '', }); this.initialize(); return this.innerApiCalls.readTensorboardBlobData(request, options); @@ -3403,7 +3403,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTensorboard(request, options, callback); @@ -3550,7 +3550,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'tensorboard.name': request.tensorboard!.name || '', + 'tensorboard.name': request.tensorboard!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateTensorboard(request, options, callback); @@ -3690,7 +3690,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTensorboard(request, options, callback); @@ -3830,7 +3830,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTensorboardExperiment( @@ -3974,7 +3974,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTensorboardRun(request, options, callback); @@ -4114,7 +4114,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTensorboardTimeSeries( @@ -4268,7 +4268,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTensorboards(request, options, callback); @@ -4323,7 +4323,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboards']; const callSettings = defaultCallSettings.merge(options); @@ -4387,7 +4387,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboards']; const callSettings = defaultCallSettings.merge(options); @@ -4508,7 +4508,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTensorboardExperiments( @@ -4567,7 +4567,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardExperiments']; const callSettings = defaultCallSettings.merge(options); @@ -4631,7 +4631,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardExperiments']; const callSettings = defaultCallSettings.merge(options); @@ -4752,7 +4752,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTensorboardRuns(request, options, callback); @@ -4807,7 +4807,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardRuns']; const callSettings = defaultCallSettings.merge(options); @@ -4871,7 +4871,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardRuns']; const callSettings = defaultCallSettings.merge(options); @@ -4992,7 +4992,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTensorboardTimeSeries( @@ -5051,7 +5051,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardTimeSeries']; const callSettings = defaultCallSettings.merge(options); @@ -5115,7 +5115,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardTimeSeries']; const callSettings = defaultCallSettings.merge(options); @@ -5236,7 +5236,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_time_series: request.tensorboardTimeSeries || '', + tensorboard_time_series: request.tensorboardTimeSeries ?? '', }); this.initialize(); return this.innerApiCalls.exportTensorboardTimeSeriesData( @@ -5294,7 +5294,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_time_series: request.tensorboardTimeSeries || '', + tensorboard_time_series: request.tensorboardTimeSeries ?? '', }); const defaultCallSettings = this._defaults['exportTensorboardTimeSeriesData']; @@ -5358,7 +5358,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_time_series: request.tensorboardTimeSeries || '', + tensorboard_time_series: request.tensorboardTimeSeries ?? '', }); const defaultCallSettings = this._defaults['exportTensorboardTimeSeriesData']; diff --git a/src/v1/vizier_service_client.ts b/src/v1/vizier_service_client.ts index 17061cff..41a69050 100644 --- a/src/v1/vizier_service_client.ts +++ b/src/v1/vizier_service_client.ts @@ -1533,7 +1533,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createStudy(request, options, callback); @@ -1617,7 +1617,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getStudy(request, options, callback); @@ -1703,7 +1703,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteStudy(request, options, callback); @@ -1792,7 +1792,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.lookupStudy(request, options, callback); @@ -1880,7 +1880,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTrial(request, options, callback); @@ -1965,7 +1965,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTrial(request, options, callback); @@ -2061,7 +2061,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - trial_name: request.trialName || '', + trial_name: request.trialName ?? '', }); this.initialize(); return this.innerApiCalls.addTrialMeasurement(request, options, callback); @@ -2164,7 +2164,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.completeTrial(request, options, callback); @@ -2251,7 +2251,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTrial(request, options, callback); @@ -2338,7 +2338,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.stopTrial(request, options, callback); @@ -2432,7 +2432,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listOptimalTrials(request, options, callback); @@ -2549,7 +2549,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.suggestTrials(request, options, callback); @@ -2692,7 +2692,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - trial_name: request.trialName || '', + trial_name: request.trialName ?? '', }); this.initialize(); return this.innerApiCalls.checkTrialEarlyStoppingState( @@ -2826,7 +2826,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listStudies(request, options, callback); @@ -2867,7 +2867,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listStudies']; const callSettings = defaultCallSettings.merge(options); @@ -2917,7 +2917,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listStudies']; const callSettings = defaultCallSettings.merge(options); @@ -3018,7 +3018,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTrials(request, options, callback); @@ -3059,7 +3059,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTrials']; const callSettings = defaultCallSettings.merge(options); @@ -3109,7 +3109,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTrials']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/dataset_service_client.ts b/src/v1beta1/dataset_service_client.ts index 34fcd606..748e4e0d 100644 --- a/src/v1beta1/dataset_service_client.ts +++ b/src/v1beta1/dataset_service_client.ts @@ -1626,7 +1626,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getDataset(request, options, callback); @@ -1725,7 +1725,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'dataset.name': request.dataset!.name || '', + 'dataset.name': request.dataset!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateDataset(request, options, callback); @@ -1826,7 +1826,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getAnnotationSpec(request, options, callback); @@ -1933,7 +1933,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createDataset(request, options, callback); @@ -2073,7 +2073,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteDataset(request, options, callback); @@ -2216,7 +2216,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.importData(request, options, callback); @@ -2358,7 +2358,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.exportData(request, options, callback); @@ -2517,7 +2517,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDatasets(request, options, callback); @@ -2581,7 +2581,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatasets']; const callSettings = defaultCallSettings.merge(options); @@ -2654,7 +2654,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDatasets']; const callSettings = defaultCallSettings.merge(options); @@ -2767,7 +2767,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDataItems(request, options, callback); @@ -2814,7 +2814,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDataItems']; const callSettings = defaultCallSettings.merge(options); @@ -2870,7 +2870,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDataItems']; const callSettings = defaultCallSettings.merge(options); @@ -2983,7 +2983,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listSavedQueries(request, options, callback); @@ -3030,7 +3030,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listSavedQueries']; const callSettings = defaultCallSettings.merge(options); @@ -3086,7 +3086,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listSavedQueries']; const callSettings = defaultCallSettings.merge(options); @@ -3199,7 +3199,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listAnnotations(request, options, callback); @@ -3246,7 +3246,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listAnnotations']; const callSettings = defaultCallSettings.merge(options); @@ -3302,7 +3302,7 @@ export class DatasetServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listAnnotations']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/deployment_resource_pool_service_client.ts b/src/v1beta1/deployment_resource_pool_service_client.ts index f4ef8b4e..c0055dc2 100644 --- a/src/v1beta1/deployment_resource_pool_service_client.ts +++ b/src/v1beta1/deployment_resource_pool_service_client.ts @@ -1606,7 +1606,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getDeploymentResourcePool( @@ -1724,7 +1724,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createDeploymentResourcePool( @@ -1868,7 +1868,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteDeploymentResourcePool( @@ -2012,7 +2012,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDeploymentResourcePools( @@ -2061,7 +2061,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDeploymentResourcePools']; const callSettings = defaultCallSettings.merge(options); @@ -2115,7 +2115,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDeploymentResourcePools']; const callSettings = defaultCallSettings.merge(options); @@ -2227,7 +2227,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - deployment_resource_pool: request.deploymentResourcePool || '', + deployment_resource_pool: request.deploymentResourcePool ?? '', }); this.initialize(); return this.innerApiCalls.queryDeployedModels(request, options, callback); @@ -2273,7 +2273,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - deployment_resource_pool: request.deploymentResourcePool || '', + deployment_resource_pool: request.deploymentResourcePool ?? '', }); const defaultCallSettings = this._defaults['queryDeployedModels']; const callSettings = defaultCallSettings.merge(options); @@ -2328,7 +2328,7 @@ export class DeploymentResourcePoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - deployment_resource_pool: request.deploymentResourcePool || '', + deployment_resource_pool: request.deploymentResourcePool ?? '', }); const defaultCallSettings = this._defaults['queryDeployedModels']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/endpoint_service_client.ts b/src/v1beta1/endpoint_service_client.ts index 7a234bb3..4c9bbd32 100644 --- a/src/v1beta1/endpoint_service_client.ts +++ b/src/v1beta1/endpoint_service_client.ts @@ -1606,7 +1606,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getEndpoint(request, options, callback); @@ -1699,7 +1699,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'endpoint.name': request.endpoint!.name || '', + 'endpoint.name': request.endpoint!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateEndpoint(request, options, callback); @@ -1815,7 +1815,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createEndpoint(request, options, callback); @@ -1955,7 +1955,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteEndpoint(request, options, callback); @@ -2112,7 +2112,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.deployModel(request, options, callback); @@ -2263,7 +2263,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.undeployModel(request, options, callback); @@ -2418,7 +2418,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listEndpoints(request, options, callback); @@ -2478,7 +2478,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listEndpoints']; const callSettings = defaultCallSettings.merge(options); @@ -2547,7 +2547,7 @@ export class EndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listEndpoints']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/featurestore_online_serving_service_client.ts b/src/v1beta1/featurestore_online_serving_service_client.ts index 41657a8b..7d434919 100644 --- a/src/v1beta1/featurestore_online_serving_service_client.ts +++ b/src/v1beta1/featurestore_online_serving_service_client.ts @@ -1576,7 +1576,7 @@ export class FeaturestoreOnlineServingServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.readFeatureValues(request, options, callback); @@ -1684,7 +1684,7 @@ export class FeaturestoreOnlineServingServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.writeFeatureValues(request, options, callback); @@ -1731,7 +1731,7 @@ export class FeaturestoreOnlineServingServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.streamingReadFeatureValues(request, options); diff --git a/src/v1beta1/featurestore_service_client.ts b/src/v1beta1/featurestore_service_client.ts index 015506ec..7805fa3c 100644 --- a/src/v1beta1/featurestore_service_client.ts +++ b/src/v1beta1/featurestore_service_client.ts @@ -1723,7 +1723,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getFeaturestore(request, options, callback); @@ -1816,7 +1816,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getEntityType(request, options, callback); @@ -1936,7 +1936,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'entity_type.name': request.entityType!.name || '', + 'entity_type.name': request.entityType!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateEntityType(request, options, callback); @@ -2029,7 +2029,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getFeature(request, options, callback); @@ -2137,7 +2137,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'feature.name': request.feature!.name || '', + 'feature.name': request.feature!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateFeature(request, options, callback); @@ -2253,7 +2253,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createFeaturestore(request, options, callback); @@ -2408,7 +2408,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'featurestore.name': request.featurestore!.name || '', + 'featurestore.name': request.featurestore!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateFeaturestore(request, options, callback); @@ -2553,7 +2553,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteFeaturestore(request, options, callback); @@ -2703,7 +2703,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createEntityType(request, options, callback); @@ -2847,7 +2847,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteEntityType(request, options, callback); @@ -2997,7 +2997,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createFeature(request, options, callback); @@ -3142,7 +3142,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchCreateFeatures(request, options, callback); @@ -3282,7 +3282,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteFeature(request, options, callback); @@ -3470,7 +3470,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.importFeatureValues(request, options, callback); @@ -3658,7 +3658,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - featurestore: request.featurestore || '', + featurestore: request.featurestore ?? '', }); this.initialize(); return this.innerApiCalls.batchReadFeatureValues( @@ -3814,7 +3814,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - entity_type: request.entityType || '', + entity_type: request.entityType ?? '', }); this.initialize(); return this.innerApiCalls.exportFeatureValues(request, options, callback); @@ -3988,7 +3988,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listFeaturestores(request, options, callback); @@ -4067,7 +4067,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listFeaturestores']; const callSettings = defaultCallSettings.merge(options); @@ -4155,7 +4155,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listFeaturestores']; const callSettings = defaultCallSettings.merge(options); @@ -4300,7 +4300,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listEntityTypes(request, options, callback); @@ -4379,7 +4379,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listEntityTypes']; const callSettings = defaultCallSettings.merge(options); @@ -4467,7 +4467,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listEntityTypes']; const callSettings = defaultCallSettings.merge(options); @@ -4619,7 +4619,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listFeatures(request, options, callback); @@ -4705,7 +4705,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listFeatures']; const callSettings = defaultCallSettings.merge(options); @@ -4800,7 +4800,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listFeatures']; const callSettings = defaultCallSettings.merge(options); @@ -4975,7 +4975,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - location: request.location || '', + location: request.location ?? '', }); this.initialize(); return this.innerApiCalls.searchFeatures(request, options, callback); @@ -5084,7 +5084,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - location: request.location || '', + location: request.location ?? '', }); const defaultCallSettings = this._defaults['searchFeatures']; const callSettings = defaultCallSettings.merge(options); @@ -5202,7 +5202,7 @@ export class FeaturestoreServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - location: request.location || '', + location: request.location ?? '', }); const defaultCallSettings = this._defaults['searchFeatures']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/index_endpoint_service_client.ts b/src/v1beta1/index_endpoint_service_client.ts index 9c63c400..1021257b 100644 --- a/src/v1beta1/index_endpoint_service_client.ts +++ b/src/v1beta1/index_endpoint_service_client.ts @@ -1625,7 +1625,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getIndexEndpoint(request, options, callback); @@ -1724,7 +1724,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'index_endpoint.name': request.indexEndpoint!.name || '', + 'index_endpoint.name': request.indexEndpoint!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateIndexEndpoint(request, options, callback); @@ -1831,7 +1831,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createIndexEndpoint(request, options, callback); @@ -1971,7 +1971,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteIndexEndpoint(request, options, callback); @@ -2115,7 +2115,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index_endpoint: request.indexEndpoint || '', + index_endpoint: request.indexEndpoint ?? '', }); this.initialize(); return this.innerApiCalls.deployIndex(request, options, callback); @@ -2258,7 +2258,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index_endpoint: request.indexEndpoint || '', + index_endpoint: request.indexEndpoint ?? '', }); this.initialize(); return this.innerApiCalls.undeployIndex(request, options, callback); @@ -2402,7 +2402,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index_endpoint: request.indexEndpoint || '', + index_endpoint: request.indexEndpoint ?? '', }); this.initialize(); return this.innerApiCalls.mutateDeployedIndex(request, options, callback); @@ -2560,7 +2560,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listIndexEndpoints(request, options, callback); @@ -2623,7 +2623,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listIndexEndpoints']; const callSettings = defaultCallSettings.merge(options); @@ -2695,7 +2695,7 @@ export class IndexEndpointServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listIndexEndpoints']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/index_service_client.ts b/src/v1beta1/index_service_client.ts index 175e6939..fbd51907 100644 --- a/src/v1beta1/index_service_client.ts +++ b/src/v1beta1/index_service_client.ts @@ -1595,7 +1595,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getIndex(request, options, callback); @@ -1696,7 +1696,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index: request.index || '', + index: request.index ?? '', }); this.initialize(); return this.innerApiCalls.upsertDatapoints(request, options, callback); @@ -1797,7 +1797,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - index: request.index || '', + index: request.index ?? '', }); this.initialize(); return this.innerApiCalls.removeDatapoints(request, options, callback); @@ -1904,7 +1904,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createIndex(request, options, callback); @@ -2045,7 +2045,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'index.name': request.index!.name || '', + 'index.name': request.index!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateIndex(request, options, callback); @@ -2187,7 +2187,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteIndex(request, options, callback); @@ -2328,7 +2328,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listIndexes(request, options, callback); @@ -2374,7 +2374,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listIndexes']; const callSettings = defaultCallSettings.merge(options); @@ -2429,7 +2429,7 @@ export class IndexServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listIndexes']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/job_service_client.ts b/src/v1beta1/job_service_client.ts index 1410cffa..0322d5ff 100644 --- a/src/v1beta1/job_service_client.ts +++ b/src/v1beta1/job_service_client.ts @@ -1703,7 +1703,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createCustomJob(request, options, callback); @@ -1796,7 +1796,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getCustomJob(request, options, callback); @@ -1904,7 +1904,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelCustomJob(request, options, callback); @@ -2004,7 +2004,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createDataLabelingJob(request, options, callback); @@ -2103,7 +2103,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getDataLabelingJob(request, options, callback); @@ -2202,7 +2202,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelDataLabelingJob(request, options, callback); @@ -2302,7 +2302,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createHyperparameterTuningJob( @@ -2405,7 +2405,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getHyperparameterTuningJob( @@ -2517,7 +2517,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelHyperparameterTuningJob( @@ -2622,7 +2622,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createBatchPredictionJob( @@ -2725,7 +2725,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getBatchPredictionJob(request, options, callback); @@ -2833,7 +2833,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelBatchPredictionJob( @@ -2938,7 +2938,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createModelDeploymentMonitoringJob( @@ -3041,7 +3041,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getModelDeploymentMonitoringJob( @@ -3146,7 +3146,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.pauseModelDeploymentMonitoringJob( @@ -3251,7 +3251,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.resumeModelDeploymentMonitoringJob( @@ -3361,7 +3361,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteCustomJob(request, options, callback); @@ -3501,7 +3501,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteDataLabelingJob(request, options, callback); @@ -3641,7 +3641,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteHyperparameterTuningJob( @@ -3786,7 +3786,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteBatchPredictionJob( @@ -3958,7 +3958,7 @@ export class JobServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ 'model_deployment_monitoring_job.name': - request.modelDeploymentMonitoringJob!.name || '', + request.modelDeploymentMonitoringJob!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateModelDeploymentMonitoringJob( @@ -4102,7 +4102,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteModelDeploymentMonitoringJob( @@ -4261,7 +4261,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listCustomJobs(request, options, callback); @@ -4321,7 +4321,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listCustomJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4390,7 +4390,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listCustomJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4520,7 +4520,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listDataLabelingJobs(request, options, callback); @@ -4584,7 +4584,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDataLabelingJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4657,7 +4657,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listDataLabelingJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4783,7 +4783,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listHyperparameterTuningJobs( @@ -4847,7 +4847,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listHyperparameterTuningJobs']; const callSettings = defaultCallSettings.merge(options); @@ -4916,7 +4916,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listHyperparameterTuningJobs']; const callSettings = defaultCallSettings.merge(options); @@ -5043,7 +5043,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listBatchPredictionJobs( @@ -5108,7 +5108,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listBatchPredictionJobs']; const callSettings = defaultCallSettings.merge(options); @@ -5178,7 +5178,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listBatchPredictionJobs']; const callSettings = defaultCallSettings.merge(options); @@ -5303,7 +5303,7 @@ export class JobServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ model_deployment_monitoring_job: - request.modelDeploymentMonitoringJob || '', + request.modelDeploymentMonitoringJob ?? '', }); this.initialize(); return this.innerApiCalls.searchModelDeploymentMonitoringStatsAnomalies( @@ -5366,7 +5366,7 @@ export class JobServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ model_deployment_monitoring_job: - request.modelDeploymentMonitoringJob || '', + request.modelDeploymentMonitoringJob ?? '', }); const defaultCallSettings = this._defaults['searchModelDeploymentMonitoringStatsAnomalies']; @@ -5436,7 +5436,7 @@ export class JobServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ model_deployment_monitoring_job: - request.modelDeploymentMonitoringJob || '', + request.modelDeploymentMonitoringJob ?? '', }); const defaultCallSettings = this._defaults['searchModelDeploymentMonitoringStatsAnomalies']; @@ -5562,7 +5562,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listModelDeploymentMonitoringJobs( @@ -5623,7 +5623,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelDeploymentMonitoringJobs']; @@ -5690,7 +5690,7 @@ export class JobServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelDeploymentMonitoringJobs']; diff --git a/src/v1beta1/metadata_service_client.ts b/src/v1beta1/metadata_service_client.ts index ad3bb89a..b1194ef6 100644 --- a/src/v1beta1/metadata_service_client.ts +++ b/src/v1beta1/metadata_service_client.ts @@ -1703,7 +1703,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getMetadataStore(request, options, callback); @@ -1807,7 +1807,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createArtifact(request, options, callback); @@ -1900,7 +1900,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getArtifact(request, options, callback); @@ -2001,7 +2001,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'artifact.name': request.artifact!.name || '', + 'artifact.name': request.artifact!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateArtifact(request, options, callback); @@ -2105,7 +2105,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createContext(request, options, callback); @@ -2198,7 +2198,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getContext(request, options, callback); @@ -2299,7 +2299,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'context.name': request.context!.name || '', + 'context.name': request.context!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateContext(request, options, callback); @@ -2412,7 +2412,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - context: request.context || '', + context: request.context ?? '', }); this.initialize(); return this.innerApiCalls.addContextArtifactsAndExecutions( @@ -2522,7 +2522,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - context: request.context || '', + context: request.context ?? '', }); this.initialize(); return this.innerApiCalls.addContextChildren(request, options, callback); @@ -2627,7 +2627,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - context: request.context || '', + context: request.context ?? '', }); this.initialize(); return this.innerApiCalls.queryContextLineageSubgraph( @@ -2742,7 +2742,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createExecution(request, options, callback); @@ -2835,7 +2835,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getExecution(request, options, callback); @@ -2942,7 +2942,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'execution.name': request.execution!.name || '', + 'execution.name': request.execution!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateExecution(request, options, callback); @@ -3047,7 +3047,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - execution: request.execution || '', + execution: request.execution ?? '', }); this.initialize(); return this.innerApiCalls.addExecutionEvents(request, options, callback); @@ -3149,7 +3149,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - execution: request.execution || '', + execution: request.execution ?? '', }); this.initialize(); return this.innerApiCalls.queryExecutionInputsAndOutputs( @@ -3264,7 +3264,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createMetadataSchema(request, options, callback); @@ -3363,7 +3363,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getMetadataSchema(request, options, callback); @@ -3496,7 +3496,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - artifact: request.artifact || '', + artifact: request.artifact ?? '', }); this.initialize(); return this.innerApiCalls.queryArtifactLineageSubgraph( @@ -3617,7 +3617,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createMetadataStore(request, options, callback); @@ -3760,7 +3760,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteMetadataStore(request, options, callback); @@ -3904,7 +3904,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteArtifact(request, options, callback); @@ -4051,7 +4051,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.purgeArtifacts(request, options, callback); @@ -4198,7 +4198,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteContext(request, options, callback); @@ -4345,7 +4345,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.purgeContexts(request, options, callback); @@ -4489,7 +4489,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteExecution(request, options, callback); @@ -4636,7 +4636,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.purgeExecutions(request, options, callback); @@ -4779,7 +4779,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listMetadataStores(request, options, callback); @@ -4827,7 +4827,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMetadataStores']; const callSettings = defaultCallSettings.merge(options); @@ -4884,7 +4884,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMetadataStores']; const callSettings = defaultCallSettings.merge(options); @@ -5024,7 +5024,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listArtifacts(request, options, callback); @@ -5098,7 +5098,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listArtifacts']; const callSettings = defaultCallSettings.merge(options); @@ -5181,7 +5181,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listArtifacts']; const callSettings = defaultCallSettings.merge(options); @@ -5325,7 +5325,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listContexts(request, options, callback); @@ -5403,7 +5403,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listContexts']; const callSettings = defaultCallSettings.merge(options); @@ -5490,7 +5490,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listContexts']; const callSettings = defaultCallSettings.merge(options); @@ -5629,7 +5629,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listExecutions(request, options, callback); @@ -5702,7 +5702,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listExecutions']; const callSettings = defaultCallSettings.merge(options); @@ -5784,7 +5784,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listExecutions']; const callSettings = defaultCallSettings.merge(options); @@ -5900,7 +5900,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listMetadataSchemas(request, options, callback); @@ -5950,7 +5950,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMetadataSchemas']; const callSettings = defaultCallSettings.merge(options); @@ -6009,7 +6009,7 @@ export class MetadataServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listMetadataSchemas']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/migration_service_client.ts b/src/v1beta1/migration_service_client.ts index a816966f..9d7e5ca1 100644 --- a/src/v1beta1/migration_service_client.ts +++ b/src/v1beta1/migration_service_client.ts @@ -1589,7 +1589,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchMigrateResources(request, options, callback); @@ -1742,7 +1742,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.searchMigratableResources( @@ -1802,7 +1802,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['searchMigratableResources']; const callSettings = defaultCallSettings.merge(options); @@ -1867,7 +1867,7 @@ export class MigrationServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['searchMigratableResources']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/model_service_client.ts b/src/v1beta1/model_service_client.ts index 208775f1..a89bb9fd 100644 --- a/src/v1beta1/model_service_client.ts +++ b/src/v1beta1/model_service_client.ts @@ -1654,7 +1654,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getModel(request, options, callback); @@ -1765,7 +1765,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'model.name': request.model!.name || '', + 'model.name': request.model!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateModel(request, options, callback); @@ -1878,7 +1878,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.mergeVersionAliases(request, options, callback); @@ -1978,7 +1978,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.importModelEvaluation(request, options, callback); @@ -2079,7 +2079,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchImportModelEvaluationSlices( @@ -2182,7 +2182,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getModelEvaluation(request, options, callback); @@ -2281,7 +2281,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getModelEvaluationSlice( @@ -2401,7 +2401,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.uploadModel(request, options, callback); @@ -2542,7 +2542,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - model: request.model || '', + model: request.model ?? '', }); this.initialize(); return this.innerApiCalls.updateExplanationDataset( @@ -2689,7 +2689,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteModel(request, options, callback); @@ -2834,7 +2834,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteModelVersion(request, options, callback); @@ -2978,7 +2978,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.exportModel(request, options, callback); @@ -3134,7 +3134,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listModels(request, options, callback); @@ -3195,7 +3195,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModels']; const callSettings = defaultCallSettings.merge(options); @@ -3265,7 +3265,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModels']; const callSettings = defaultCallSettings.merge(options); @@ -3386,7 +3386,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.listModelVersions(request, options, callback); @@ -3441,7 +3441,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listModelVersions']; const callSettings = defaultCallSettings.merge(options); @@ -3505,7 +3505,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); const defaultCallSettings = this._defaults['listModelVersions']; const callSettings = defaultCallSettings.merge(options); @@ -3617,7 +3617,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listModelEvaluations(request, options, callback); @@ -3663,7 +3663,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelEvaluations']; const callSettings = defaultCallSettings.merge(options); @@ -3718,7 +3718,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelEvaluations']; const callSettings = defaultCallSettings.merge(options); @@ -3833,7 +3833,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listModelEvaluationSlices( @@ -3886,7 +3886,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelEvaluationSlices']; const callSettings = defaultCallSettings.merge(options); @@ -3944,7 +3944,7 @@ export class ModelServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listModelEvaluationSlices']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/pipeline_service_client.ts b/src/v1beta1/pipeline_service_client.ts index cb1c1948..9720b065 100644 --- a/src/v1beta1/pipeline_service_client.ts +++ b/src/v1beta1/pipeline_service_client.ts @@ -1606,7 +1606,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTrainingPipeline( @@ -1709,7 +1709,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTrainingPipeline(request, options, callback); @@ -1817,7 +1817,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelTrainingPipeline( @@ -1928,7 +1928,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createPipelineJob(request, options, callback); @@ -2021,7 +2021,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getPipelineJob(request, options, callback); @@ -2129,7 +2129,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.cancelPipelineJob(request, options, callback); @@ -2235,7 +2235,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTrainingPipeline( @@ -2379,7 +2379,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deletePipelineJob(request, options, callback); @@ -2536,7 +2536,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTrainingPipelines(request, options, callback); @@ -2598,7 +2598,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTrainingPipelines']; const callSettings = defaultCallSettings.merge(options); @@ -2669,7 +2669,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTrainingPipelines']; const callSettings = defaultCallSettings.merge(options); @@ -2826,7 +2826,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listPipelineJobs(request, options, callback); @@ -2917,7 +2917,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listPipelineJobs']; const callSettings = defaultCallSettings.merge(options); @@ -3017,7 +3017,7 @@ export class PipelineServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listPipelineJobs']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/prediction_service_client.ts b/src/v1beta1/prediction_service_client.ts index 9ea08805..5637e71d 100644 --- a/src/v1beta1/prediction_service_client.ts +++ b/src/v1beta1/prediction_service_client.ts @@ -1543,7 +1543,7 @@ export class PredictionServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.predict(request, options, callback); @@ -1658,7 +1658,7 @@ export class PredictionServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.rawPredict(request, options, callback); @@ -1781,7 +1781,7 @@ export class PredictionServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - endpoint: request.endpoint || '', + endpoint: request.endpoint ?? '', }); this.initialize(); return this.innerApiCalls.explain(request, options, callback); diff --git a/src/v1beta1/specialist_pool_service_client.ts b/src/v1beta1/specialist_pool_service_client.ts index 7cef0f40..2746d012 100644 --- a/src/v1beta1/specialist_pool_service_client.ts +++ b/src/v1beta1/specialist_pool_service_client.ts @@ -1606,7 +1606,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getSpecialistPool(request, options, callback); @@ -1713,7 +1713,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createSpecialistPool(request, options, callback); @@ -1856,7 +1856,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteSpecialistPool(request, options, callback); @@ -1996,7 +1996,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'specialist_pool.name': request.specialistPool!.name || '', + 'specialist_pool.name': request.specialistPool!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateSpecialistPool(request, options, callback); @@ -2135,7 +2135,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listSpecialistPools(request, options, callback); @@ -2179,7 +2179,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listSpecialistPools']; const callSettings = defaultCallSettings.merge(options); @@ -2232,7 +2232,7 @@ export class SpecialistPoolServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listSpecialistPools']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1beta1/tensorboard_service_client.ts b/src/v1beta1/tensorboard_service_client.ts index 28668861..beb5e659 100644 --- a/src/v1beta1/tensorboard_service_client.ts +++ b/src/v1beta1/tensorboard_service_client.ts @@ -1703,7 +1703,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTensorboard(request, options, callback); @@ -1810,7 +1810,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTensorboardExperiment( @@ -1913,7 +1913,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTensorboardExperiment( @@ -2024,7 +2024,7 @@ export class TensorboardServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ 'tensorboard_experiment.name': - request.tensorboardExperiment!.name || '', + request.tensorboardExperiment!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateTensorboardExperiment( @@ -2135,7 +2135,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTensorboardRun(request, options, callback); @@ -2239,7 +2239,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchCreateTensorboardRuns( @@ -2342,7 +2342,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTensorboardRun(request, options, callback); @@ -2448,7 +2448,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'tensorboard_run.name': request.tensorboardRun!.name || '', + 'tensorboard_run.name': request.tensorboardRun!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateTensorboardRun(request, options, callback); @@ -2554,7 +2554,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.batchCreateTensorboardTimeSeries( @@ -2665,7 +2665,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTensorboardTimeSeries( @@ -2768,7 +2768,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTensorboardTimeSeries( @@ -2880,7 +2880,7 @@ export class TensorboardServiceClient { options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ 'tensorboard_time_series.name': - request.tensorboardTimeSeries!.name || '', + request.tensorboardTimeSeries!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateTensorboardTimeSeries( @@ -2992,7 +2992,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard: request.tensorboard || '', + tensorboard: request.tensorboard ?? '', }); this.initialize(); return this.innerApiCalls.batchReadTensorboardTimeSeriesData( @@ -3106,7 +3106,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_time_series: request.tensorboardTimeSeries || '', + tensorboard_time_series: request.tensorboardTimeSeries ?? '', }); this.initialize(); return this.innerApiCalls.readTensorboardTimeSeriesData( @@ -3213,7 +3213,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_experiment: request.tensorboardExperiment || '', + tensorboard_experiment: request.tensorboardExperiment ?? '', }); this.initialize(); return this.innerApiCalls.writeTensorboardExperimentData( @@ -3324,7 +3324,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_run: request.tensorboardRun || '', + tensorboard_run: request.tensorboardRun ?? '', }); this.initialize(); return this.innerApiCalls.writeTensorboardRunData( @@ -3368,7 +3368,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - time_series: request.timeSeries || '', + time_series: request.timeSeries ?? '', }); this.initialize(); return this.innerApiCalls.readTensorboardBlobData(request, options); @@ -3475,7 +3475,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTensorboard(request, options, callback); @@ -3622,7 +3622,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'tensorboard.name': request.tensorboard!.name || '', + 'tensorboard.name': request.tensorboard!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateTensorboard(request, options, callback); @@ -3762,7 +3762,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTensorboard(request, options, callback); @@ -3902,7 +3902,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTensorboardExperiment( @@ -4046,7 +4046,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTensorboardRun(request, options, callback); @@ -4186,7 +4186,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTensorboardTimeSeries( @@ -4340,7 +4340,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTensorboards(request, options, callback); @@ -4395,7 +4395,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboards']; const callSettings = defaultCallSettings.merge(options); @@ -4459,7 +4459,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboards']; const callSettings = defaultCallSettings.merge(options); @@ -4580,7 +4580,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTensorboardExperiments( @@ -4639,7 +4639,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardExperiments']; const callSettings = defaultCallSettings.merge(options); @@ -4703,7 +4703,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardExperiments']; const callSettings = defaultCallSettings.merge(options); @@ -4824,7 +4824,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTensorboardRuns(request, options, callback); @@ -4879,7 +4879,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardRuns']; const callSettings = defaultCallSettings.merge(options); @@ -4943,7 +4943,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardRuns']; const callSettings = defaultCallSettings.merge(options); @@ -5064,7 +5064,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTensorboardTimeSeries( @@ -5123,7 +5123,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardTimeSeries']; const callSettings = defaultCallSettings.merge(options); @@ -5187,7 +5187,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTensorboardTimeSeries']; const callSettings = defaultCallSettings.merge(options); @@ -5308,7 +5308,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_time_series: request.tensorboardTimeSeries || '', + tensorboard_time_series: request.tensorboardTimeSeries ?? '', }); this.initialize(); return this.innerApiCalls.exportTensorboardTimeSeriesData( @@ -5366,7 +5366,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_time_series: request.tensorboardTimeSeries || '', + tensorboard_time_series: request.tensorboardTimeSeries ?? '', }); const defaultCallSettings = this._defaults['exportTensorboardTimeSeriesData']; @@ -5430,7 +5430,7 @@ export class TensorboardServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - tensorboard_time_series: request.tensorboardTimeSeries || '', + tensorboard_time_series: request.tensorboardTimeSeries ?? '', }); const defaultCallSettings = this._defaults['exportTensorboardTimeSeriesData']; diff --git a/src/v1beta1/vizier_service_client.ts b/src/v1beta1/vizier_service_client.ts index 7962ed47..afeacfbe 100644 --- a/src/v1beta1/vizier_service_client.ts +++ b/src/v1beta1/vizier_service_client.ts @@ -1607,7 +1607,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createStudy(request, options, callback); @@ -1699,7 +1699,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getStudy(request, options, callback); @@ -1791,7 +1791,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteStudy(request, options, callback); @@ -1886,7 +1886,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.lookupStudy(request, options, callback); @@ -1980,7 +1980,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.createTrial(request, options, callback); @@ -2073,7 +2073,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.getTrial(request, options, callback); @@ -2175,7 +2175,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - trial_name: request.trialName || '', + trial_name: request.trialName ?? '', }); this.initialize(); return this.innerApiCalls.addTrialMeasurement(request, options, callback); @@ -2278,7 +2278,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.completeTrial(request, options, callback); @@ -2371,7 +2371,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.deleteTrial(request, options, callback); @@ -2464,7 +2464,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - name: request.name || '', + name: request.name ?? '', }); this.initialize(); return this.innerApiCalls.stopTrial(request, options, callback); @@ -2564,7 +2564,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listOptimalTrials(request, options, callback); @@ -2681,7 +2681,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.suggestTrials(request, options, callback); @@ -2824,7 +2824,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - trial_name: request.trialName || '', + trial_name: request.trialName ?? '', }); this.initialize(); return this.innerApiCalls.checkTrialEarlyStoppingState( @@ -2964,7 +2964,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listStudies(request, options, callback); @@ -3005,7 +3005,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listStudies']; const callSettings = defaultCallSettings.merge(options); @@ -3055,7 +3055,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listStudies']; const callSettings = defaultCallSettings.merge(options); @@ -3162,7 +3162,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); this.initialize(); return this.innerApiCalls.listTrials(request, options, callback); @@ -3203,7 +3203,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTrials']; const callSettings = defaultCallSettings.merge(options); @@ -3253,7 +3253,7 @@ export class VizierServiceClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - parent: request.parent || '', + parent: request.parent ?? '', }); const defaultCallSettings = this._defaults['listTrials']; const callSettings = defaultCallSettings.merge(options); diff --git a/test/gapic_dataset_service_v1.ts b/test/gapic_dataset_service_v1.ts index ea86c9f1..e0419eaf 100644 --- a/test/gapic_dataset_service_v1.ts +++ b/test/gapic_dataset_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,23 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatasetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Dataset() ); client.innerApiCalls.getDataset = stubSimpleCall(expectedResponse); const [response] = await client.getDataset(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataset without error using callback', async () => { @@ -291,15 +303,9 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatasetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Dataset() ); @@ -322,11 +328,14 @@ describe('v1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataset with error', async () => { @@ -338,26 +347,23 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatasetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getDataset = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getDataset(request), expectedError); - assert( - (client.innerApiCalls.getDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataset with closed client', async () => { @@ -369,7 +375,8 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetDatasetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetDatasetRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getDataset(request), expectedError); @@ -386,27 +393,27 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateDatasetRequest() ); - request.dataset = {}; - request.dataset.name = ''; - const expectedHeaderRequestParams = 'dataset.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.dataset ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateDatasetRequest', [ + 'dataset', + 'name', + ]); + request.dataset.name = defaultValue1; + const expectedHeaderRequestParams = `dataset.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Dataset() ); client.innerApiCalls.updateDataset = stubSimpleCall(expectedResponse); const [response] = await client.updateDataset(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDataset without error using callback', async () => { @@ -418,16 +425,13 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateDatasetRequest() ); - request.dataset = {}; - request.dataset.name = ''; - const expectedHeaderRequestParams = 'dataset.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.dataset ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateDatasetRequest', [ + 'dataset', + 'name', + ]); + request.dataset.name = defaultValue1; + const expectedHeaderRequestParams = `dataset.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Dataset() ); @@ -450,11 +454,14 @@ describe('v1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDataset with error', async () => { @@ -466,27 +473,27 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateDatasetRequest() ); - request.dataset = {}; - request.dataset.name = ''; - const expectedHeaderRequestParams = 'dataset.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.dataset ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateDatasetRequest', [ + 'dataset', + 'name', + ]); + request.dataset.name = defaultValue1; + const expectedHeaderRequestParams = `dataset.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateDataset = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateDataset(request), expectedError); - assert( - (client.innerApiCalls.updateDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDataset with closed client', async () => { @@ -498,8 +505,12 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateDatasetRequest() ); - request.dataset = {}; - request.dataset.name = ''; + request.dataset ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateDatasetRequest', [ + 'dataset', + 'name', + ]); + request.dataset.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateDataset(request), expectedError); @@ -516,26 +527,25 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetAnnotationSpecRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAnnotationSpecRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AnnotationSpec() ); client.innerApiCalls.getAnnotationSpec = stubSimpleCall(expectedResponse); const [response] = await client.getAnnotationSpec(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getAnnotationSpec as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAnnotationSpec without error using callback', async () => { @@ -547,15 +557,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetAnnotationSpecRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAnnotationSpecRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AnnotationSpec() ); @@ -578,11 +584,14 @@ describe('v1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getAnnotationSpec as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAnnotationSpec with error', async () => { @@ -594,26 +603,25 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetAnnotationSpecRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAnnotationSpecRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getAnnotationSpec = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getAnnotationSpec(request), expectedError); - assert( - (client.innerApiCalls.getAnnotationSpec as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAnnotationSpec with closed client', async () => { @@ -625,7 +633,10 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetAnnotationSpecRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetAnnotationSpecRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getAnnotationSpec(request), expectedError); @@ -642,15 +653,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateDatasetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatasetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -659,11 +666,14 @@ describe('v1.DatasetServiceClient', () => { const [operation] = await client.createDataset(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataset without error using callback', async () => { @@ -675,15 +685,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateDatasetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatasetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -713,11 +719,14 @@ describe('v1.DatasetServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataset with call error', async () => { @@ -729,26 +738,25 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateDatasetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatasetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDataset = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createDataset(request), expectedError); - assert( - (client.innerApiCalls.createDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataset with LRO error', async () => { @@ -760,15 +768,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateDatasetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatasetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDataset = stubLongRunningCall( undefined, @@ -777,11 +781,14 @@ describe('v1.DatasetServiceClient', () => { ); const [operation] = await client.createDataset(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateDatasetProgress without error', async () => { @@ -836,15 +843,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteDatasetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -853,11 +856,14 @@ describe('v1.DatasetServiceClient', () => { const [operation] = await client.deleteDataset(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataset without error using callback', async () => { @@ -869,15 +875,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteDatasetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -907,11 +909,14 @@ describe('v1.DatasetServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataset with call error', async () => { @@ -923,26 +928,25 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteDatasetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDataset = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteDataset(request), expectedError); - assert( - (client.innerApiCalls.deleteDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataset with LRO error', async () => { @@ -954,15 +958,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteDatasetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDataset = stubLongRunningCall( undefined, @@ -971,11 +971,14 @@ describe('v1.DatasetServiceClient', () => { ); const [operation] = await client.deleteDataset(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteDatasetProgress without error', async () => { @@ -1030,15 +1033,9 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1046,11 +1043,14 @@ describe('v1.DatasetServiceClient', () => { const [operation] = await client.importData(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importData without error using callback', async () => { @@ -1062,15 +1062,9 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1100,11 +1094,14 @@ describe('v1.DatasetServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importData with call error', async () => { @@ -1116,26 +1113,23 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importData = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importData(request), expectedError); - assert( - (client.innerApiCalls.importData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importData with LRO error', async () => { @@ -1147,15 +1141,9 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importData = stubLongRunningCall( undefined, @@ -1164,11 +1152,14 @@ describe('v1.DatasetServiceClient', () => { ); const [operation] = await client.importData(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportDataProgress without error', async () => { @@ -1220,15 +1211,9 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1236,11 +1221,14 @@ describe('v1.DatasetServiceClient', () => { const [operation] = await client.exportData(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportData without error using callback', async () => { @@ -1252,15 +1240,9 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1290,11 +1272,14 @@ describe('v1.DatasetServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportData with call error', async () => { @@ -1306,26 +1291,23 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportData = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.exportData(request), expectedError); - assert( - (client.innerApiCalls.exportData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportData with LRO error', async () => { @@ -1337,15 +1319,9 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportData = stubLongRunningCall( undefined, @@ -1354,11 +1330,14 @@ describe('v1.DatasetServiceClient', () => { ); const [operation] = await client.exportData(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.exportData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkExportDataProgress without error', async () => { @@ -1410,15 +1389,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Dataset()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Dataset()), @@ -1427,11 +1402,14 @@ describe('v1.DatasetServiceClient', () => { client.innerApiCalls.listDatasets = stubSimpleCall(expectedResponse); const [response] = await client.listDatasets(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatasets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatasets without error using callback', async () => { @@ -1443,15 +1421,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Dataset()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Dataset()), @@ -1476,11 +1450,14 @@ describe('v1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatasets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatasets with error', async () => { @@ -1492,26 +1469,25 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDatasets = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listDatasets(request), expectedError); - assert( - (client.innerApiCalls.listDatasets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatasetsStream without error', async () => { @@ -1523,8 +1499,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Dataset()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Dataset()), @@ -1555,11 +1534,12 @@ describe('v1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatasets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDatasets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatasets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1572,8 +1552,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatasets.createStream = stubPageStreamingCall( undefined, @@ -1601,11 +1584,12 @@ describe('v1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatasets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDatasets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatasets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1618,8 +1602,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Dataset()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Dataset()), @@ -1639,11 +1626,12 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDatasets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatasets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1656,8 +1644,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatasets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1674,11 +1665,12 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDatasets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatasets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1693,15 +1685,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.DataItem()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.DataItem()), @@ -1710,11 +1698,14 @@ describe('v1.DatasetServiceClient', () => { client.innerApiCalls.listDataItems = stubSimpleCall(expectedResponse); const [response] = await client.listDataItems(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDataItems as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataItems without error using callback', async () => { @@ -1726,15 +1717,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.DataItem()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.DataItem()), @@ -1759,11 +1746,14 @@ describe('v1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDataItems as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataItems with error', async () => { @@ -1775,26 +1765,25 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDataItems = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listDataItems(request), expectedError); - assert( - (client.innerApiCalls.listDataItems as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataItemsStream without error', async () => { @@ -1806,8 +1795,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.DataItem()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.DataItem()), @@ -1838,11 +1830,12 @@ describe('v1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDataItems, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDataItems.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataItems.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1855,8 +1848,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDataItems.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1882,11 +1878,12 @@ describe('v1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDataItems, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDataItems.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataItems.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1899,8 +1896,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.DataItem()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.DataItem()), @@ -1920,11 +1920,12 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDataItems.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataItems.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1937,8 +1938,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDataItems.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1955,11 +1959,12 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDataItems.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataItems.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1974,15 +1979,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.SavedQuery() @@ -1997,11 +1998,14 @@ describe('v1.DatasetServiceClient', () => { client.innerApiCalls.listSavedQueries = stubSimpleCall(expectedResponse); const [response] = await client.listSavedQueries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSavedQueries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSavedQueries without error using callback', async () => { @@ -2013,15 +2017,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.SavedQuery() @@ -2052,11 +2052,14 @@ describe('v1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSavedQueries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSavedQueries with error', async () => { @@ -2068,26 +2071,25 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listSavedQueries = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listSavedQueries(request), expectedError); - assert( - (client.innerApiCalls.listSavedQueries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSavedQueriesStream without error', async () => { @@ -2099,8 +2101,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.SavedQuery() @@ -2137,11 +2142,12 @@ describe('v1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSavedQueries, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSavedQueries.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSavedQueries.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2154,8 +2160,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSavedQueries.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2181,11 +2190,12 @@ describe('v1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSavedQueries, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSavedQueries.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSavedQueries.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2198,8 +2208,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.SavedQuery() @@ -2225,11 +2238,12 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSavedQueries.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSavedQueries.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2242,8 +2256,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSavedQueries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2260,11 +2277,12 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSavedQueries.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSavedQueries.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2279,15 +2297,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Annotation() @@ -2302,11 +2316,14 @@ describe('v1.DatasetServiceClient', () => { client.innerApiCalls.listAnnotations = stubSimpleCall(expectedResponse); const [response] = await client.listAnnotations(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listAnnotations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAnnotations without error using callback', async () => { @@ -2318,15 +2335,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Annotation() @@ -2357,11 +2370,14 @@ describe('v1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listAnnotations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAnnotations with error', async () => { @@ -2373,26 +2389,25 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listAnnotations = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listAnnotations(request), expectedError); - assert( - (client.innerApiCalls.listAnnotations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAnnotationsStream without error', async () => { @@ -2404,8 +2419,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Annotation() @@ -2442,11 +2460,12 @@ describe('v1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listAnnotations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listAnnotations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAnnotations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2459,8 +2478,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listAnnotations.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2486,11 +2508,12 @@ describe('v1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listAnnotations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listAnnotations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAnnotations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2503,8 +2526,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Annotation() @@ -2530,11 +2556,12 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listAnnotations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAnnotations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2547,8 +2574,11 @@ describe('v1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listAnnotations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2565,11 +2595,12 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listAnnotations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAnnotations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3044,12 +3075,15 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -3080,12 +3114,15 @@ describe('v1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_dataset_service_v1beta1.ts b/test/gapic_dataset_service_v1beta1.ts index e589b4b9..1e9a83d6 100644 --- a/test/gapic_dataset_service_v1beta1.ts +++ b/test/gapic_dataset_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,23 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatasetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Dataset() ); client.innerApiCalls.getDataset = stubSimpleCall(expectedResponse); const [response] = await client.getDataset(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataset without error using callback', async () => { @@ -291,15 +303,9 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatasetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Dataset() ); @@ -322,11 +328,14 @@ describe('v1beta1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataset with error', async () => { @@ -338,26 +347,23 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDatasetRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getDataset = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getDataset(request), expectedError); - assert( - (client.innerApiCalls.getDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataset with closed client', async () => { @@ -369,7 +375,8 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDatasetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetDatasetRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getDataset(request), expectedError); @@ -386,27 +393,27 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateDatasetRequest() ); - request.dataset = {}; - request.dataset.name = ''; - const expectedHeaderRequestParams = 'dataset.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.dataset ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateDatasetRequest', [ + 'dataset', + 'name', + ]); + request.dataset.name = defaultValue1; + const expectedHeaderRequestParams = `dataset.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Dataset() ); client.innerApiCalls.updateDataset = stubSimpleCall(expectedResponse); const [response] = await client.updateDataset(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDataset without error using callback', async () => { @@ -418,16 +425,13 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateDatasetRequest() ); - request.dataset = {}; - request.dataset.name = ''; - const expectedHeaderRequestParams = 'dataset.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.dataset ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateDatasetRequest', [ + 'dataset', + 'name', + ]); + request.dataset.name = defaultValue1; + const expectedHeaderRequestParams = `dataset.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Dataset() ); @@ -450,11 +454,14 @@ describe('v1beta1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDataset with error', async () => { @@ -466,27 +473,27 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateDatasetRequest() ); - request.dataset = {}; - request.dataset.name = ''; - const expectedHeaderRequestParams = 'dataset.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.dataset ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateDatasetRequest', [ + 'dataset', + 'name', + ]); + request.dataset.name = defaultValue1; + const expectedHeaderRequestParams = `dataset.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateDataset = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateDataset(request), expectedError); - assert( - (client.innerApiCalls.updateDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateDataset with closed client', async () => { @@ -498,8 +505,12 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateDatasetRequest() ); - request.dataset = {}; - request.dataset.name = ''; + request.dataset ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateDatasetRequest', [ + 'dataset', + 'name', + ]); + request.dataset.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateDataset(request), expectedError); @@ -516,26 +527,25 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetAnnotationSpecRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAnnotationSpecRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AnnotationSpec() ); client.innerApiCalls.getAnnotationSpec = stubSimpleCall(expectedResponse); const [response] = await client.getAnnotationSpec(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getAnnotationSpec as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAnnotationSpec without error using callback', async () => { @@ -547,15 +557,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetAnnotationSpecRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAnnotationSpecRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AnnotationSpec() ); @@ -578,11 +584,14 @@ describe('v1beta1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getAnnotationSpec as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAnnotationSpec with error', async () => { @@ -594,26 +603,25 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetAnnotationSpecRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetAnnotationSpecRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getAnnotationSpec = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getAnnotationSpec(request), expectedError); - assert( - (client.innerApiCalls.getAnnotationSpec as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAnnotationSpec as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getAnnotationSpec with closed client', async () => { @@ -625,7 +633,10 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetAnnotationSpecRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetAnnotationSpecRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getAnnotationSpec(request), expectedError); @@ -642,15 +653,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDatasetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatasetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -659,11 +666,14 @@ describe('v1beta1.DatasetServiceClient', () => { const [operation] = await client.createDataset(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataset without error using callback', async () => { @@ -675,15 +685,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDatasetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatasetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -713,11 +719,14 @@ describe('v1beta1.DatasetServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataset with call error', async () => { @@ -729,26 +738,25 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDatasetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatasetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDataset = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createDataset(request), expectedError); - assert( - (client.innerApiCalls.createDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataset with LRO error', async () => { @@ -760,15 +768,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDatasetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateDatasetRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDataset = stubLongRunningCall( undefined, @@ -777,11 +781,14 @@ describe('v1beta1.DatasetServiceClient', () => { ); const [operation] = await client.createDataset(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateDatasetProgress without error', async () => { @@ -836,15 +843,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteDatasetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -853,11 +856,14 @@ describe('v1beta1.DatasetServiceClient', () => { const [operation] = await client.deleteDataset(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataset without error using callback', async () => { @@ -869,15 +875,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteDatasetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -907,11 +909,14 @@ describe('v1beta1.DatasetServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataset with call error', async () => { @@ -923,26 +928,25 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteDatasetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDataset = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteDataset(request), expectedError); - assert( - (client.innerApiCalls.deleteDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataset with LRO error', async () => { @@ -954,15 +958,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDatasetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteDatasetRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDataset = stubLongRunningCall( undefined, @@ -971,11 +971,14 @@ describe('v1beta1.DatasetServiceClient', () => { ); const [operation] = await client.deleteDataset(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteDatasetProgress without error', async () => { @@ -1030,15 +1033,9 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1046,11 +1043,14 @@ describe('v1beta1.DatasetServiceClient', () => { const [operation] = await client.importData(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importData without error using callback', async () => { @@ -1062,15 +1062,9 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1100,11 +1094,14 @@ describe('v1beta1.DatasetServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importData with call error', async () => { @@ -1116,26 +1113,23 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importData = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importData(request), expectedError); - assert( - (client.innerApiCalls.importData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importData with LRO error', async () => { @@ -1147,15 +1141,9 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importData = stubLongRunningCall( undefined, @@ -1164,11 +1152,14 @@ describe('v1beta1.DatasetServiceClient', () => { ); const [operation] = await client.importData(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportDataProgress without error', async () => { @@ -1220,15 +1211,9 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1236,11 +1221,14 @@ describe('v1beta1.DatasetServiceClient', () => { const [operation] = await client.exportData(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportData without error using callback', async () => { @@ -1252,15 +1240,9 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1290,11 +1272,14 @@ describe('v1beta1.DatasetServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportData with call error', async () => { @@ -1306,26 +1291,23 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportData = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.exportData(request), expectedError); - assert( - (client.innerApiCalls.exportData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportData with LRO error', async () => { @@ -1337,15 +1319,9 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportDataRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportDataRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportData = stubLongRunningCall( undefined, @@ -1354,11 +1330,14 @@ describe('v1beta1.DatasetServiceClient', () => { ); const [operation] = await client.exportData(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.exportData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkExportDataProgress without error', async () => { @@ -1410,15 +1389,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Dataset() @@ -1433,11 +1408,14 @@ describe('v1beta1.DatasetServiceClient', () => { client.innerApiCalls.listDatasets = stubSimpleCall(expectedResponse); const [response] = await client.listDatasets(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatasets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatasets without error using callback', async () => { @@ -1449,15 +1427,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Dataset() @@ -1488,11 +1462,14 @@ describe('v1beta1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDatasets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatasets with error', async () => { @@ -1504,26 +1481,25 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDatasets = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listDatasets(request), expectedError); - assert( - (client.innerApiCalls.listDatasets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDatasetsStream without error', async () => { @@ -1535,8 +1511,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Dataset() @@ -1573,11 +1552,12 @@ describe('v1beta1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatasets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDatasets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatasets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1590,8 +1570,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatasets.createStream = stubPageStreamingCall( undefined, @@ -1619,11 +1602,12 @@ describe('v1beta1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDatasets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDatasets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatasets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1636,8 +1620,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Dataset() @@ -1663,11 +1650,12 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDatasets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatasets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1680,8 +1668,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDatasetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDatasetsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDatasets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1698,11 +1689,12 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDatasets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDatasets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1717,15 +1709,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataItem() @@ -1740,11 +1728,14 @@ describe('v1beta1.DatasetServiceClient', () => { client.innerApiCalls.listDataItems = stubSimpleCall(expectedResponse); const [response] = await client.listDataItems(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDataItems as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataItems without error using callback', async () => { @@ -1756,15 +1747,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataItem() @@ -1795,11 +1782,14 @@ describe('v1beta1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDataItems as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataItems with error', async () => { @@ -1811,26 +1801,25 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDataItems = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listDataItems(request), expectedError); - assert( - (client.innerApiCalls.listDataItems as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataItems as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataItemsStream without error', async () => { @@ -1842,8 +1831,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataItem() @@ -1880,11 +1872,12 @@ describe('v1beta1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDataItems, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDataItems.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataItems.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1897,8 +1890,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDataItems.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1924,11 +1920,12 @@ describe('v1beta1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDataItems, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDataItems.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataItems.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1941,8 +1938,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataItem() @@ -1968,11 +1968,12 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDataItems.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataItems.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1985,8 +1986,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataItemsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataItemsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDataItems.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2004,11 +2008,12 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDataItems.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataItems.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2023,15 +2028,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SavedQuery() @@ -2046,11 +2047,14 @@ describe('v1beta1.DatasetServiceClient', () => { client.innerApiCalls.listSavedQueries = stubSimpleCall(expectedResponse); const [response] = await client.listSavedQueries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSavedQueries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSavedQueries without error using callback', async () => { @@ -2062,15 +2066,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SavedQuery() @@ -2101,11 +2101,14 @@ describe('v1beta1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSavedQueries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSavedQueries with error', async () => { @@ -2117,26 +2120,25 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listSavedQueries = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listSavedQueries(request), expectedError); - assert( - (client.innerApiCalls.listSavedQueries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSavedQueries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSavedQueriesStream without error', async () => { @@ -2148,8 +2150,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SavedQuery() @@ -2187,11 +2192,12 @@ describe('v1beta1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSavedQueries, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSavedQueries.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSavedQueries.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2204,8 +2210,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSavedQueries.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2232,11 +2241,12 @@ describe('v1beta1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSavedQueries, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSavedQueries.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSavedQueries.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2249,8 +2259,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SavedQuery() @@ -2277,11 +2290,12 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSavedQueries.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSavedQueries.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2294,8 +2308,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSavedQueriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSavedQueriesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSavedQueries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2313,11 +2330,12 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSavedQueries.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSavedQueries.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2332,15 +2350,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Annotation() @@ -2355,11 +2369,14 @@ describe('v1beta1.DatasetServiceClient', () => { client.innerApiCalls.listAnnotations = stubSimpleCall(expectedResponse); const [response] = await client.listAnnotations(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listAnnotations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAnnotations without error using callback', async () => { @@ -2371,15 +2388,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Annotation() @@ -2410,11 +2423,14 @@ describe('v1beta1.DatasetServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listAnnotations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAnnotations with error', async () => { @@ -2426,26 +2442,25 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listAnnotations = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listAnnotations(request), expectedError); - assert( - (client.innerApiCalls.listAnnotations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAnnotations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listAnnotationsStream without error', async () => { @@ -2457,8 +2472,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Annotation() @@ -2496,11 +2514,12 @@ describe('v1beta1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listAnnotations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listAnnotations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAnnotations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2513,8 +2532,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listAnnotations.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2541,11 +2563,12 @@ describe('v1beta1.DatasetServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listAnnotations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listAnnotations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAnnotations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2558,8 +2581,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Annotation() @@ -2586,11 +2612,12 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listAnnotations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAnnotations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2603,8 +2630,11 @@ describe('v1beta1.DatasetServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListAnnotationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListAnnotationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listAnnotations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2622,11 +2652,12 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listAnnotations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listAnnotations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3101,12 +3132,15 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -3137,12 +3171,15 @@ describe('v1beta1.DatasetServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_deployment_resource_pool_service_v1beta1.ts b/test/gapic_deployment_resource_pool_service_v1beta1.ts index 37cde198..70497bd1 100644 --- a/test/gapic_deployment_resource_pool_service_v1beta1.ts +++ b/test/gapic_deployment_resource_pool_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -286,15 +301,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDeploymentResourcePoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetDeploymentResourcePoolRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeploymentResourcePool() ); @@ -302,11 +314,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getDeploymentResourcePool(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDeploymentResourcePool without error using callback', async () => { @@ -321,15 +336,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDeploymentResourcePoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetDeploymentResourcePoolRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeploymentResourcePool() ); @@ -352,11 +364,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDeploymentResourcePool with error', async () => { @@ -371,15 +386,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDeploymentResourcePoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetDeploymentResourcePoolRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getDeploymentResourcePool = stubSimpleCall( undefined, @@ -389,11 +401,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { client.getDeploymentResourcePool(request), expectedError ); - assert( - (client.innerApiCalls.getDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDeploymentResourcePool with closed client', async () => { @@ -408,7 +423,11 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDeploymentResourcePoolRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetDeploymentResourcePoolRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -431,15 +450,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDeploymentResourcePoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDeploymentResourcePoolRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -448,11 +464,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const [operation] = await client.createDeploymentResourcePool(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDeploymentResourcePool without error using callback', async () => { @@ -467,15 +486,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDeploymentResourcePoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDeploymentResourcePoolRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -505,11 +521,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDeploymentResourcePool with call error', async () => { @@ -524,15 +543,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDeploymentResourcePoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDeploymentResourcePoolRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDeploymentResourcePool = stubLongRunningCall( undefined, @@ -542,11 +558,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { client.createDeploymentResourcePool(request), expectedError ); - assert( - (client.innerApiCalls.createDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDeploymentResourcePool with LRO error', async () => { @@ -561,15 +580,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDeploymentResourcePoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDeploymentResourcePoolRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDeploymentResourcePool = stubLongRunningCall( undefined, @@ -578,11 +594,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { ); const [operation] = await client.createDeploymentResourcePool(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateDeploymentResourcePoolProgress without error', async () => { @@ -647,15 +666,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDeploymentResourcePoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDeploymentResourcePoolRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -664,11 +680,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const [operation] = await client.deleteDeploymentResourcePool(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDeploymentResourcePool without error using callback', async () => { @@ -683,15 +702,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDeploymentResourcePoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDeploymentResourcePoolRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -721,11 +737,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDeploymentResourcePool with call error', async () => { @@ -740,15 +759,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDeploymentResourcePoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDeploymentResourcePoolRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDeploymentResourcePool = stubLongRunningCall( undefined, @@ -758,11 +774,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { client.deleteDeploymentResourcePool(request), expectedError ); - assert( - (client.innerApiCalls.deleteDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDeploymentResourcePool with LRO error', async () => { @@ -777,15 +796,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDeploymentResourcePoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDeploymentResourcePoolRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDeploymentResourcePool = stubLongRunningCall( undefined, @@ -794,11 +810,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { ); const [operation] = await client.deleteDeploymentResourcePool(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteDeploymentResourcePool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDeploymentResourcePool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeploymentResourcePool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteDeploymentResourcePoolProgress without error', async () => { @@ -863,15 +882,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDeploymentResourcePoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListDeploymentResourcePoolsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeploymentResourcePool() @@ -887,11 +903,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listDeploymentResourcePools(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDeploymentResourcePools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDeploymentResourcePools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeploymentResourcePools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDeploymentResourcePools without error using callback', async () => { @@ -906,15 +925,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDeploymentResourcePoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListDeploymentResourcePoolsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeploymentResourcePool() @@ -947,11 +963,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDeploymentResourcePools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDeploymentResourcePools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeploymentResourcePools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDeploymentResourcePools with error', async () => { @@ -966,15 +985,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDeploymentResourcePoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListDeploymentResourcePoolsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDeploymentResourcePools = stubSimpleCall( undefined, @@ -984,11 +1000,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { client.listDeploymentResourcePools(request), expectedError ); - assert( - (client.innerApiCalls.listDeploymentResourcePools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDeploymentResourcePools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeploymentResourcePools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDeploymentResourcePoolsStream without error', async () => { @@ -1003,8 +1022,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDeploymentResourcePoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListDeploymentResourcePoolsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeploymentResourcePool() @@ -1047,12 +1070,15 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDeploymentResourcePools, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listDeploymentResourcePools .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1068,8 +1094,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDeploymentResourcePoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListDeploymentResourcePoolsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDeploymentResourcePools.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1101,12 +1131,15 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDeploymentResourcePools, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listDeploymentResourcePools .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1122,8 +1155,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDeploymentResourcePoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListDeploymentResourcePoolsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeploymentResourcePool() @@ -1151,12 +1188,15 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listDeploymentResourcePools .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1172,8 +1212,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDeploymentResourcePoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListDeploymentResourcePoolsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDeploymentResourcePools.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1192,12 +1236,15 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listDeploymentResourcePools .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1215,15 +1262,11 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryDeployedModelsRequest() ); - request.deploymentResourcePool = ''; - const expectedHeaderRequestParams = 'deployment_resource_pool='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('QueryDeployedModelsRequest', [ + 'deploymentResourcePool', + ]); + request.deploymentResourcePool = defaultValue1; + const expectedHeaderRequestParams = `deployment_resource_pool=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployedModel() @@ -1239,11 +1282,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.queryDeployedModels(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryDeployedModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryDeployedModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryDeployedModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryDeployedModels without error using callback', async () => { @@ -1258,15 +1304,11 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryDeployedModelsRequest() ); - request.deploymentResourcePool = ''; - const expectedHeaderRequestParams = 'deployment_resource_pool='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('QueryDeployedModelsRequest', [ + 'deploymentResourcePool', + ]); + request.deploymentResourcePool = defaultValue1; + const expectedHeaderRequestParams = `deployment_resource_pool=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployedModel() @@ -1299,11 +1341,14 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryDeployedModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.queryDeployedModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryDeployedModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryDeployedModels with error', async () => { @@ -1318,26 +1363,25 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryDeployedModelsRequest() ); - request.deploymentResourcePool = ''; - const expectedHeaderRequestParams = 'deployment_resource_pool='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('QueryDeployedModelsRequest', [ + 'deploymentResourcePool', + ]); + request.deploymentResourcePool = defaultValue1; + const expectedHeaderRequestParams = `deployment_resource_pool=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.queryDeployedModels = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.queryDeployedModels(request), expectedError); - assert( - (client.innerApiCalls.queryDeployedModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryDeployedModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryDeployedModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryDeployedModelsStream without error', async () => { @@ -1352,8 +1396,11 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryDeployedModelsRequest() ); - request.deploymentResourcePool = ''; - const expectedHeaderRequestParams = 'deployment_resource_pool='; + const defaultValue1 = getTypeDefaultValue('QueryDeployedModelsRequest', [ + 'deploymentResourcePool', + ]); + request.deploymentResourcePool = defaultValue1; + const expectedHeaderRequestParams = `deployment_resource_pool=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployedModel() @@ -1391,11 +1438,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.queryDeployedModels, request) ); - assert.strictEqual( - ( - client.descriptors.page.queryDeployedModels.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.queryDeployedModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1411,8 +1459,11 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryDeployedModelsRequest() ); - request.deploymentResourcePool = ''; - const expectedHeaderRequestParams = 'deployment_resource_pool='; + const defaultValue1 = getTypeDefaultValue('QueryDeployedModelsRequest', [ + 'deploymentResourcePool', + ]); + request.deploymentResourcePool = defaultValue1; + const expectedHeaderRequestParams = `deployment_resource_pool=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.queryDeployedModels.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1439,11 +1490,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.queryDeployedModels, request) ); - assert.strictEqual( - ( - client.descriptors.page.queryDeployedModels.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.queryDeployedModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1459,8 +1511,11 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryDeployedModelsRequest() ); - request.deploymentResourcePool = ''; - const expectedHeaderRequestParams = 'deployment_resource_pool='; + const defaultValue1 = getTypeDefaultValue('QueryDeployedModelsRequest', [ + 'deploymentResourcePool', + ]); + request.deploymentResourcePool = defaultValue1; + const expectedHeaderRequestParams = `deployment_resource_pool=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployedModel() @@ -1487,11 +1542,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.queryDeployedModels.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.queryDeployedModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1507,8 +1563,11 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryDeployedModelsRequest() ); - request.deploymentResourcePool = ''; - const expectedHeaderRequestParams = 'deployment_resource_pool='; + const defaultValue1 = getTypeDefaultValue('QueryDeployedModelsRequest', [ + 'deploymentResourcePool', + ]); + request.deploymentResourcePool = defaultValue1; + const expectedHeaderRequestParams = `deployment_resource_pool=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.queryDeployedModels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1526,11 +1585,12 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.queryDeployedModels.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.queryDeployedModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2044,12 +2104,15 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -2083,12 +2146,15 @@ describe('v1beta1.DeploymentResourcePoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_endpoint_service_v1.ts b/test/gapic_endpoint_service_v1.ts index 83714891..b53617ab 100644 --- a/test/gapic_endpoint_service_v1.ts +++ b/test/gapic_endpoint_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,23 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEndpointRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Endpoint() ); client.innerApiCalls.getEndpoint = stubSimpleCall(expectedResponse); const [response] = await client.getEndpoint(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEndpoint without error using callback', async () => { @@ -291,15 +303,9 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEndpointRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Endpoint() ); @@ -322,11 +328,14 @@ describe('v1.EndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEndpoint with error', async () => { @@ -338,26 +347,23 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEndpointRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getEndpoint = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getEndpoint(request), expectedError); - assert( - (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEndpoint with closed client', async () => { @@ -369,7 +375,8 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetEndpointRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetEndpointRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getEndpoint(request), expectedError); @@ -386,27 +393,27 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateEndpointRequest() ); - request.endpoint = {}; - request.endpoint.name = ''; - const expectedHeaderRequestParams = 'endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEndpointRequest', [ + 'endpoint', + 'name', + ]); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Endpoint() ); client.innerApiCalls.updateEndpoint = stubSimpleCall(expectedResponse); const [response] = await client.updateEndpoint(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEndpoint without error using callback', async () => { @@ -418,16 +425,13 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateEndpointRequest() ); - request.endpoint = {}; - request.endpoint.name = ''; - const expectedHeaderRequestParams = 'endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEndpointRequest', [ + 'endpoint', + 'name', + ]); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Endpoint() ); @@ -450,11 +454,14 @@ describe('v1.EndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEndpoint with error', async () => { @@ -466,27 +473,27 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateEndpointRequest() ); - request.endpoint = {}; - request.endpoint.name = ''; - const expectedHeaderRequestParams = 'endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEndpointRequest', [ + 'endpoint', + 'name', + ]); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateEndpoint = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateEndpoint(request), expectedError); - assert( - (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEndpoint with closed client', async () => { @@ -498,8 +505,12 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateEndpointRequest() ); - request.endpoint = {}; - request.endpoint.name = ''; + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEndpointRequest', [ + 'endpoint', + 'name', + ]); + request.endpoint.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateEndpoint(request), expectedError); @@ -516,15 +527,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -533,11 +540,14 @@ describe('v1.EndpointServiceClient', () => { const [operation] = await client.createEndpoint(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEndpoint without error using callback', async () => { @@ -549,15 +559,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -587,11 +593,14 @@ describe('v1.EndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEndpoint with call error', async () => { @@ -603,26 +612,25 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEndpoint = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createEndpoint(request), expectedError); - assert( - (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEndpoint with LRO error', async () => { @@ -634,15 +642,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEndpoint = stubLongRunningCall( undefined, @@ -651,11 +655,14 @@ describe('v1.EndpointServiceClient', () => { ); const [operation] = await client.createEndpoint(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateEndpointProgress without error', async () => { @@ -710,15 +717,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -727,11 +730,14 @@ describe('v1.EndpointServiceClient', () => { const [operation] = await client.deleteEndpoint(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEndpoint without error using callback', async () => { @@ -743,15 +749,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -781,11 +783,14 @@ describe('v1.EndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEndpoint with call error', async () => { @@ -797,26 +802,25 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEndpoint = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteEndpoint(request), expectedError); - assert( - (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEndpoint with LRO error', async () => { @@ -828,15 +832,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEndpoint = stubLongRunningCall( undefined, @@ -845,11 +845,14 @@ describe('v1.EndpointServiceClient', () => { ); const [operation] = await client.deleteEndpoint(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteEndpointProgress without error', async () => { @@ -904,15 +907,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -920,11 +919,14 @@ describe('v1.EndpointServiceClient', () => { const [operation] = await client.deployModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployModel without error using callback', async () => { @@ -936,15 +938,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -974,11 +972,14 @@ describe('v1.EndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployModel with call error', async () => { @@ -990,26 +991,25 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deployModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deployModel(request), expectedError); - assert( - (client.innerApiCalls.deployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployModel with LRO error', async () => { @@ -1021,15 +1021,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deployModel = stubLongRunningCall( undefined, @@ -1038,11 +1034,14 @@ describe('v1.EndpointServiceClient', () => { ); const [operation] = await client.deployModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeployModelProgress without error', async () => { @@ -1094,15 +1093,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UndeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1111,11 +1106,14 @@ describe('v1.EndpointServiceClient', () => { const [operation] = await client.undeployModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.undeployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployModel without error using callback', async () => { @@ -1127,15 +1125,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UndeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1165,11 +1159,14 @@ describe('v1.EndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.undeployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployModel with call error', async () => { @@ -1181,26 +1178,25 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UndeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.undeployModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.undeployModel(request), expectedError); - assert( - (client.innerApiCalls.undeployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployModel with LRO error', async () => { @@ -1212,15 +1208,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UndeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.undeployModel = stubLongRunningCall( undefined, @@ -1229,11 +1221,14 @@ describe('v1.EndpointServiceClient', () => { ); const [operation] = await client.undeployModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.undeployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUndeployModelProgress without error', async () => { @@ -1288,15 +1283,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Endpoint()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Endpoint()), @@ -1305,11 +1296,14 @@ describe('v1.EndpointServiceClient', () => { client.innerApiCalls.listEndpoints = stubSimpleCall(expectedResponse); const [response] = await client.listEndpoints(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEndpoints without error using callback', async () => { @@ -1321,15 +1315,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Endpoint()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Endpoint()), @@ -1354,11 +1344,14 @@ describe('v1.EndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEndpoints with error', async () => { @@ -1370,26 +1363,25 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listEndpoints = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listEndpoints(request), expectedError); - assert( - (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEndpointsStream without error', async () => { @@ -1401,8 +1393,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Endpoint()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Endpoint()), @@ -1433,11 +1428,12 @@ describe('v1.EndpointServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEndpoints, request) ); - assert.strictEqual( - ( - client.descriptors.page.listEndpoints.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1450,8 +1446,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEndpoints.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1477,11 +1476,12 @@ describe('v1.EndpointServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEndpoints, request) ); - assert.strictEqual( - ( - client.descriptors.page.listEndpoints.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1494,8 +1494,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Endpoint()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Endpoint()), @@ -1515,11 +1518,12 @@ describe('v1.EndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listEndpoints.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1532,8 +1536,11 @@ describe('v1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEndpoints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1550,11 +1557,12 @@ describe('v1.EndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listEndpoints.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2029,12 +2037,15 @@ describe('v1.EndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -2065,12 +2076,15 @@ describe('v1.EndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_endpoint_service_v1beta1.ts b/test/gapic_endpoint_service_v1beta1.ts index e93606d2..35494492 100644 --- a/test/gapic_endpoint_service_v1beta1.ts +++ b/test/gapic_endpoint_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,23 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEndpointRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Endpoint() ); client.innerApiCalls.getEndpoint = stubSimpleCall(expectedResponse); const [response] = await client.getEndpoint(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEndpoint without error using callback', async () => { @@ -291,15 +303,9 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEndpointRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Endpoint() ); @@ -322,11 +328,14 @@ describe('v1beta1.EndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEndpoint with error', async () => { @@ -338,26 +347,23 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEndpointRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getEndpoint = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getEndpoint(request), expectedError); - assert( - (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEndpoint with closed client', async () => { @@ -369,7 +375,8 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetEndpointRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetEndpointRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getEndpoint(request), expectedError); @@ -386,27 +393,27 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateEndpointRequest() ); - request.endpoint = {}; - request.endpoint.name = ''; - const expectedHeaderRequestParams = 'endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEndpointRequest', [ + 'endpoint', + 'name', + ]); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Endpoint() ); client.innerApiCalls.updateEndpoint = stubSimpleCall(expectedResponse); const [response] = await client.updateEndpoint(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEndpoint without error using callback', async () => { @@ -418,16 +425,13 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateEndpointRequest() ); - request.endpoint = {}; - request.endpoint.name = ''; - const expectedHeaderRequestParams = 'endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEndpointRequest', [ + 'endpoint', + 'name', + ]); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Endpoint() ); @@ -450,11 +454,14 @@ describe('v1beta1.EndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEndpoint with error', async () => { @@ -466,27 +473,27 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateEndpointRequest() ); - request.endpoint = {}; - request.endpoint.name = ''; - const expectedHeaderRequestParams = 'endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEndpointRequest', [ + 'endpoint', + 'name', + ]); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateEndpoint = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateEndpoint(request), expectedError); - assert( - (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEndpoint with closed client', async () => { @@ -498,8 +505,12 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateEndpointRequest() ); - request.endpoint = {}; - request.endpoint.name = ''; + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEndpointRequest', [ + 'endpoint', + 'name', + ]); + request.endpoint.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateEndpoint(request), expectedError); @@ -516,15 +527,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -533,11 +540,14 @@ describe('v1beta1.EndpointServiceClient', () => { const [operation] = await client.createEndpoint(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEndpoint without error using callback', async () => { @@ -549,15 +559,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -587,11 +593,14 @@ describe('v1beta1.EndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEndpoint with call error', async () => { @@ -603,26 +612,25 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEndpoint = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createEndpoint(request), expectedError); - assert( - (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEndpoint with LRO error', async () => { @@ -634,15 +642,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEndpoint = stubLongRunningCall( undefined, @@ -651,11 +655,14 @@ describe('v1beta1.EndpointServiceClient', () => { ); const [operation] = await client.createEndpoint(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateEndpointProgress without error', async () => { @@ -710,15 +717,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -727,11 +730,14 @@ describe('v1beta1.EndpointServiceClient', () => { const [operation] = await client.deleteEndpoint(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEndpoint without error using callback', async () => { @@ -743,15 +749,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -781,11 +783,14 @@ describe('v1beta1.EndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEndpoint with call error', async () => { @@ -797,26 +802,25 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEndpoint = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteEndpoint(request), expectedError); - assert( - (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEndpoint with LRO error', async () => { @@ -828,15 +832,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEndpoint = stubLongRunningCall( undefined, @@ -845,11 +845,14 @@ describe('v1beta1.EndpointServiceClient', () => { ); const [operation] = await client.deleteEndpoint(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteEndpointProgress without error', async () => { @@ -904,15 +907,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -920,11 +919,14 @@ describe('v1beta1.EndpointServiceClient', () => { const [operation] = await client.deployModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployModel without error using callback', async () => { @@ -936,15 +938,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -974,11 +972,14 @@ describe('v1beta1.EndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployModel with call error', async () => { @@ -990,26 +991,25 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deployModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deployModel(request), expectedError); - assert( - (client.innerApiCalls.deployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployModel with LRO error', async () => { @@ -1021,15 +1021,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deployModel = stubLongRunningCall( undefined, @@ -1038,11 +1034,14 @@ describe('v1beta1.EndpointServiceClient', () => { ); const [operation] = await client.deployModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeployModelProgress without error', async () => { @@ -1094,15 +1093,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UndeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1111,11 +1106,14 @@ describe('v1beta1.EndpointServiceClient', () => { const [operation] = await client.undeployModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.undeployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployModel without error using callback', async () => { @@ -1127,15 +1125,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UndeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1165,11 +1159,14 @@ describe('v1beta1.EndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.undeployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployModel with call error', async () => { @@ -1181,26 +1178,25 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UndeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.undeployModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.undeployModel(request), expectedError); - assert( - (client.innerApiCalls.undeployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployModel with LRO error', async () => { @@ -1212,15 +1208,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UndeployModelRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployModelRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.undeployModel = stubLongRunningCall( undefined, @@ -1229,11 +1221,14 @@ describe('v1beta1.EndpointServiceClient', () => { ); const [operation] = await client.undeployModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.undeployModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUndeployModelProgress without error', async () => { @@ -1288,15 +1283,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Endpoint() @@ -1311,11 +1302,14 @@ describe('v1beta1.EndpointServiceClient', () => { client.innerApiCalls.listEndpoints = stubSimpleCall(expectedResponse); const [response] = await client.listEndpoints(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEndpoints without error using callback', async () => { @@ -1327,15 +1321,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Endpoint() @@ -1366,11 +1356,14 @@ describe('v1beta1.EndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEndpoints with error', async () => { @@ -1382,26 +1375,25 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listEndpoints = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listEndpoints(request), expectedError); - assert( - (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEndpointsStream without error', async () => { @@ -1413,8 +1405,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Endpoint() @@ -1451,11 +1446,12 @@ describe('v1beta1.EndpointServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEndpoints, request) ); - assert.strictEqual( - ( - client.descriptors.page.listEndpoints.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1468,8 +1464,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEndpoints.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1495,11 +1494,12 @@ describe('v1beta1.EndpointServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEndpoints, request) ); - assert.strictEqual( - ( - client.descriptors.page.listEndpoints.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1512,8 +1512,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Endpoint() @@ -1539,11 +1542,12 @@ describe('v1beta1.EndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listEndpoints.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1556,8 +1560,11 @@ describe('v1beta1.EndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEndpoints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1575,11 +1582,12 @@ describe('v1beta1.EndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listEndpoints.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2054,12 +2062,15 @@ describe('v1beta1.EndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -2090,12 +2101,15 @@ describe('v1beta1.EndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_featurestore_online_serving_service_v1.ts b/test/gapic_featurestore_online_serving_service_v1.ts index db6bd0a8..2cb68898 100644 --- a/test/gapic_featurestore_online_serving_service_v1.ts +++ b/test/gapic_featurestore_online_serving_service_v1.ts @@ -32,6 +32,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -242,26 +257,25 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadFeatureValuesResponse() ); client.innerApiCalls.readFeatureValues = stubSimpleCall(expectedResponse); const [response] = await client.readFeatureValues(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readFeatureValues without error using callback', async () => { @@ -276,15 +290,11 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadFeatureValuesResponse() ); @@ -307,11 +317,14 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readFeatureValues with error', async () => { @@ -326,26 +339,25 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.readFeatureValues = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.readFeatureValues(request), expectedError); - assert( - (client.innerApiCalls.readFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readFeatureValues with closed client', async () => { @@ -360,7 +372,10 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadFeatureValuesRequest() ); - request.entityType = ''; + const defaultValue1 = getTypeDefaultValue('ReadFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.readFeatureValues(request), expectedError); @@ -380,15 +395,12 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.StreamingReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StreamingReadFeatureValuesRequest', + ['entityType'] + ); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadFeatureValuesResponse() ); @@ -410,11 +422,14 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.streamingReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.streamingReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.streamingReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes streamingReadFeatureValues with error', async () => { @@ -429,15 +444,12 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.StreamingReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StreamingReadFeatureValuesRequest', + ['entityType'] + ); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.streamingReadFeatureValues = stubServerStreamingCall( undefined, @@ -458,11 +470,14 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { }); }); await assert.rejects(promise, expectedError); - assert( - (client.innerApiCalls.streamingReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.streamingReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.streamingReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes streamingReadFeatureValues with closed client', async () => { @@ -477,7 +492,11 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.StreamingReadFeatureValuesRequest() ); - request.entityType = ''; + const defaultValue1 = getTypeDefaultValue( + 'StreamingReadFeatureValuesRequest', + ['entityType'] + ); + request.entityType = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.streamingReadFeatureValues(request); @@ -1007,12 +1026,15 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1046,12 +1068,15 @@ describe('v1.FeaturestoreOnlineServingServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_featurestore_online_serving_service_v1beta1.ts b/test/gapic_featurestore_online_serving_service_v1beta1.ts index 55d2875f..f54d0166 100644 --- a/test/gapic_featurestore_online_serving_service_v1beta1.ts +++ b/test/gapic_featurestore_online_serving_service_v1beta1.ts @@ -32,6 +32,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -242,26 +257,25 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadFeatureValuesResponse() ); client.innerApiCalls.readFeatureValues = stubSimpleCall(expectedResponse); const [response] = await client.readFeatureValues(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readFeatureValues without error using callback', async () => { @@ -276,15 +290,11 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadFeatureValuesResponse() ); @@ -307,11 +317,14 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readFeatureValues with error', async () => { @@ -326,26 +339,25 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ReadFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.readFeatureValues = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.readFeatureValues(request), expectedError); - assert( - (client.innerApiCalls.readFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readFeatureValues with closed client', async () => { @@ -360,7 +372,10 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadFeatureValuesRequest() ); - request.entityType = ''; + const defaultValue1 = getTypeDefaultValue('ReadFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.readFeatureValues(request), expectedError); @@ -380,15 +395,11 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('WriteFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteFeatureValuesResponse() ); @@ -396,11 +407,14 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.writeFeatureValues(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeFeatureValues without error using callback', async () => { @@ -415,15 +429,11 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('WriteFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteFeatureValuesResponse() ); @@ -446,11 +456,14 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.writeFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeFeatureValues with error', async () => { @@ -465,26 +478,25 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('WriteFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.writeFeatureValues = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.writeFeatureValues(request), expectedError); - assert( - (client.innerApiCalls.writeFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeFeatureValues with closed client', async () => { @@ -499,7 +511,10 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteFeatureValuesRequest() ); - request.entityType = ''; + const defaultValue1 = getTypeDefaultValue('WriteFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.writeFeatureValues(request), expectedError); @@ -519,15 +534,12 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.StreamingReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StreamingReadFeatureValuesRequest', + ['entityType'] + ); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadFeatureValuesResponse() ); @@ -549,11 +561,14 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.streamingReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.streamingReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.streamingReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes streamingReadFeatureValues with error', async () => { @@ -568,15 +583,12 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.StreamingReadFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'StreamingReadFeatureValuesRequest', + ['entityType'] + ); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.streamingReadFeatureValues = stubServerStreamingCall( undefined, @@ -597,11 +609,14 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { }); }); await assert.rejects(promise, expectedError); - assert( - (client.innerApiCalls.streamingReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.streamingReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.streamingReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes streamingReadFeatureValues with closed client', async () => { @@ -616,7 +631,11 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.StreamingReadFeatureValuesRequest() ); - request.entityType = ''; + const defaultValue1 = getTypeDefaultValue( + 'StreamingReadFeatureValuesRequest', + ['entityType'] + ); + request.entityType = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.streamingReadFeatureValues(request); @@ -1146,12 +1165,15 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1185,12 +1207,15 @@ describe('v1beta1.FeaturestoreOnlineServingServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_featurestore_service_v1.ts b/test/gapic_featurestore_service_v1.ts index fbeaee26..052b391d 100644 --- a/test/gapic_featurestore_service_v1.ts +++ b/test/gapic_featurestore_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -275,26 +290,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Featurestore() ); client.innerApiCalls.getFeaturestore = stubSimpleCall(expectedResponse); const [response] = await client.getFeaturestore(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeaturestore without error using callback', async () => { @@ -308,15 +322,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Featurestore() ); @@ -339,11 +349,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeaturestore with error', async () => { @@ -357,26 +370,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getFeaturestore = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getFeaturestore(request), expectedError); - assert( - (client.innerApiCalls.getFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeaturestore with closed client', async () => { @@ -390,7 +402,10 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetFeaturestoreRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getFeaturestore(request), expectedError); @@ -409,26 +424,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.EntityType() ); client.innerApiCalls.getEntityType = stubSimpleCall(expectedResponse); const [response] = await client.getEntityType(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEntityType without error using callback', async () => { @@ -442,15 +456,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.EntityType() ); @@ -473,11 +483,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEntityType with error', async () => { @@ -491,26 +504,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getEntityType = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getEntityType(request), expectedError); - assert( - (client.innerApiCalls.getEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEntityType with closed client', async () => { @@ -524,7 +536,10 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetEntityTypeRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getEntityType(request), expectedError); @@ -543,27 +558,27 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateEntityTypeRequest() ); - request.entityType = {}; - request.entityType.name = ''; - const expectedHeaderRequestParams = 'entity_type.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.entityType ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEntityTypeRequest', [ + 'entityType', + 'name', + ]); + request.entityType.name = defaultValue1; + const expectedHeaderRequestParams = `entity_type.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.EntityType() ); client.innerApiCalls.updateEntityType = stubSimpleCall(expectedResponse); const [response] = await client.updateEntityType(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEntityType without error using callback', async () => { @@ -577,16 +592,13 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateEntityTypeRequest() ); - request.entityType = {}; - request.entityType.name = ''; - const expectedHeaderRequestParams = 'entity_type.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.entityType ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEntityTypeRequest', [ + 'entityType', + 'name', + ]); + request.entityType.name = defaultValue1; + const expectedHeaderRequestParams = `entity_type.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.EntityType() ); @@ -609,11 +621,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEntityType with error', async () => { @@ -627,27 +642,27 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateEntityTypeRequest() ); - request.entityType = {}; - request.entityType.name = ''; - const expectedHeaderRequestParams = 'entity_type.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.entityType ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEntityTypeRequest', [ + 'entityType', + 'name', + ]); + request.entityType.name = defaultValue1; + const expectedHeaderRequestParams = `entity_type.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateEntityType = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateEntityType(request), expectedError); - assert( - (client.innerApiCalls.updateEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEntityType with closed client', async () => { @@ -661,8 +676,12 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateEntityTypeRequest() ); - request.entityType = {}; - request.entityType.name = ''; + request.entityType ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEntityTypeRequest', [ + 'entityType', + 'name', + ]); + request.entityType.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateEntityType(request), expectedError); @@ -681,26 +700,23 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeatureRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Feature() ); client.innerApiCalls.getFeature = stubSimpleCall(expectedResponse); const [response] = await client.getFeature(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeature without error using callback', async () => { @@ -714,15 +730,9 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeatureRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Feature() ); @@ -745,11 +755,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeature with error', async () => { @@ -763,26 +776,23 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeatureRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getFeature = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getFeature(request), expectedError); - assert( - (client.innerApiCalls.getFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeature with closed client', async () => { @@ -796,7 +806,8 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetFeatureRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetFeatureRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getFeature(request), expectedError); @@ -815,27 +826,27 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateFeatureRequest() ); - request.feature = {}; - request.feature.name = ''; - const expectedHeaderRequestParams = 'feature.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.feature ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeatureRequest', [ + 'feature', + 'name', + ]); + request.feature.name = defaultValue1; + const expectedHeaderRequestParams = `feature.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Feature() ); client.innerApiCalls.updateFeature = stubSimpleCall(expectedResponse); const [response] = await client.updateFeature(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeature without error using callback', async () => { @@ -849,16 +860,13 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateFeatureRequest() ); - request.feature = {}; - request.feature.name = ''; - const expectedHeaderRequestParams = 'feature.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.feature ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeatureRequest', [ + 'feature', + 'name', + ]); + request.feature.name = defaultValue1; + const expectedHeaderRequestParams = `feature.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Feature() ); @@ -881,11 +889,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeature with error', async () => { @@ -899,27 +910,27 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateFeatureRequest() ); - request.feature = {}; - request.feature.name = ''; - const expectedHeaderRequestParams = 'feature.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.feature ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeatureRequest', [ + 'feature', + 'name', + ]); + request.feature.name = defaultValue1; + const expectedHeaderRequestParams = `feature.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateFeature = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateFeature(request), expectedError); - assert( - (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeature with closed client', async () => { @@ -933,8 +944,12 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateFeatureRequest() ); - request.feature = {}; - request.feature.name = ''; + request.feature ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeatureRequest', [ + 'feature', + 'name', + ]); + request.feature.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateFeature(request), expectedError); @@ -953,15 +968,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateFeaturestoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeaturestoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -970,11 +981,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.createFeaturestore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeaturestore without error using callback', async () => { @@ -988,15 +1002,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateFeaturestoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeaturestoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1026,11 +1036,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeaturestore with call error', async () => { @@ -1044,26 +1057,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateFeaturestoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeaturestoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createFeaturestore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createFeaturestore(request), expectedError); - assert( - (client.innerApiCalls.createFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeaturestore with LRO error', async () => { @@ -1077,15 +1089,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateFeaturestoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeaturestoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createFeaturestore = stubLongRunningCall( undefined, @@ -1094,11 +1102,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.createFeaturestore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateFeaturestoreProgress without error', async () => { @@ -1159,16 +1170,13 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateFeaturestoreRequest() ); - request.featurestore = {}; - request.featurestore.name = ''; - const expectedHeaderRequestParams = 'featurestore.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.featurestore ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeaturestoreRequest', [ + 'featurestore', + 'name', + ]); + request.featurestore.name = defaultValue1; + const expectedHeaderRequestParams = `featurestore.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1177,11 +1185,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.updateFeaturestore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeaturestore without error using callback', async () => { @@ -1195,16 +1206,13 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateFeaturestoreRequest() ); - request.featurestore = {}; - request.featurestore.name = ''; - const expectedHeaderRequestParams = 'featurestore.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.featurestore ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeaturestoreRequest', [ + 'featurestore', + 'name', + ]); + request.featurestore.name = defaultValue1; + const expectedHeaderRequestParams = `featurestore.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1234,11 +1242,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeaturestore with call error', async () => { @@ -1252,27 +1263,27 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateFeaturestoreRequest() ); - request.featurestore = {}; - request.featurestore.name = ''; - const expectedHeaderRequestParams = 'featurestore.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.featurestore ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeaturestoreRequest', [ + 'featurestore', + 'name', + ]); + request.featurestore.name = defaultValue1; + const expectedHeaderRequestParams = `featurestore.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateFeaturestore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateFeaturestore(request), expectedError); - assert( - (client.innerApiCalls.updateFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeaturestore with LRO error', async () => { @@ -1286,16 +1297,13 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateFeaturestoreRequest() ); - request.featurestore = {}; - request.featurestore.name = ''; - const expectedHeaderRequestParams = 'featurestore.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.featurestore ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeaturestoreRequest', [ + 'featurestore', + 'name', + ]); + request.featurestore.name = defaultValue1; + const expectedHeaderRequestParams = `featurestore.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateFeaturestore = stubLongRunningCall( undefined, @@ -1304,11 +1312,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.updateFeaturestore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateFeaturestoreProgress without error', async () => { @@ -1369,15 +1380,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1386,11 +1393,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.deleteFeaturestore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeaturestore without error using callback', async () => { @@ -1404,15 +1414,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1442,11 +1448,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeaturestore with call error', async () => { @@ -1460,26 +1469,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteFeaturestore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteFeaturestore(request), expectedError); - assert( - (client.innerApiCalls.deleteFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeaturestore with LRO error', async () => { @@ -1493,15 +1501,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteFeaturestore = stubLongRunningCall( undefined, @@ -1510,11 +1514,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.deleteFeaturestore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteFeaturestoreProgress without error', async () => { @@ -1575,15 +1582,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateEntityTypeRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEntityTypeRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1592,11 +1595,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.createEntityType(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEntityType without error using callback', async () => { @@ -1610,15 +1616,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateEntityTypeRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEntityTypeRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1648,11 +1650,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEntityType with call error', async () => { @@ -1666,26 +1671,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateEntityTypeRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEntityTypeRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEntityType = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createEntityType(request), expectedError); - assert( - (client.innerApiCalls.createEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEntityType with LRO error', async () => { @@ -1699,15 +1703,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateEntityTypeRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEntityTypeRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEntityType = stubLongRunningCall( undefined, @@ -1716,11 +1716,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.createEntityType(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateEntityTypeProgress without error', async () => { @@ -1781,15 +1784,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1798,11 +1797,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.deleteEntityType(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEntityType without error using callback', async () => { @@ -1816,15 +1818,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1854,11 +1852,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEntityType with call error', async () => { @@ -1872,26 +1873,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEntityType = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteEntityType(request), expectedError); - assert( - (client.innerApiCalls.deleteEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEntityType with LRO error', async () => { @@ -1905,15 +1905,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEntityType = stubLongRunningCall( undefined, @@ -1922,11 +1918,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.deleteEntityType(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteEntityTypeProgress without error', async () => { @@ -1987,15 +1986,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateFeatureRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeatureRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2004,11 +1999,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.createFeature(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeature without error using callback', async () => { @@ -2022,15 +2020,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateFeatureRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeatureRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2060,11 +2054,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeature with call error', async () => { @@ -2078,26 +2075,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateFeatureRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeatureRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createFeature = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createFeature(request), expectedError); - assert( - (client.innerApiCalls.createFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeature with LRO error', async () => { @@ -2111,15 +2107,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateFeatureRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeatureRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createFeature = stubLongRunningCall( undefined, @@ -2128,11 +2120,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.createFeature(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateFeatureProgress without error', async () => { @@ -2193,15 +2188,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2210,11 +2201,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.batchCreateFeatures(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateFeatures without error using callback', async () => { @@ -2228,15 +2222,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2266,11 +2256,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateFeatures with call error', async () => { @@ -2284,26 +2277,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateFeatures = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.batchCreateFeatures(request), expectedError); - assert( - (client.innerApiCalls.batchCreateFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateFeatures with LRO error', async () => { @@ -2317,15 +2309,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateFeatures = stubLongRunningCall( undefined, @@ -2334,11 +2322,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.batchCreateFeatures(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.batchCreateFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkBatchCreateFeaturesProgress without error', async () => { @@ -2399,15 +2390,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeatureRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2416,11 +2403,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.deleteFeature(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeature without error using callback', async () => { @@ -2434,15 +2424,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeatureRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2472,11 +2458,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeature with call error', async () => { @@ -2490,26 +2479,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeatureRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteFeature = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteFeature(request), expectedError); - assert( - (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeature with LRO error', async () => { @@ -2523,15 +2511,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeatureRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteFeature = stubLongRunningCall( undefined, @@ -2540,11 +2524,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.deleteFeature(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteFeatureProgress without error', async () => { @@ -2605,15 +2592,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2622,11 +2605,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.importFeatureValues(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importFeatureValues without error using callback', async () => { @@ -2640,15 +2626,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2678,11 +2660,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importFeatureValues with call error', async () => { @@ -2696,26 +2681,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importFeatureValues = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importFeatureValues(request), expectedError); - assert( - (client.innerApiCalls.importFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importFeatureValues with LRO error', async () => { @@ -2729,15 +2713,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importFeatureValues = stubLongRunningCall( undefined, @@ -2746,11 +2726,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.importFeatureValues(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportFeatureValuesProgress without error', async () => { @@ -2811,15 +2794,12 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadFeatureValuesRequest() ); - request.featurestore = ''; - const expectedHeaderRequestParams = 'featurestore='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadFeatureValuesRequest', + ['featurestore'] + ); + request.featurestore = defaultValue1; + const expectedHeaderRequestParams = `featurestore=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2828,11 +2808,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.batchReadFeatureValues(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadFeatureValues without error using callback', async () => { @@ -2846,15 +2829,12 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadFeatureValuesRequest() ); - request.featurestore = ''; - const expectedHeaderRequestParams = 'featurestore='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadFeatureValuesRequest', + ['featurestore'] + ); + request.featurestore = defaultValue1; + const expectedHeaderRequestParams = `featurestore=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2884,11 +2864,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadFeatureValues with call error', async () => { @@ -2902,15 +2885,12 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadFeatureValuesRequest() ); - request.featurestore = ''; - const expectedHeaderRequestParams = 'featurestore='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadFeatureValuesRequest', + ['featurestore'] + ); + request.featurestore = defaultValue1; + const expectedHeaderRequestParams = `featurestore=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchReadFeatureValues = stubLongRunningCall( undefined, @@ -2920,11 +2900,14 @@ describe('v1.FeaturestoreServiceClient', () => { client.batchReadFeatureValues(request), expectedError ); - assert( - (client.innerApiCalls.batchReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadFeatureValues with LRO error', async () => { @@ -2938,15 +2921,12 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadFeatureValuesRequest() ); - request.featurestore = ''; - const expectedHeaderRequestParams = 'featurestore='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadFeatureValuesRequest', + ['featurestore'] + ); + request.featurestore = defaultValue1; + const expectedHeaderRequestParams = `featurestore=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchReadFeatureValues = stubLongRunningCall( undefined, @@ -2955,11 +2935,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.batchReadFeatureValues(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.batchReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkBatchReadFeatureValuesProgress without error', async () => { @@ -3014,21 +2997,17 @@ describe('v1.FeaturestoreServiceClient', () => { { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', - } - ); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.aiplatform.v1.ExportFeatureValuesRequest() - ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + } + ); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.ExportFeatureValuesRequest() + ); + const defaultValue1 = getTypeDefaultValue('ExportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3037,11 +3016,14 @@ describe('v1.FeaturestoreServiceClient', () => { const [operation] = await client.exportFeatureValues(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportFeatureValues without error using callback', async () => { @@ -3055,15 +3037,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3093,11 +3071,14 @@ describe('v1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportFeatureValues with call error', async () => { @@ -3111,26 +3092,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportFeatureValues = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.exportFeatureValues(request), expectedError); - assert( - (client.innerApiCalls.exportFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportFeatureValues with LRO error', async () => { @@ -3144,15 +3124,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportFeatureValues = stubLongRunningCall( undefined, @@ -3161,11 +3137,14 @@ describe('v1.FeaturestoreServiceClient', () => { ); const [operation] = await client.exportFeatureValues(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.exportFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkExportFeatureValuesProgress without error', async () => { @@ -3226,15 +3205,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Featurestore() @@ -3249,11 +3224,14 @@ describe('v1.FeaturestoreServiceClient', () => { client.innerApiCalls.listFeaturestores = stubSimpleCall(expectedResponse); const [response] = await client.listFeaturestores(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listFeaturestores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeaturestores without error using callback', async () => { @@ -3267,15 +3245,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Featurestore() @@ -3306,11 +3280,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listFeaturestores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeaturestores with error', async () => { @@ -3324,26 +3301,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listFeaturestores = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listFeaturestores(request), expectedError); - assert( - (client.innerApiCalls.listFeaturestores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeaturestoresStream without error', async () => { @@ -3357,8 +3333,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Featurestore() @@ -3395,11 +3374,12 @@ describe('v1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listFeaturestores, request) ); - assert.strictEqual( - ( - client.descriptors.page.listFeaturestores.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeaturestores.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3414,8 +3394,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listFeaturestores.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3441,11 +3424,12 @@ describe('v1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listFeaturestores, request) ); - assert.strictEqual( - ( - client.descriptors.page.listFeaturestores.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeaturestores.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3460,8 +3444,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Featurestore() @@ -3487,11 +3474,12 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listFeaturestores.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeaturestores.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3506,8 +3494,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listFeaturestores.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3524,11 +3515,12 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listFeaturestores.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeaturestores.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3545,15 +3537,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.EntityType() @@ -3568,11 +3556,14 @@ describe('v1.FeaturestoreServiceClient', () => { client.innerApiCalls.listEntityTypes = stubSimpleCall(expectedResponse); const [response] = await client.listEntityTypes(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEntityTypes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEntityTypes without error using callback', async () => { @@ -3586,15 +3577,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.EntityType() @@ -3625,11 +3612,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEntityTypes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEntityTypes with error', async () => { @@ -3643,26 +3633,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listEntityTypes = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listEntityTypes(request), expectedError); - assert( - (client.innerApiCalls.listEntityTypes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEntityTypesStream without error', async () => { @@ -3676,8 +3665,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.EntityType() @@ -3714,11 +3706,12 @@ describe('v1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEntityTypes, request) ); - assert.strictEqual( - ( - client.descriptors.page.listEntityTypes.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEntityTypes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3733,8 +3726,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEntityTypes.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3760,11 +3756,12 @@ describe('v1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEntityTypes, request) ); - assert.strictEqual( - ( - client.descriptors.page.listEntityTypes.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEntityTypes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3779,8 +3776,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.EntityType() @@ -3806,11 +3806,12 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listEntityTypes.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEntityTypes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3825,8 +3826,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEntityTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3843,11 +3847,12 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listEntityTypes.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEntityTypes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3864,15 +3869,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), @@ -3881,11 +3882,14 @@ describe('v1.FeaturestoreServiceClient', () => { client.innerApiCalls.listFeatures = stubSimpleCall(expectedResponse); const [response] = await client.listFeatures(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeatures without error using callback', async () => { @@ -3899,15 +3903,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), @@ -3932,11 +3932,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeatures with error', async () => { @@ -3950,26 +3953,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listFeatures = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listFeatures(request), expectedError); - assert( - (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeaturesStream without error', async () => { @@ -3983,8 +3985,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), @@ -4015,11 +4020,12 @@ describe('v1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listFeatures, request) ); - assert.strictEqual( - ( - client.descriptors.page.listFeatures.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4034,8 +4040,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listFeatures.createStream = stubPageStreamingCall( undefined, @@ -4063,11 +4072,12 @@ describe('v1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listFeatures, request) ); - assert.strictEqual( - ( - client.descriptors.page.listFeatures.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4082,8 +4092,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), @@ -4103,11 +4116,12 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listFeatures.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4122,8 +4136,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listFeatures.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4140,11 +4157,12 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listFeatures.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4161,15 +4179,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), @@ -4178,11 +4192,14 @@ describe('v1.FeaturestoreServiceClient', () => { client.innerApiCalls.searchFeatures = stubSimpleCall(expectedResponse); const [response] = await client.searchFeatures(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchFeatures without error using callback', async () => { @@ -4196,15 +4213,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), @@ -4229,11 +4242,14 @@ describe('v1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchFeatures with error', async () => { @@ -4247,26 +4263,25 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.searchFeatures = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.searchFeatures(request), expectedError); - assert( - (client.innerApiCalls.searchFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchFeaturesStream without error', async () => { @@ -4280,8 +4295,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), @@ -4312,11 +4330,12 @@ describe('v1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.searchFeatures, request) ); - assert.strictEqual( - ( - client.descriptors.page.searchFeatures.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.searchFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4331,8 +4350,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchFeatures.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4358,11 +4380,12 @@ describe('v1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.searchFeatures, request) ); - assert.strictEqual( - ( - client.descriptors.page.searchFeatures.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.searchFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4377,8 +4400,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Feature()), @@ -4398,11 +4424,12 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.searchFeatures.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.searchFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4417,8 +4444,11 @@ describe('v1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchFeatures.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4435,11 +4465,12 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.searchFeatures.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.searchFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4940,12 +4971,15 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -4978,12 +5012,15 @@ describe('v1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_featurestore_service_v1beta1.ts b/test/gapic_featurestore_service_v1beta1.ts index 8750ce16..b7a070f1 100644 --- a/test/gapic_featurestore_service_v1beta1.ts +++ b/test/gapic_featurestore_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -269,26 +284,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Featurestore() ); client.innerApiCalls.getFeaturestore = stubSimpleCall(expectedResponse); const [response] = await client.getFeaturestore(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeaturestore without error using callback', async () => { @@ -301,15 +315,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Featurestore() ); @@ -332,11 +342,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeaturestore with error', async () => { @@ -349,26 +362,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getFeaturestore = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getFeaturestore(request), expectedError); - assert( - (client.innerApiCalls.getFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeaturestore with closed client', async () => { @@ -381,7 +393,10 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetFeaturestoreRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getFeaturestore(request), expectedError); @@ -399,26 +414,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.EntityType() ); client.innerApiCalls.getEntityType = stubSimpleCall(expectedResponse); const [response] = await client.getEntityType(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEntityType without error using callback', async () => { @@ -431,15 +445,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.EntityType() ); @@ -462,11 +472,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEntityType with error', async () => { @@ -479,26 +492,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getEntityType = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getEntityType(request), expectedError); - assert( - (client.innerApiCalls.getEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getEntityType with closed client', async () => { @@ -511,7 +523,10 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetEntityTypeRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getEntityType(request), expectedError); @@ -529,27 +544,27 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateEntityTypeRequest() ); - request.entityType = {}; - request.entityType.name = ''; - const expectedHeaderRequestParams = 'entity_type.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.entityType ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEntityTypeRequest', [ + 'entityType', + 'name', + ]); + request.entityType.name = defaultValue1; + const expectedHeaderRequestParams = `entity_type.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.EntityType() ); client.innerApiCalls.updateEntityType = stubSimpleCall(expectedResponse); const [response] = await client.updateEntityType(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEntityType without error using callback', async () => { @@ -562,16 +577,13 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateEntityTypeRequest() ); - request.entityType = {}; - request.entityType.name = ''; - const expectedHeaderRequestParams = 'entity_type.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.entityType ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEntityTypeRequest', [ + 'entityType', + 'name', + ]); + request.entityType.name = defaultValue1; + const expectedHeaderRequestParams = `entity_type.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.EntityType() ); @@ -594,11 +606,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEntityType with error', async () => { @@ -611,27 +626,27 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateEntityTypeRequest() ); - request.entityType = {}; - request.entityType.name = ''; - const expectedHeaderRequestParams = 'entity_type.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.entityType ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEntityTypeRequest', [ + 'entityType', + 'name', + ]); + request.entityType.name = defaultValue1; + const expectedHeaderRequestParams = `entity_type.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateEntityType = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateEntityType(request), expectedError); - assert( - (client.innerApiCalls.updateEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateEntityType with closed client', async () => { @@ -644,8 +659,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateEntityTypeRequest() ); - request.entityType = {}; - request.entityType.name = ''; + request.entityType ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateEntityTypeRequest', [ + 'entityType', + 'name', + ]); + request.entityType.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateEntityType(request), expectedError); @@ -663,26 +682,23 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeatureRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() ); client.innerApiCalls.getFeature = stubSimpleCall(expectedResponse); const [response] = await client.getFeature(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeature without error using callback', async () => { @@ -695,15 +711,9 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeatureRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() ); @@ -726,11 +736,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeature with error', async () => { @@ -743,26 +756,23 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetFeatureRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getFeature = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getFeature(request), expectedError); - assert( - (client.innerApiCalls.getFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getFeature with closed client', async () => { @@ -775,7 +785,8 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetFeatureRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetFeatureRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getFeature(request), expectedError); @@ -793,27 +804,27 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateFeatureRequest() ); - request.feature = {}; - request.feature.name = ''; - const expectedHeaderRequestParams = 'feature.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.feature ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeatureRequest', [ + 'feature', + 'name', + ]); + request.feature.name = defaultValue1; + const expectedHeaderRequestParams = `feature.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() ); client.innerApiCalls.updateFeature = stubSimpleCall(expectedResponse); const [response] = await client.updateFeature(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeature without error using callback', async () => { @@ -826,16 +837,13 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateFeatureRequest() ); - request.feature = {}; - request.feature.name = ''; - const expectedHeaderRequestParams = 'feature.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.feature ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeatureRequest', [ + 'feature', + 'name', + ]); + request.feature.name = defaultValue1; + const expectedHeaderRequestParams = `feature.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() ); @@ -858,11 +866,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeature with error', async () => { @@ -875,27 +886,27 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateFeatureRequest() ); - request.feature = {}; - request.feature.name = ''; - const expectedHeaderRequestParams = 'feature.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.feature ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeatureRequest', [ + 'feature', + 'name', + ]); + request.feature.name = defaultValue1; + const expectedHeaderRequestParams = `feature.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateFeature = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateFeature(request), expectedError); - assert( - (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeature with closed client', async () => { @@ -908,8 +919,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateFeatureRequest() ); - request.feature = {}; - request.feature.name = ''; + request.feature ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeatureRequest', [ + 'feature', + 'name', + ]); + request.feature.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateFeature(request), expectedError); @@ -927,15 +942,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateFeaturestoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeaturestoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -944,11 +955,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.createFeaturestore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeaturestore without error using callback', async () => { @@ -961,15 +975,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateFeaturestoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeaturestoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -999,11 +1009,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeaturestore with call error', async () => { @@ -1016,26 +1029,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateFeaturestoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeaturestoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createFeaturestore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createFeaturestore(request), expectedError); - assert( - (client.innerApiCalls.createFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeaturestore with LRO error', async () => { @@ -1048,15 +1060,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateFeaturestoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeaturestoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createFeaturestore = stubLongRunningCall( undefined, @@ -1065,11 +1073,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.createFeaturestore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateFeaturestoreProgress without error', async () => { @@ -1127,16 +1138,13 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateFeaturestoreRequest() ); - request.featurestore = {}; - request.featurestore.name = ''; - const expectedHeaderRequestParams = 'featurestore.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.featurestore ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeaturestoreRequest', [ + 'featurestore', + 'name', + ]); + request.featurestore.name = defaultValue1; + const expectedHeaderRequestParams = `featurestore.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1145,11 +1153,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.updateFeaturestore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeaturestore without error using callback', async () => { @@ -1162,16 +1173,13 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateFeaturestoreRequest() ); - request.featurestore = {}; - request.featurestore.name = ''; - const expectedHeaderRequestParams = 'featurestore.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.featurestore ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeaturestoreRequest', [ + 'featurestore', + 'name', + ]); + request.featurestore.name = defaultValue1; + const expectedHeaderRequestParams = `featurestore.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1201,11 +1209,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeaturestore with call error', async () => { @@ -1218,27 +1229,27 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateFeaturestoreRequest() ); - request.featurestore = {}; - request.featurestore.name = ''; - const expectedHeaderRequestParams = 'featurestore.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.featurestore ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeaturestoreRequest', [ + 'featurestore', + 'name', + ]); + request.featurestore.name = defaultValue1; + const expectedHeaderRequestParams = `featurestore.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateFeaturestore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateFeaturestore(request), expectedError); - assert( - (client.innerApiCalls.updateFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateFeaturestore with LRO error', async () => { @@ -1251,16 +1262,13 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateFeaturestoreRequest() ); - request.featurestore = {}; - request.featurestore.name = ''; - const expectedHeaderRequestParams = 'featurestore.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.featurestore ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateFeaturestoreRequest', [ + 'featurestore', + 'name', + ]); + request.featurestore.name = defaultValue1; + const expectedHeaderRequestParams = `featurestore.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateFeaturestore = stubLongRunningCall( undefined, @@ -1269,11 +1277,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.updateFeaturestore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateFeaturestoreProgress without error', async () => { @@ -1331,15 +1342,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1348,11 +1355,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.deleteFeaturestore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeaturestore without error using callback', async () => { @@ -1365,15 +1375,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1403,11 +1409,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeaturestore with call error', async () => { @@ -1420,26 +1429,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteFeaturestore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteFeaturestore(request), expectedError); - assert( - (client.innerApiCalls.deleteFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeaturestore with LRO error', async () => { @@ -1452,15 +1460,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteFeaturestoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeaturestoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteFeaturestore = stubLongRunningCall( undefined, @@ -1469,11 +1473,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.deleteFeaturestore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteFeaturestore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeaturestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteFeaturestoreProgress without error', async () => { @@ -1531,15 +1538,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateEntityTypeRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEntityTypeRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1548,11 +1551,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.createEntityType(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEntityType without error using callback', async () => { @@ -1565,15 +1571,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateEntityTypeRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEntityTypeRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1603,11 +1605,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEntityType with call error', async () => { @@ -1620,26 +1625,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateEntityTypeRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEntityTypeRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEntityType = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createEntityType(request), expectedError); - assert( - (client.innerApiCalls.createEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createEntityType with LRO error', async () => { @@ -1652,15 +1656,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateEntityTypeRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateEntityTypeRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createEntityType = stubLongRunningCall( undefined, @@ -1669,11 +1669,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.createEntityType(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateEntityTypeProgress without error', async () => { @@ -1731,15 +1734,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1748,11 +1747,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.deleteEntityType(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEntityType without error using callback', async () => { @@ -1765,15 +1767,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1803,11 +1801,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEntityType with call error', async () => { @@ -1820,26 +1821,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEntityType = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteEntityType(request), expectedError); - assert( - (client.innerApiCalls.deleteEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteEntityType with LRO error', async () => { @@ -1852,15 +1852,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteEntityTypeRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteEntityTypeRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteEntityType = stubLongRunningCall( undefined, @@ -1869,11 +1865,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.deleteEntityType(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteEntityType as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEntityType as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteEntityTypeProgress without error', async () => { @@ -1931,15 +1930,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateFeatureRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeatureRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1948,11 +1943,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.createFeature(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeature without error using callback', async () => { @@ -1965,15 +1963,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateFeatureRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeatureRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2003,11 +1997,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeature with call error', async () => { @@ -2020,26 +2017,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateFeatureRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeatureRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createFeature = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createFeature(request), expectedError); - assert( - (client.innerApiCalls.createFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createFeature with LRO error', async () => { @@ -2052,15 +2048,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateFeatureRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateFeatureRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createFeature = stubLongRunningCall( undefined, @@ -2069,11 +2061,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.createFeature(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateFeatureProgress without error', async () => { @@ -2131,15 +2126,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2148,11 +2139,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.batchCreateFeatures(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateFeatures without error using callback', async () => { @@ -2165,15 +2159,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2203,11 +2193,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateFeatures with call error', async () => { @@ -2220,26 +2213,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateFeatures = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.batchCreateFeatures(request), expectedError); - assert( - (client.innerApiCalls.batchCreateFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateFeatures with LRO error', async () => { @@ -2252,15 +2244,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('BatchCreateFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateFeatures = stubLongRunningCall( undefined, @@ -2269,11 +2257,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.batchCreateFeatures(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.batchCreateFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkBatchCreateFeaturesProgress without error', async () => { @@ -2331,15 +2322,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeatureRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2348,11 +2335,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.deleteFeature(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeature without error using callback', async () => { @@ -2365,15 +2355,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeatureRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2403,11 +2389,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeature with call error', async () => { @@ -2420,26 +2409,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeatureRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteFeature = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteFeature(request), expectedError); - assert( - (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteFeature with LRO error', async () => { @@ -2452,15 +2440,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteFeatureRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteFeatureRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteFeature = stubLongRunningCall( undefined, @@ -2469,11 +2453,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.deleteFeature(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteFeatureProgress without error', async () => { @@ -2531,15 +2518,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2548,11 +2531,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.importFeatureValues(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importFeatureValues without error using callback', async () => { @@ -2565,15 +2551,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2603,11 +2585,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importFeatureValues with call error', async () => { @@ -2620,26 +2605,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importFeatureValues = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importFeatureValues(request), expectedError); - assert( - (client.innerApiCalls.importFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importFeatureValues with LRO error', async () => { @@ -2652,15 +2636,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ImportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importFeatureValues = stubLongRunningCall( undefined, @@ -2669,11 +2649,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.importFeatureValues(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportFeatureValuesProgress without error', async () => { @@ -2731,15 +2714,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadFeatureValuesRequest() ); - request.featurestore = ''; - const expectedHeaderRequestParams = 'featurestore='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadFeatureValuesRequest', + ['featurestore'] + ); + request.featurestore = defaultValue1; + const expectedHeaderRequestParams = `featurestore=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2748,11 +2728,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.batchReadFeatureValues(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadFeatureValues without error using callback', async () => { @@ -2765,15 +2748,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadFeatureValuesRequest() ); - request.featurestore = ''; - const expectedHeaderRequestParams = 'featurestore='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadFeatureValuesRequest', + ['featurestore'] + ); + request.featurestore = defaultValue1; + const expectedHeaderRequestParams = `featurestore=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2803,11 +2783,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadFeatureValues with call error', async () => { @@ -2820,15 +2803,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadFeatureValuesRequest() ); - request.featurestore = ''; - const expectedHeaderRequestParams = 'featurestore='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadFeatureValuesRequest', + ['featurestore'] + ); + request.featurestore = defaultValue1; + const expectedHeaderRequestParams = `featurestore=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchReadFeatureValues = stubLongRunningCall( undefined, @@ -2838,11 +2818,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { client.batchReadFeatureValues(request), expectedError ); - assert( - (client.innerApiCalls.batchReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadFeatureValues with LRO error', async () => { @@ -2855,15 +2838,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadFeatureValuesRequest() ); - request.featurestore = ''; - const expectedHeaderRequestParams = 'featurestore='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadFeatureValuesRequest', + ['featurestore'] + ); + request.featurestore = defaultValue1; + const expectedHeaderRequestParams = `featurestore=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchReadFeatureValues = stubLongRunningCall( undefined, @@ -2872,11 +2852,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.batchReadFeatureValues(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.batchReadFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkBatchReadFeatureValuesProgress without error', async () => { @@ -2928,21 +2911,17 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const client = new featurestoreserviceModule.v1beta1.FeaturestoreServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.aiplatform.v1beta1.ExportFeatureValuesRequest() - ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.ExportFeatureValuesRequest() + ); + const defaultValue1 = getTypeDefaultValue('ExportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2951,11 +2930,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const [operation] = await client.exportFeatureValues(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportFeatureValues without error using callback', async () => { @@ -2968,15 +2950,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3006,11 +2984,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportFeatureValues with call error', async () => { @@ -3023,26 +3004,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportFeatureValues = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.exportFeatureValues(request), expectedError); - assert( - (client.innerApiCalls.exportFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportFeatureValues with LRO error', async () => { @@ -3055,15 +3035,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportFeatureValuesRequest() ); - request.entityType = ''; - const expectedHeaderRequestParams = 'entity_type='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportFeatureValuesRequest', [ + 'entityType', + ]); + request.entityType = defaultValue1; + const expectedHeaderRequestParams = `entity_type=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportFeatureValues = stubLongRunningCall( undefined, @@ -3072,11 +3048,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ); const [operation] = await client.exportFeatureValues(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.exportFeatureValues as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportFeatureValues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkExportFeatureValuesProgress without error', async () => { @@ -3134,15 +3113,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Featurestore() @@ -3157,11 +3132,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { client.innerApiCalls.listFeaturestores = stubSimpleCall(expectedResponse); const [response] = await client.listFeaturestores(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listFeaturestores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeaturestores without error using callback', async () => { @@ -3174,15 +3152,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Featurestore() @@ -3215,11 +3189,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listFeaturestores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeaturestores with error', async () => { @@ -3232,26 +3209,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listFeaturestores = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listFeaturestores(request), expectedError); - assert( - (client.innerApiCalls.listFeaturestores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeaturestores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeaturestoresStream without error', async () => { @@ -3264,8 +3240,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Featurestore() @@ -3303,11 +3282,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listFeaturestores, request) ); - assert.strictEqual( - ( - client.descriptors.page.listFeaturestores.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeaturestores.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3321,8 +3301,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listFeaturestores.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3349,11 +3332,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listFeaturestores, request) ); - assert.strictEqual( - ( - client.descriptors.page.listFeaturestores.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeaturestores.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3367,8 +3351,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Featurestore() @@ -3395,11 +3382,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listFeaturestores.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeaturestores.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3413,8 +3401,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturestoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturestoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listFeaturestores.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3432,11 +3423,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listFeaturestores.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeaturestores.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3452,15 +3444,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.EntityType() @@ -3475,11 +3463,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { client.innerApiCalls.listEntityTypes = stubSimpleCall(expectedResponse); const [response] = await client.listEntityTypes(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEntityTypes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEntityTypes without error using callback', async () => { @@ -3492,15 +3483,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.EntityType() @@ -3531,11 +3518,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listEntityTypes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEntityTypes with error', async () => { @@ -3548,26 +3538,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listEntityTypes = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listEntityTypes(request), expectedError); - assert( - (client.innerApiCalls.listEntityTypes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntityTypes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listEntityTypesStream without error', async () => { @@ -3580,8 +3569,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.EntityType() @@ -3619,11 +3611,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEntityTypes, request) ); - assert.strictEqual( - ( - client.descriptors.page.listEntityTypes.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEntityTypes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3637,8 +3630,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEntityTypes.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3665,11 +3661,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listEntityTypes, request) ); - assert.strictEqual( - ( - client.descriptors.page.listEntityTypes.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEntityTypes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3683,8 +3680,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.EntityType() @@ -3711,11 +3711,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listEntityTypes.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEntityTypes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3729,8 +3730,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListEntityTypesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListEntityTypesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listEntityTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3748,11 +3752,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listEntityTypes.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listEntityTypes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3768,15 +3773,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() @@ -3791,11 +3792,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { client.innerApiCalls.listFeatures = stubSimpleCall(expectedResponse); const [response] = await client.listFeatures(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeatures without error using callback', async () => { @@ -3808,15 +3812,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() @@ -3847,11 +3847,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeatures with error', async () => { @@ -3864,26 +3867,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listFeatures = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listFeatures(request), expectedError); - assert( - (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listFeaturesStream without error', async () => { @@ -3896,8 +3898,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() @@ -3934,11 +3939,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listFeatures, request) ); - assert.strictEqual( - ( - client.descriptors.page.listFeatures.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3952,8 +3958,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listFeatures.createStream = stubPageStreamingCall( undefined, @@ -3981,11 +3990,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listFeatures, request) ); - assert.strictEqual( - ( - client.descriptors.page.listFeatures.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3999,8 +4009,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() @@ -4026,11 +4039,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listFeatures.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4044,8 +4058,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListFeaturesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListFeaturesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listFeatures.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4062,11 +4079,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listFeatures.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4082,15 +4100,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() @@ -4105,11 +4119,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { client.innerApiCalls.searchFeatures = stubSimpleCall(expectedResponse); const [response] = await client.searchFeatures(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchFeatures without error using callback', async () => { @@ -4122,15 +4139,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() @@ -4161,11 +4174,14 @@ describe('v1beta1.FeaturestoreServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchFeatures with error', async () => { @@ -4178,26 +4194,25 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.searchFeatures = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.searchFeatures(request), expectedError); - assert( - (client.innerApiCalls.searchFeatures as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchFeaturesStream without error', async () => { @@ -4210,8 +4225,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() @@ -4248,11 +4266,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.searchFeatures, request) ); - assert.strictEqual( - ( - client.descriptors.page.searchFeatures.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.searchFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4266,8 +4285,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchFeatures.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4293,11 +4315,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.searchFeatures, request) ); - assert.strictEqual( - ( - client.descriptors.page.searchFeatures.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.searchFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4311,8 +4334,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Feature() @@ -4338,11 +4364,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.searchFeatures.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.searchFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4356,8 +4383,11 @@ describe('v1beta1.FeaturestoreServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchFeaturesRequest() ); - request.location = ''; - const expectedHeaderRequestParams = 'location='; + const defaultValue1 = getTypeDefaultValue('SearchFeaturesRequest', [ + 'location', + ]); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchFeatures.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4374,11 +4404,12 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.searchFeatures.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.searchFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4866,12 +4897,15 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -4903,12 +4937,15 @@ describe('v1beta1.FeaturestoreServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_index_endpoint_service_v1.ts b/test/gapic_index_endpoint_service_v1.ts index dfb97c58..dd41ce5d 100644 --- a/test/gapic_index_endpoint_service_v1.ts +++ b/test/gapic_index_endpoint_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -269,26 +284,25 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.IndexEndpoint() ); client.innerApiCalls.getIndexEndpoint = stubSimpleCall(expectedResponse); const [response] = await client.getIndexEndpoint(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndexEndpoint without error using callback', async () => { @@ -301,15 +315,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.IndexEndpoint() ); @@ -332,11 +342,14 @@ describe('v1.IndexEndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndexEndpoint with error', async () => { @@ -349,26 +362,25 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getIndexEndpoint = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getIndexEndpoint(request), expectedError); - assert( - (client.innerApiCalls.getIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndexEndpoint with closed client', async () => { @@ -381,7 +393,10 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetIndexEndpointRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getIndexEndpoint(request), expectedError); @@ -399,16 +414,13 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateIndexEndpointRequest() ); - request.indexEndpoint = {}; - request.indexEndpoint.name = ''; - const expectedHeaderRequestParams = 'index_endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.indexEndpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexEndpointRequest', [ + 'indexEndpoint', + 'name', + ]); + request.indexEndpoint.name = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.IndexEndpoint() ); @@ -416,11 +428,14 @@ describe('v1.IndexEndpointServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.updateIndexEndpoint(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndexEndpoint without error using callback', async () => { @@ -433,16 +448,13 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateIndexEndpointRequest() ); - request.indexEndpoint = {}; - request.indexEndpoint.name = ''; - const expectedHeaderRequestParams = 'index_endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.indexEndpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexEndpointRequest', [ + 'indexEndpoint', + 'name', + ]); + request.indexEndpoint.name = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.IndexEndpoint() ); @@ -465,11 +477,14 @@ describe('v1.IndexEndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndexEndpoint with error', async () => { @@ -482,27 +497,27 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateIndexEndpointRequest() ); - request.indexEndpoint = {}; - request.indexEndpoint.name = ''; - const expectedHeaderRequestParams = 'index_endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.indexEndpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexEndpointRequest', [ + 'indexEndpoint', + 'name', + ]); + request.indexEndpoint.name = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateIndexEndpoint = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateIndexEndpoint(request), expectedError); - assert( - (client.innerApiCalls.updateIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndexEndpoint with closed client', async () => { @@ -515,8 +530,12 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateIndexEndpointRequest() ); - request.indexEndpoint = {}; - request.indexEndpoint.name = ''; + request.indexEndpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexEndpointRequest', [ + 'indexEndpoint', + 'name', + ]); + request.indexEndpoint.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateIndexEndpoint(request), expectedError); @@ -534,15 +553,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateIndexEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -551,11 +566,14 @@ describe('v1.IndexEndpointServiceClient', () => { const [operation] = await client.createIndexEndpoint(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndexEndpoint without error using callback', async () => { @@ -568,15 +586,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateIndexEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -606,11 +620,14 @@ describe('v1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndexEndpoint with call error', async () => { @@ -623,26 +640,25 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateIndexEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndexEndpoint = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createIndexEndpoint(request), expectedError); - assert( - (client.innerApiCalls.createIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndexEndpoint with LRO error', async () => { @@ -655,15 +671,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateIndexEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndexEndpoint = stubLongRunningCall( undefined, @@ -672,11 +684,14 @@ describe('v1.IndexEndpointServiceClient', () => { ); const [operation] = await client.createIndexEndpoint(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateIndexEndpointProgress without error', async () => { @@ -734,15 +749,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -751,11 +762,14 @@ describe('v1.IndexEndpointServiceClient', () => { const [operation] = await client.deleteIndexEndpoint(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndexEndpoint without error using callback', async () => { @@ -768,15 +782,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -806,11 +816,14 @@ describe('v1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndexEndpoint with call error', async () => { @@ -823,26 +836,25 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndexEndpoint = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteIndexEndpoint(request), expectedError); - assert( - (client.innerApiCalls.deleteIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndexEndpoint with LRO error', async () => { @@ -855,15 +867,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndexEndpoint = stubLongRunningCall( undefined, @@ -872,11 +880,14 @@ describe('v1.IndexEndpointServiceClient', () => { ); const [operation] = await client.deleteIndexEndpoint(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteIndexEndpointProgress without error', async () => { @@ -934,15 +945,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -950,11 +957,14 @@ describe('v1.IndexEndpointServiceClient', () => { const [operation] = await client.deployIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployIndex without error using callback', async () => { @@ -967,15 +977,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1005,11 +1011,14 @@ describe('v1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployIndex with call error', async () => { @@ -1022,26 +1031,25 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deployIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deployIndex(request), expectedError); - assert( - (client.innerApiCalls.deployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployIndex with LRO error', async () => { @@ -1054,15 +1062,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deployIndex = stubLongRunningCall( undefined, @@ -1071,11 +1075,14 @@ describe('v1.IndexEndpointServiceClient', () => { ); const [operation] = await client.deployIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeployIndexProgress without error', async () => { @@ -1130,15 +1137,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UndeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1147,11 +1150,14 @@ describe('v1.IndexEndpointServiceClient', () => { const [operation] = await client.undeployIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.undeployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployIndex without error using callback', async () => { @@ -1164,15 +1170,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UndeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1202,11 +1204,14 @@ describe('v1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.undeployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployIndex with call error', async () => { @@ -1219,26 +1224,25 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UndeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.undeployIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.undeployIndex(request), expectedError); - assert( - (client.innerApiCalls.undeployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployIndex with LRO error', async () => { @@ -1251,15 +1255,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UndeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.undeployIndex = stubLongRunningCall( undefined, @@ -1268,11 +1268,14 @@ describe('v1.IndexEndpointServiceClient', () => { ); const [operation] = await client.undeployIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.undeployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUndeployIndexProgress without error', async () => { @@ -1330,15 +1333,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MutateDeployedIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MutateDeployedIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1347,11 +1346,14 @@ describe('v1.IndexEndpointServiceClient', () => { const [operation] = await client.mutateDeployedIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.mutateDeployedIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mutateDeployedIndex without error using callback', async () => { @@ -1364,15 +1366,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MutateDeployedIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MutateDeployedIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1402,11 +1400,14 @@ describe('v1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.mutateDeployedIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mutateDeployedIndex with call error', async () => { @@ -1419,26 +1420,25 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MutateDeployedIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MutateDeployedIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.mutateDeployedIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.mutateDeployedIndex(request), expectedError); - assert( - (client.innerApiCalls.mutateDeployedIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mutateDeployedIndex with LRO error', async () => { @@ -1451,15 +1451,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MutateDeployedIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MutateDeployedIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.mutateDeployedIndex = stubLongRunningCall( undefined, @@ -1468,11 +1464,14 @@ describe('v1.IndexEndpointServiceClient', () => { ); const [operation] = await client.mutateDeployedIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.mutateDeployedIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkMutateDeployedIndexProgress without error', async () => { @@ -1530,15 +1529,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.IndexEndpoint() @@ -1554,11 +1549,14 @@ describe('v1.IndexEndpointServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listIndexEndpoints(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listIndexEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexEndpoints without error using callback', async () => { @@ -1571,15 +1569,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.IndexEndpoint() @@ -1610,11 +1604,14 @@ describe('v1.IndexEndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listIndexEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexEndpoints with error', async () => { @@ -1627,26 +1624,25 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listIndexEndpoints = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listIndexEndpoints(request), expectedError); - assert( - (client.innerApiCalls.listIndexEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexEndpointsStream without error', async () => { @@ -1659,8 +1655,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.IndexEndpoint() @@ -1697,11 +1696,12 @@ describe('v1.IndexEndpointServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listIndexEndpoints, request) ); - assert.strictEqual( - ( - client.descriptors.page.listIndexEndpoints.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1715,8 +1715,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexEndpoints.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1742,11 +1745,12 @@ describe('v1.IndexEndpointServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listIndexEndpoints, request) ); - assert.strictEqual( - ( - client.descriptors.page.listIndexEndpoints.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1760,8 +1764,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.IndexEndpoint() @@ -1787,11 +1794,12 @@ describe('v1.IndexEndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listIndexEndpoints.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1805,8 +1813,11 @@ describe('v1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexEndpoints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1824,11 +1835,12 @@ describe('v1.IndexEndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listIndexEndpoints.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2316,12 +2328,15 @@ describe('v1.IndexEndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -2353,12 +2368,15 @@ describe('v1.IndexEndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_index_endpoint_service_v1beta1.ts b/test/gapic_index_endpoint_service_v1beta1.ts index a9d21de4..1259a433 100644 --- a/test/gapic_index_endpoint_service_v1beta1.ts +++ b/test/gapic_index_endpoint_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -271,26 +286,25 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.IndexEndpoint() ); client.innerApiCalls.getIndexEndpoint = stubSimpleCall(expectedResponse); const [response] = await client.getIndexEndpoint(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndexEndpoint without error using callback', async () => { @@ -303,15 +317,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.IndexEndpoint() ); @@ -334,11 +344,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndexEndpoint with error', async () => { @@ -351,26 +364,25 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getIndexEndpoint = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getIndexEndpoint(request), expectedError); - assert( - (client.innerApiCalls.getIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndexEndpoint with closed client', async () => { @@ -383,7 +395,10 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetIndexEndpointRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getIndexEndpoint(request), expectedError); @@ -401,16 +416,13 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateIndexEndpointRequest() ); - request.indexEndpoint = {}; - request.indexEndpoint.name = ''; - const expectedHeaderRequestParams = 'index_endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.indexEndpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexEndpointRequest', [ + 'indexEndpoint', + 'name', + ]); + request.indexEndpoint.name = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.IndexEndpoint() ); @@ -418,11 +430,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.updateIndexEndpoint(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndexEndpoint without error using callback', async () => { @@ -435,16 +450,13 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateIndexEndpointRequest() ); - request.indexEndpoint = {}; - request.indexEndpoint.name = ''; - const expectedHeaderRequestParams = 'index_endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.indexEndpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexEndpointRequest', [ + 'indexEndpoint', + 'name', + ]); + request.indexEndpoint.name = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.IndexEndpoint() ); @@ -467,11 +479,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndexEndpoint with error', async () => { @@ -484,27 +499,27 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateIndexEndpointRequest() ); - request.indexEndpoint = {}; - request.indexEndpoint.name = ''; - const expectedHeaderRequestParams = 'index_endpoint.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.indexEndpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexEndpointRequest', [ + 'indexEndpoint', + 'name', + ]); + request.indexEndpoint.name = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateIndexEndpoint = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateIndexEndpoint(request), expectedError); - assert( - (client.innerApiCalls.updateIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndexEndpoint with closed client', async () => { @@ -517,8 +532,12 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateIndexEndpointRequest() ); - request.indexEndpoint = {}; - request.indexEndpoint.name = ''; + request.indexEndpoint ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexEndpointRequest', [ + 'indexEndpoint', + 'name', + ]); + request.indexEndpoint.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateIndexEndpoint(request), expectedError); @@ -536,15 +555,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateIndexEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -553,11 +568,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const [operation] = await client.createIndexEndpoint(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndexEndpoint without error using callback', async () => { @@ -570,15 +588,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateIndexEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -608,11 +622,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndexEndpoint with call error', async () => { @@ -625,26 +642,25 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateIndexEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndexEndpoint = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createIndexEndpoint(request), expectedError); - assert( - (client.innerApiCalls.createIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndexEndpoint with LRO error', async () => { @@ -657,15 +673,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateIndexEndpointRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexEndpointRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndexEndpoint = stubLongRunningCall( undefined, @@ -674,11 +686,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ); const [operation] = await client.createIndexEndpoint(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateIndexEndpointProgress without error', async () => { @@ -736,15 +751,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -753,11 +764,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const [operation] = await client.deleteIndexEndpoint(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndexEndpoint without error using callback', async () => { @@ -770,15 +784,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -808,11 +818,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndexEndpoint with call error', async () => { @@ -825,26 +838,25 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndexEndpoint = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteIndexEndpoint(request), expectedError); - assert( - (client.innerApiCalls.deleteIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndexEndpoint with LRO error', async () => { @@ -857,15 +869,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteIndexEndpointRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexEndpointRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndexEndpoint = stubLongRunningCall( undefined, @@ -874,11 +882,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ); const [operation] = await client.deleteIndexEndpoint(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteIndexEndpoint as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndexEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteIndexEndpointProgress without error', async () => { @@ -936,15 +947,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -952,11 +959,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const [operation] = await client.deployIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployIndex without error using callback', async () => { @@ -969,15 +979,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1007,11 +1013,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployIndex with call error', async () => { @@ -1024,26 +1033,25 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deployIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deployIndex(request), expectedError); - assert( - (client.innerApiCalls.deployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deployIndex with LRO error', async () => { @@ -1056,15 +1064,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deployIndex = stubLongRunningCall( undefined, @@ -1073,11 +1077,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ); const [operation] = await client.deployIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeployIndexProgress without error', async () => { @@ -1132,15 +1139,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UndeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1149,11 +1152,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const [operation] = await client.undeployIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.undeployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployIndex without error using callback', async () => { @@ -1166,15 +1172,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UndeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1204,11 +1206,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.undeployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployIndex with call error', async () => { @@ -1221,26 +1226,25 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UndeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.undeployIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.undeployIndex(request), expectedError); - assert( - (client.innerApiCalls.undeployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes undeployIndex with LRO error', async () => { @@ -1253,15 +1257,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UndeployIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UndeployIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.undeployIndex = stubLongRunningCall( undefined, @@ -1270,11 +1270,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ); const [operation] = await client.undeployIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.undeployIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeployIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUndeployIndexProgress without error', async () => { @@ -1332,15 +1335,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MutateDeployedIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MutateDeployedIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1349,11 +1348,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const [operation] = await client.mutateDeployedIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.mutateDeployedIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mutateDeployedIndex without error using callback', async () => { @@ -1366,15 +1368,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MutateDeployedIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MutateDeployedIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1404,11 +1402,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.mutateDeployedIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mutateDeployedIndex with call error', async () => { @@ -1421,26 +1422,25 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MutateDeployedIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MutateDeployedIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.mutateDeployedIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.mutateDeployedIndex(request), expectedError); - assert( - (client.innerApiCalls.mutateDeployedIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mutateDeployedIndex with LRO error', async () => { @@ -1453,15 +1453,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MutateDeployedIndexRequest() ); - request.indexEndpoint = ''; - const expectedHeaderRequestParams = 'index_endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MutateDeployedIndexRequest', [ + 'indexEndpoint', + ]); + request.indexEndpoint = defaultValue1; + const expectedHeaderRequestParams = `index_endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.mutateDeployedIndex = stubLongRunningCall( undefined, @@ -1470,11 +1466,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ); const [operation] = await client.mutateDeployedIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.mutateDeployedIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mutateDeployedIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkMutateDeployedIndexProgress without error', async () => { @@ -1532,15 +1531,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.IndexEndpoint() @@ -1556,11 +1551,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listIndexEndpoints(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listIndexEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexEndpoints without error using callback', async () => { @@ -1573,15 +1571,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.IndexEndpoint() @@ -1614,11 +1608,14 @@ describe('v1beta1.IndexEndpointServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listIndexEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexEndpoints with error', async () => { @@ -1631,26 +1628,25 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listIndexEndpoints = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listIndexEndpoints(request), expectedError); - assert( - (client.innerApiCalls.listIndexEndpoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexEndpointsStream without error', async () => { @@ -1663,8 +1659,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.IndexEndpoint() @@ -1702,11 +1701,12 @@ describe('v1beta1.IndexEndpointServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listIndexEndpoints, request) ); - assert.strictEqual( - ( - client.descriptors.page.listIndexEndpoints.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1720,8 +1720,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexEndpoints.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1748,11 +1751,12 @@ describe('v1beta1.IndexEndpointServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listIndexEndpoints, request) ); - assert.strictEqual( - ( - client.descriptors.page.listIndexEndpoints.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1766,8 +1770,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.IndexEndpoint() @@ -1794,11 +1801,12 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listIndexEndpoints.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1812,8 +1820,11 @@ describe('v1beta1.IndexEndpointServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexEndpointsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexEndpointsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexEndpoints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1831,11 +1842,12 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listIndexEndpoints.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2323,12 +2335,15 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -2360,12 +2375,15 @@ describe('v1beta1.IndexEndpointServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_index_service_v1.ts b/test/gapic_index_service_v1.ts index 81061411..19862c4a 100644 --- a/test/gapic_index_service_v1.ts +++ b/test/gapic_index_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -258,26 +273,23 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Index() ); client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); const [response] = await client.getIndex(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndex without error using callback', async () => { @@ -289,15 +301,9 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Index() ); @@ -320,11 +326,14 @@ describe('v1.IndexServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndex with error', async () => { @@ -336,23 +345,20 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getIndex(request), expectedError); - assert( - (client.innerApiCalls.getIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndex with closed client', async () => { @@ -364,7 +370,8 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetIndexRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetIndexRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getIndex(request), expectedError); @@ -381,26 +388,25 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpsertDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpsertDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpsertDatapointsResponse() ); client.innerApiCalls.upsertDatapoints = stubSimpleCall(expectedResponse); const [response] = await client.upsertDatapoints(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.upsertDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes upsertDatapoints without error using callback', async () => { @@ -412,15 +418,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpsertDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpsertDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpsertDatapointsResponse() ); @@ -443,11 +445,14 @@ describe('v1.IndexServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.upsertDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes upsertDatapoints with error', async () => { @@ -459,26 +464,25 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpsertDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpsertDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.upsertDatapoints = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.upsertDatapoints(request), expectedError); - assert( - (client.innerApiCalls.upsertDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes upsertDatapoints with closed client', async () => { @@ -490,7 +494,10 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpsertDatapointsRequest() ); - request.index = ''; + const defaultValue1 = getTypeDefaultValue('UpsertDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.upsertDatapoints(request), expectedError); @@ -507,26 +514,25 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RemoveDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RemoveDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RemoveDatapointsResponse() ); client.innerApiCalls.removeDatapoints = stubSimpleCall(expectedResponse); const [response] = await client.removeDatapoints(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeDatapoints without error using callback', async () => { @@ -538,15 +544,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RemoveDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RemoveDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RemoveDatapointsResponse() ); @@ -569,11 +571,14 @@ describe('v1.IndexServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeDatapoints with error', async () => { @@ -585,26 +590,25 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RemoveDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RemoveDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.removeDatapoints = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.removeDatapoints(request), expectedError); - assert( - (client.innerApiCalls.removeDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeDatapoints with closed client', async () => { @@ -616,7 +620,10 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RemoveDatapointsRequest() ); - request.index = ''; + const defaultValue1 = getTypeDefaultValue('RemoveDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.removeDatapoints(request), expectedError); @@ -633,15 +640,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateIndexRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -649,11 +652,14 @@ describe('v1.IndexServiceClient', () => { const [operation] = await client.createIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndex without error using callback', async () => { @@ -665,15 +671,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateIndexRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -703,11 +705,14 @@ describe('v1.IndexServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndex with call error', async () => { @@ -719,26 +724,25 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateIndexRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createIndex(request), expectedError); - assert( - (client.innerApiCalls.createIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndex with LRO error', async () => { @@ -750,15 +754,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateIndexRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndex = stubLongRunningCall( undefined, @@ -767,11 +767,14 @@ describe('v1.IndexServiceClient', () => { ); const [operation] = await client.createIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateIndexProgress without error', async () => { @@ -823,16 +826,13 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateIndexRequest() ); - request.index = {}; - request.index.name = ''; - const expectedHeaderRequestParams = 'index.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.index ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexRequest', [ + 'index', + 'name', + ]); + request.index.name = defaultValue1; + const expectedHeaderRequestParams = `index.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -840,11 +840,14 @@ describe('v1.IndexServiceClient', () => { const [operation] = await client.updateIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndex without error using callback', async () => { @@ -856,16 +859,13 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateIndexRequest() ); - request.index = {}; - request.index.name = ''; - const expectedHeaderRequestParams = 'index.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.index ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexRequest', [ + 'index', + 'name', + ]); + request.index.name = defaultValue1; + const expectedHeaderRequestParams = `index.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -895,11 +895,14 @@ describe('v1.IndexServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndex with call error', async () => { @@ -911,27 +914,27 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateIndexRequest() ); - request.index = {}; - request.index.name = ''; - const expectedHeaderRequestParams = 'index.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.index ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexRequest', [ + 'index', + 'name', + ]); + request.index.name = defaultValue1; + const expectedHeaderRequestParams = `index.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateIndex(request), expectedError); - assert( - (client.innerApiCalls.updateIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndex with LRO error', async () => { @@ -943,16 +946,13 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateIndexRequest() ); - request.index = {}; - request.index.name = ''; - const expectedHeaderRequestParams = 'index.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.index ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexRequest', [ + 'index', + 'name', + ]); + request.index.name = defaultValue1; + const expectedHeaderRequestParams = `index.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateIndex = stubLongRunningCall( undefined, @@ -961,11 +961,14 @@ describe('v1.IndexServiceClient', () => { ); const [operation] = await client.updateIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateIndexProgress without error', async () => { @@ -1017,15 +1020,9 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1033,11 +1030,14 @@ describe('v1.IndexServiceClient', () => { const [operation] = await client.deleteIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndex without error using callback', async () => { @@ -1049,15 +1049,9 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1087,11 +1081,14 @@ describe('v1.IndexServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndex with call error', async () => { @@ -1103,26 +1100,23 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteIndex(request), expectedError); - assert( - (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndex with LRO error', async () => { @@ -1134,15 +1128,9 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndex = stubLongRunningCall( undefined, @@ -1151,11 +1139,14 @@ describe('v1.IndexServiceClient', () => { ); const [operation] = await client.deleteIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteIndexProgress without error', async () => { @@ -1207,15 +1198,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Index()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Index()), @@ -1224,11 +1211,14 @@ describe('v1.IndexServiceClient', () => { client.innerApiCalls.listIndexes = stubSimpleCall(expectedResponse); const [response] = await client.listIndexes(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexes without error using callback', async () => { @@ -1240,15 +1230,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Index()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Index()), @@ -1273,11 +1259,14 @@ describe('v1.IndexServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexes with error', async () => { @@ -1289,26 +1278,25 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listIndexes = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listIndexes(request), expectedError); - assert( - (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexesStream without error', async () => { @@ -1320,8 +1308,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Index()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Index()), @@ -1352,11 +1343,12 @@ describe('v1.IndexServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listIndexes, request) ); - assert.strictEqual( - (client.descriptors.page.listIndexes.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1369,8 +1361,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexes.createStream = stubPageStreamingCall( undefined, @@ -1398,11 +1393,12 @@ describe('v1.IndexServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listIndexes, request) ); - assert.strictEqual( - (client.descriptors.page.listIndexes.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1415,8 +1411,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Index()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Index()), @@ -1436,11 +1435,12 @@ describe('v1.IndexServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1453,8 +1453,11 @@ describe('v1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall( undefined, @@ -1473,11 +1476,12 @@ describe('v1.IndexServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1952,12 +1956,15 @@ describe('v1.IndexServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1988,12 +1995,15 @@ describe('v1.IndexServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_index_service_v1beta1.ts b/test/gapic_index_service_v1beta1.ts index 51f2de19..61dc66d5 100644 --- a/test/gapic_index_service_v1beta1.ts +++ b/test/gapic_index_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,23 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Index() ); client.innerApiCalls.getIndex = stubSimpleCall(expectedResponse); const [response] = await client.getIndex(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndex without error using callback', async () => { @@ -291,15 +303,9 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Index() ); @@ -322,11 +328,14 @@ describe('v1beta1.IndexServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndex with error', async () => { @@ -338,23 +347,20 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getIndex = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getIndex(request), expectedError); - assert( - (client.innerApiCalls.getIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getIndex with closed client', async () => { @@ -366,7 +372,8 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetIndexRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetIndexRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getIndex(request), expectedError); @@ -383,26 +390,25 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpsertDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpsertDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpsertDatapointsResponse() ); client.innerApiCalls.upsertDatapoints = stubSimpleCall(expectedResponse); const [response] = await client.upsertDatapoints(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.upsertDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes upsertDatapoints without error using callback', async () => { @@ -414,15 +420,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpsertDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpsertDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpsertDatapointsResponse() ); @@ -445,11 +447,14 @@ describe('v1beta1.IndexServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.upsertDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes upsertDatapoints with error', async () => { @@ -461,26 +466,25 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpsertDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UpsertDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.upsertDatapoints = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.upsertDatapoints(request), expectedError); - assert( - (client.innerApiCalls.upsertDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.upsertDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes upsertDatapoints with closed client', async () => { @@ -492,7 +496,10 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpsertDatapointsRequest() ); - request.index = ''; + const defaultValue1 = getTypeDefaultValue('UpsertDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.upsertDatapoints(request), expectedError); @@ -509,26 +516,25 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RemoveDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RemoveDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RemoveDatapointsResponse() ); client.innerApiCalls.removeDatapoints = stubSimpleCall(expectedResponse); const [response] = await client.removeDatapoints(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeDatapoints without error using callback', async () => { @@ -540,15 +546,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RemoveDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RemoveDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RemoveDatapointsResponse() ); @@ -571,11 +573,14 @@ describe('v1beta1.IndexServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeDatapoints with error', async () => { @@ -587,26 +592,25 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RemoveDatapointsRequest() ); - request.index = ''; - const expectedHeaderRequestParams = 'index='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RemoveDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; + const expectedHeaderRequestParams = `index=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.removeDatapoints = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.removeDatapoints(request), expectedError); - assert( - (client.innerApiCalls.removeDatapoints as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeDatapoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeDatapoints with closed client', async () => { @@ -618,7 +622,10 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RemoveDatapointsRequest() ); - request.index = ''; + const defaultValue1 = getTypeDefaultValue('RemoveDatapointsRequest', [ + 'index', + ]); + request.index = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.removeDatapoints(request), expectedError); @@ -635,15 +642,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateIndexRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -651,11 +654,14 @@ describe('v1beta1.IndexServiceClient', () => { const [operation] = await client.createIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndex without error using callback', async () => { @@ -667,15 +673,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateIndexRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -705,11 +707,14 @@ describe('v1beta1.IndexServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndex with call error', async () => { @@ -721,26 +726,25 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateIndexRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createIndex(request), expectedError); - assert( - (client.innerApiCalls.createIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createIndex with LRO error', async () => { @@ -752,15 +756,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateIndexRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateIndexRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createIndex = stubLongRunningCall( undefined, @@ -769,11 +769,14 @@ describe('v1beta1.IndexServiceClient', () => { ); const [operation] = await client.createIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateIndexProgress without error', async () => { @@ -825,16 +828,13 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateIndexRequest() ); - request.index = {}; - request.index.name = ''; - const expectedHeaderRequestParams = 'index.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.index ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexRequest', [ + 'index', + 'name', + ]); + request.index.name = defaultValue1; + const expectedHeaderRequestParams = `index.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -842,11 +842,14 @@ describe('v1beta1.IndexServiceClient', () => { const [operation] = await client.updateIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndex without error using callback', async () => { @@ -858,16 +861,13 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateIndexRequest() ); - request.index = {}; - request.index.name = ''; - const expectedHeaderRequestParams = 'index.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.index ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexRequest', [ + 'index', + 'name', + ]); + request.index.name = defaultValue1; + const expectedHeaderRequestParams = `index.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -897,11 +897,14 @@ describe('v1beta1.IndexServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndex with call error', async () => { @@ -913,27 +916,27 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateIndexRequest() ); - request.index = {}; - request.index.name = ''; - const expectedHeaderRequestParams = 'index.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.index ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexRequest', [ + 'index', + 'name', + ]); + request.index.name = defaultValue1; + const expectedHeaderRequestParams = `index.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateIndex(request), expectedError); - assert( - (client.innerApiCalls.updateIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateIndex with LRO error', async () => { @@ -945,16 +948,13 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateIndexRequest() ); - request.index = {}; - request.index.name = ''; - const expectedHeaderRequestParams = 'index.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.index ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateIndexRequest', [ + 'index', + 'name', + ]); + request.index.name = defaultValue1; + const expectedHeaderRequestParams = `index.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateIndex = stubLongRunningCall( undefined, @@ -963,11 +963,14 @@ describe('v1beta1.IndexServiceClient', () => { ); const [operation] = await client.updateIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateIndexProgress without error', async () => { @@ -1019,15 +1022,9 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1035,11 +1032,14 @@ describe('v1beta1.IndexServiceClient', () => { const [operation] = await client.deleteIndex(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndex without error using callback', async () => { @@ -1051,15 +1051,9 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1089,11 +1083,14 @@ describe('v1beta1.IndexServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndex with call error', async () => { @@ -1105,26 +1102,23 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndex = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteIndex(request), expectedError); - assert( - (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteIndex with LRO error', async () => { @@ -1136,15 +1130,9 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteIndexRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteIndexRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteIndex = stubLongRunningCall( undefined, @@ -1153,11 +1141,14 @@ describe('v1beta1.IndexServiceClient', () => { ); const [operation] = await client.deleteIndex(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteIndex as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIndex as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteIndexProgress without error', async () => { @@ -1209,15 +1200,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Index() @@ -1232,11 +1219,14 @@ describe('v1beta1.IndexServiceClient', () => { client.innerApiCalls.listIndexes = stubSimpleCall(expectedResponse); const [response] = await client.listIndexes(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexes without error using callback', async () => { @@ -1248,15 +1238,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Index() @@ -1287,11 +1273,14 @@ describe('v1beta1.IndexServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexes with error', async () => { @@ -1303,26 +1292,25 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listIndexes = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listIndexes(request), expectedError); - assert( - (client.innerApiCalls.listIndexes as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIndexes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listIndexesStream without error', async () => { @@ -1334,8 +1322,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Index() @@ -1372,11 +1363,12 @@ describe('v1beta1.IndexServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listIndexes, request) ); - assert.strictEqual( - (client.descriptors.page.listIndexes.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1389,8 +1381,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexes.createStream = stubPageStreamingCall( undefined, @@ -1418,11 +1413,12 @@ describe('v1beta1.IndexServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listIndexes, request) ); - assert.strictEqual( - (client.descriptors.page.listIndexes.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1435,8 +1431,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Index() @@ -1462,11 +1461,12 @@ describe('v1beta1.IndexServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1479,8 +1479,11 @@ describe('v1beta1.IndexServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListIndexesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListIndexesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listIndexes.asyncIterate = stubAsyncIterationCall( undefined, @@ -1499,11 +1502,12 @@ describe('v1beta1.IndexServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listIndexes.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listIndexes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1978,12 +1982,15 @@ describe('v1beta1.IndexServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -2014,12 +2021,15 @@ describe('v1beta1.IndexServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_job_service_v1.ts b/test/gapic_job_service_v1.ts index 84b3a6eb..32bf0cb9 100644 --- a/test/gapic_job_service_v1.ts +++ b/test/gapic_job_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -258,26 +273,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateCustomJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CustomJob() ); client.innerApiCalls.createCustomJob = stubSimpleCall(expectedResponse); const [response] = await client.createCustomJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomJob without error using callback', async () => { @@ -289,15 +303,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateCustomJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CustomJob() ); @@ -320,11 +330,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomJob with error', async () => { @@ -336,26 +349,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateCustomJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createCustomJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createCustomJob(request), expectedError); - assert( - (client.innerApiCalls.createCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomJob with closed client', async () => { @@ -367,7 +379,10 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateCustomJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateCustomJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createCustomJob(request), expectedError); @@ -384,26 +399,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CustomJob() ); client.innerApiCalls.getCustomJob = stubSimpleCall(expectedResponse); const [response] = await client.getCustomJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomJob without error using callback', async () => { @@ -415,15 +429,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CustomJob() ); @@ -446,11 +456,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomJob with error', async () => { @@ -462,26 +475,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getCustomJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getCustomJob(request), expectedError); - assert( - (client.innerApiCalls.getCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomJob with closed client', async () => { @@ -493,7 +505,10 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetCustomJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getCustomJob(request), expectedError); @@ -510,26 +525,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.cancelCustomJob = stubSimpleCall(expectedResponse); const [response] = await client.cancelCustomJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelCustomJob without error using callback', async () => { @@ -541,15 +555,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -572,11 +582,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelCustomJob with error', async () => { @@ -588,26 +601,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelCustomJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.cancelCustomJob(request), expectedError); - assert( - (client.innerApiCalls.cancelCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelCustomJob with closed client', async () => { @@ -619,7 +631,10 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelCustomJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('CancelCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.cancelCustomJob(request), expectedError); @@ -636,15 +651,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateDataLabelingJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDataLabelingJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DataLabelingJob() ); @@ -652,11 +664,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createDataLabelingJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataLabelingJob without error using callback', async () => { @@ -668,15 +683,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateDataLabelingJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDataLabelingJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DataLabelingJob() ); @@ -699,11 +711,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataLabelingJob with error', async () => { @@ -715,15 +730,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateDataLabelingJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDataLabelingJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDataLabelingJob = stubSimpleCall( undefined, @@ -733,11 +745,14 @@ describe('v1.JobServiceClient', () => { client.createDataLabelingJob(request), expectedError ); - assert( - (client.innerApiCalls.createDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataLabelingJob with closed client', async () => { @@ -749,7 +764,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateDataLabelingJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateDataLabelingJobRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -769,15 +788,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDataLabelingJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DataLabelingJob() ); @@ -785,11 +800,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getDataLabelingJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataLabelingJob without error using callback', async () => { @@ -801,15 +819,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDataLabelingJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DataLabelingJob() ); @@ -832,11 +846,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataLabelingJob with error', async () => { @@ -848,26 +865,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDataLabelingJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getDataLabelingJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getDataLabelingJob(request), expectedError); - assert( - (client.innerApiCalls.getDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataLabelingJob with closed client', async () => { @@ -879,7 +895,10 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetDataLabelingJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetDataLabelingJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getDataLabelingJob(request), expectedError); @@ -896,15 +915,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -912,11 +928,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.cancelDataLabelingJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelDataLabelingJob without error using callback', async () => { @@ -928,15 +947,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -959,11 +975,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelDataLabelingJob with error', async () => { @@ -975,15 +994,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelDataLabelingJob = stubSimpleCall( undefined, @@ -993,11 +1009,14 @@ describe('v1.JobServiceClient', () => { client.cancelDataLabelingJob(request), expectedError ); - assert( - (client.innerApiCalls.cancelDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelDataLabelingJob with closed client', async () => { @@ -1009,7 +1028,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelDataLabelingJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'CancelDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1029,15 +1052,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateHyperparameterTuningJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateHyperparameterTuningJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.HyperparameterTuningJob() ); @@ -1045,11 +1065,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createHyperparameterTuningJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createHyperparameterTuningJob without error using callback', async () => { @@ -1061,15 +1084,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateHyperparameterTuningJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateHyperparameterTuningJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.HyperparameterTuningJob() ); @@ -1092,11 +1112,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createHyperparameterTuningJob with error', async () => { @@ -1108,15 +1131,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateHyperparameterTuningJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateHyperparameterTuningJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createHyperparameterTuningJob = stubSimpleCall( undefined, @@ -1126,11 +1146,14 @@ describe('v1.JobServiceClient', () => { client.createHyperparameterTuningJob(request), expectedError ); - assert( - (client.innerApiCalls.createHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createHyperparameterTuningJob with closed client', async () => { @@ -1142,7 +1165,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateHyperparameterTuningJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateHyperparameterTuningJobRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1162,15 +1189,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.HyperparameterTuningJob() ); @@ -1178,11 +1202,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getHyperparameterTuningJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getHyperparameterTuningJob without error using callback', async () => { @@ -1194,15 +1221,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.HyperparameterTuningJob() ); @@ -1225,11 +1249,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getHyperparameterTuningJob with error', async () => { @@ -1241,15 +1268,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getHyperparameterTuningJob = stubSimpleCall( undefined, @@ -1259,11 +1283,14 @@ describe('v1.JobServiceClient', () => { client.getHyperparameterTuningJob(request), expectedError ); - assert( - (client.innerApiCalls.getHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getHyperparameterTuningJob with closed client', async () => { @@ -1275,7 +1302,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetHyperparameterTuningJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1295,15 +1326,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1311,11 +1339,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.cancelHyperparameterTuningJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelHyperparameterTuningJob without error using callback', async () => { @@ -1327,15 +1358,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1358,11 +1386,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelHyperparameterTuningJob with error', async () => { @@ -1374,15 +1405,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelHyperparameterTuningJob = stubSimpleCall( undefined, @@ -1392,11 +1420,14 @@ describe('v1.JobServiceClient', () => { client.cancelHyperparameterTuningJob(request), expectedError ); - assert( - (client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelHyperparameterTuningJob with closed client', async () => { @@ -1408,7 +1439,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelHyperparameterTuningJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'CancelHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1428,15 +1463,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateBatchPredictionJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateBatchPredictionJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchPredictionJob() ); @@ -1444,11 +1476,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createBatchPredictionJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBatchPredictionJob without error using callback', async () => { @@ -1460,15 +1495,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateBatchPredictionJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateBatchPredictionJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchPredictionJob() ); @@ -1491,11 +1523,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBatchPredictionJob with error', async () => { @@ -1507,15 +1542,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateBatchPredictionJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateBatchPredictionJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createBatchPredictionJob = stubSimpleCall( undefined, @@ -1525,11 +1557,14 @@ describe('v1.JobServiceClient', () => { client.createBatchPredictionJob(request), expectedError ); - assert( - (client.innerApiCalls.createBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBatchPredictionJob with closed client', async () => { @@ -1541,7 +1576,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateBatchPredictionJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateBatchPredictionJobRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1561,15 +1600,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchPredictionJob() ); @@ -1577,11 +1613,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getBatchPredictionJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBatchPredictionJob without error using callback', async () => { @@ -1593,15 +1632,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchPredictionJob() ); @@ -1624,11 +1660,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBatchPredictionJob with error', async () => { @@ -1640,15 +1679,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getBatchPredictionJob = stubSimpleCall( undefined, @@ -1658,11 +1694,14 @@ describe('v1.JobServiceClient', () => { client.getBatchPredictionJob(request), expectedError ); - assert( - (client.innerApiCalls.getBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBatchPredictionJob with closed client', async () => { @@ -1674,7 +1713,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetBatchPredictionJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1694,15 +1737,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1710,11 +1750,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.cancelBatchPredictionJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelBatchPredictionJob without error using callback', async () => { @@ -1726,15 +1769,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1757,11 +1797,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelBatchPredictionJob with error', async () => { @@ -1773,15 +1816,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelBatchPredictionJob = stubSimpleCall( undefined, @@ -1791,11 +1831,14 @@ describe('v1.JobServiceClient', () => { client.cancelBatchPredictionJob(request), expectedError ); - assert( - (client.innerApiCalls.cancelBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelBatchPredictionJob with closed client', async () => { @@ -1807,7 +1850,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelBatchPredictionJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'CancelBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1827,15 +1874,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateModelDeploymentMonitoringJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateModelDeploymentMonitoringJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob() ); @@ -1845,11 +1889,14 @@ describe('v1.JobServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createModelDeploymentMonitoringJob without error using callback', async () => { @@ -1861,15 +1908,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateModelDeploymentMonitoringJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateModelDeploymentMonitoringJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob() ); @@ -1892,11 +1936,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createModelDeploymentMonitoringJob with error', async () => { @@ -1908,15 +1955,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateModelDeploymentMonitoringJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateModelDeploymentMonitoringJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createModelDeploymentMonitoringJob = stubSimpleCall( undefined, @@ -1926,11 +1970,14 @@ describe('v1.JobServiceClient', () => { client.createModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createModelDeploymentMonitoringJob with closed client', async () => { @@ -1942,7 +1989,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateModelDeploymentMonitoringJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateModelDeploymentMonitoringJobRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1962,15 +2013,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob() ); @@ -1978,11 +2026,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getModelDeploymentMonitoringJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelDeploymentMonitoringJob without error using callback', async () => { @@ -1992,17 +2043,14 @@ describe('v1.JobServiceClient', () => { }); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.aiplatform.v1.GetModelDeploymentMonitoringJobRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + new protos.google.cloud.aiplatform.v1.GetModelDeploymentMonitoringJobRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'GetModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob() ); @@ -2025,11 +2073,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelDeploymentMonitoringJob with error', async () => { @@ -2041,15 +2092,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getModelDeploymentMonitoringJob = stubSimpleCall( undefined, @@ -2059,11 +2107,14 @@ describe('v1.JobServiceClient', () => { client.getModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelDeploymentMonitoringJob with closed client', async () => { @@ -2075,7 +2126,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelDeploymentMonitoringJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2095,15 +2150,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PauseModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -2113,11 +2165,14 @@ describe('v1.JobServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseModelDeploymentMonitoringJob without error using callback', async () => { @@ -2129,15 +2184,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PauseModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -2160,11 +2212,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseModelDeploymentMonitoringJob with error', async () => { @@ -2176,15 +2231,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PauseModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.pauseModelDeploymentMonitoringJob = stubSimpleCall( undefined, @@ -2194,11 +2246,14 @@ describe('v1.JobServiceClient', () => { client.pauseModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseModelDeploymentMonitoringJob with closed client', async () => { @@ -2210,7 +2265,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PauseModelDeploymentMonitoringJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'PauseModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2230,15 +2289,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ResumeModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -2248,11 +2304,14 @@ describe('v1.JobServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeModelDeploymentMonitoringJob without error using callback', async () => { @@ -2264,15 +2323,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ResumeModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -2295,11 +2351,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeModelDeploymentMonitoringJob with error', async () => { @@ -2311,15 +2370,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ResumeModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.resumeModelDeploymentMonitoringJob = stubSimpleCall( undefined, @@ -2329,11 +2385,14 @@ describe('v1.JobServiceClient', () => { client.resumeModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeModelDeploymentMonitoringJob with closed client', async () => { @@ -2345,7 +2404,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ResumeModelDeploymentMonitoringJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'ResumeModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2365,15 +2428,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2382,11 +2441,14 @@ describe('v1.JobServiceClient', () => { const [operation] = await client.deleteCustomJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomJob without error using callback', async () => { @@ -2398,15 +2460,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2436,11 +2494,14 @@ describe('v1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomJob with call error', async () => { @@ -2452,26 +2513,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteCustomJob = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteCustomJob(request), expectedError); - assert( - (client.innerApiCalls.deleteCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomJob with LRO error', async () => { @@ -2483,15 +2543,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteCustomJob = stubLongRunningCall( undefined, @@ -2500,11 +2556,14 @@ describe('v1.JobServiceClient', () => { ); const [operation] = await client.deleteCustomJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteCustomJobProgress without error', async () => { @@ -2559,15 +2618,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2576,11 +2632,14 @@ describe('v1.JobServiceClient', () => { const [operation] = await client.deleteDataLabelingJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataLabelingJob without error using callback', async () => { @@ -2592,15 +2651,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2630,11 +2686,14 @@ describe('v1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataLabelingJob with call error', async () => { @@ -2646,15 +2705,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDataLabelingJob = stubLongRunningCall( undefined, @@ -2664,11 +2720,14 @@ describe('v1.JobServiceClient', () => { client.deleteDataLabelingJob(request), expectedError ); - assert( - (client.innerApiCalls.deleteDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataLabelingJob with LRO error', async () => { @@ -2680,15 +2739,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDataLabelingJob = stubLongRunningCall( undefined, @@ -2697,11 +2753,14 @@ describe('v1.JobServiceClient', () => { ); const [operation] = await client.deleteDataLabelingJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteDataLabelingJobProgress without error', async () => { @@ -2756,15 +2815,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2773,11 +2829,14 @@ describe('v1.JobServiceClient', () => { const [operation] = await client.deleteHyperparameterTuningJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteHyperparameterTuningJob without error using callback', async () => { @@ -2789,15 +2848,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2827,11 +2883,14 @@ describe('v1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteHyperparameterTuningJob with call error', async () => { @@ -2843,15 +2902,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteHyperparameterTuningJob = stubLongRunningCall( undefined, @@ -2861,11 +2917,14 @@ describe('v1.JobServiceClient', () => { client.deleteHyperparameterTuningJob(request), expectedError ); - assert( - (client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteHyperparameterTuningJob with LRO error', async () => { @@ -2877,15 +2936,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteHyperparameterTuningJob = stubLongRunningCall( undefined, @@ -2894,11 +2950,14 @@ describe('v1.JobServiceClient', () => { ); const [operation] = await client.deleteHyperparameterTuningJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteHyperparameterTuningJobProgress without error', async () => { @@ -2954,15 +3013,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2971,11 +3027,14 @@ describe('v1.JobServiceClient', () => { const [operation] = await client.deleteBatchPredictionJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBatchPredictionJob without error using callback', async () => { @@ -2987,15 +3046,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3025,11 +3081,14 @@ describe('v1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBatchPredictionJob with call error', async () => { @@ -3041,15 +3100,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteBatchPredictionJob = stubLongRunningCall( undefined, @@ -3059,11 +3115,14 @@ describe('v1.JobServiceClient', () => { client.deleteBatchPredictionJob(request), expectedError ); - assert( - (client.innerApiCalls.deleteBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBatchPredictionJob with LRO error', async () => { @@ -3075,15 +3134,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteBatchPredictionJob = stubLongRunningCall( undefined, @@ -3092,11 +3148,14 @@ describe('v1.JobServiceClient', () => { ); const [operation] = await client.deleteBatchPredictionJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteBatchPredictionJobProgress without error', async () => { @@ -3152,17 +3211,13 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateModelDeploymentMonitoringJobRequest() ); - request.modelDeploymentMonitoringJob = {}; - request.modelDeploymentMonitoringJob.name = ''; - const expectedHeaderRequestParams = - 'model_deployment_monitoring_job.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.modelDeploymentMonitoringJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateModelDeploymentMonitoringJobRequest', + ['modelDeploymentMonitoringJob', 'name'] + ); + request.modelDeploymentMonitoringJob.name = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3173,11 +3228,14 @@ describe('v1.JobServiceClient', () => { ); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModelDeploymentMonitoringJob without error using callback', async () => { @@ -3189,17 +3247,13 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateModelDeploymentMonitoringJobRequest() ); - request.modelDeploymentMonitoringJob = {}; - request.modelDeploymentMonitoringJob.name = ''; - const expectedHeaderRequestParams = - 'model_deployment_monitoring_job.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.modelDeploymentMonitoringJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateModelDeploymentMonitoringJobRequest', + ['modelDeploymentMonitoringJob', 'name'] + ); + request.modelDeploymentMonitoringJob.name = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3229,11 +3283,14 @@ describe('v1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModelDeploymentMonitoringJob with call error', async () => { @@ -3245,17 +3302,13 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateModelDeploymentMonitoringJobRequest() ); - request.modelDeploymentMonitoringJob = {}; - request.modelDeploymentMonitoringJob.name = ''; - const expectedHeaderRequestParams = - 'model_deployment_monitoring_job.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.modelDeploymentMonitoringJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateModelDeploymentMonitoringJobRequest', + ['modelDeploymentMonitoringJob', 'name'] + ); + request.modelDeploymentMonitoringJob.name = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateModelDeploymentMonitoringJob = stubLongRunningCall(undefined, expectedError); @@ -3263,11 +3316,14 @@ describe('v1.JobServiceClient', () => { client.updateModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModelDeploymentMonitoringJob with LRO error', async () => { @@ -3279,17 +3335,13 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateModelDeploymentMonitoringJobRequest() ); - request.modelDeploymentMonitoringJob = {}; - request.modelDeploymentMonitoringJob.name = ''; - const expectedHeaderRequestParams = - 'model_deployment_monitoring_job.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.modelDeploymentMonitoringJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateModelDeploymentMonitoringJobRequest', + ['modelDeploymentMonitoringJob', 'name'] + ); + request.modelDeploymentMonitoringJob.name = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateModelDeploymentMonitoringJob = stubLongRunningCall(undefined, undefined, expectedError); @@ -3297,11 +3349,14 @@ describe('v1.JobServiceClient', () => { request ); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateModelDeploymentMonitoringJobProgress without error', async () => { @@ -3357,15 +3412,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3376,11 +3428,14 @@ describe('v1.JobServiceClient', () => { ); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelDeploymentMonitoringJob without error using callback', async () => { @@ -3392,15 +3447,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3430,11 +3482,14 @@ describe('v1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelDeploymentMonitoringJob with call error', async () => { @@ -3446,15 +3501,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModelDeploymentMonitoringJob = stubLongRunningCall(undefined, expectedError); @@ -3462,11 +3514,14 @@ describe('v1.JobServiceClient', () => { client.deleteModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelDeploymentMonitoringJob with LRO error', async () => { @@ -3478,15 +3533,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModelDeploymentMonitoringJob = stubLongRunningCall(undefined, undefined, expectedError); @@ -3494,11 +3546,14 @@ describe('v1.JobServiceClient', () => { request ); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteModelDeploymentMonitoringJobProgress without error', async () => { @@ -3554,15 +3609,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.CustomJob() @@ -3577,11 +3628,14 @@ describe('v1.JobServiceClient', () => { client.innerApiCalls.listCustomJobs = stubSimpleCall(expectedResponse); const [response] = await client.listCustomJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listCustomJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomJobs without error using callback', async () => { @@ -3593,15 +3647,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.CustomJob() @@ -3632,11 +3682,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listCustomJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomJobs with error', async () => { @@ -3648,26 +3701,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listCustomJobs = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listCustomJobs(request), expectedError); - assert( - (client.innerApiCalls.listCustomJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomJobsStream without error', async () => { @@ -3679,8 +3731,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.CustomJob() @@ -3717,11 +3772,12 @@ describe('v1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listCustomJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listCustomJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3734,8 +3790,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listCustomJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3761,11 +3820,12 @@ describe('v1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listCustomJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listCustomJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3778,8 +3838,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.CustomJob() @@ -3805,11 +3868,12 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listCustomJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3822,8 +3886,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listCustomJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3840,11 +3907,12 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listCustomJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3859,15 +3927,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.DataLabelingJob() @@ -3883,11 +3947,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listDataLabelingJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDataLabelingJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataLabelingJobs without error using callback', async () => { @@ -3899,15 +3966,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.DataLabelingJob() @@ -3938,11 +4001,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDataLabelingJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataLabelingJobs with error', async () => { @@ -3954,26 +4020,25 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDataLabelingJobs = stubSimpleCall( undefined, - expectedError - ); - await assert.rejects(client.listDataLabelingJobs(request), expectedError); - assert( - (client.innerApiCalls.listDataLabelingJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) + expectedError ); + await assert.rejects(client.listDataLabelingJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataLabelingJobsStream without error', async () => { @@ -3985,8 +4050,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.DataLabelingJob() @@ -4024,11 +4092,12 @@ describe('v1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDataLabelingJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDataLabelingJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataLabelingJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4041,8 +4110,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDataLabelingJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4069,11 +4141,12 @@ describe('v1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDataLabelingJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDataLabelingJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataLabelingJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4086,8 +4159,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.DataLabelingJob() @@ -4114,11 +4190,12 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDataLabelingJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataLabelingJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4131,8 +4208,11 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDataLabelingJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4150,11 +4230,12 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDataLabelingJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataLabelingJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4169,15 +4250,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.HyperparameterTuningJob() @@ -4193,11 +4271,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listHyperparameterTuningJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listHyperparameterTuningJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listHyperparameterTuningJobs without error using callback', async () => { @@ -4209,15 +4290,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.HyperparameterTuningJob() @@ -4250,11 +4328,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listHyperparameterTuningJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listHyperparameterTuningJobs with error', async () => { @@ -4266,15 +4347,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listHyperparameterTuningJobs = stubSimpleCall( undefined, @@ -4284,11 +4362,14 @@ describe('v1.JobServiceClient', () => { client.listHyperparameterTuningJobs(request), expectedError ); - assert( - (client.innerApiCalls.listHyperparameterTuningJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listHyperparameterTuningJobsStream without error', async () => { @@ -4300,8 +4381,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.HyperparameterTuningJob() @@ -4347,12 +4432,15 @@ describe('v1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.listHyperparameterTuningJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4365,8 +4453,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listHyperparameterTuningJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4401,12 +4493,15 @@ describe('v1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.listHyperparameterTuningJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4419,8 +4514,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.HyperparameterTuningJob() @@ -4448,12 +4547,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listHyperparameterTuningJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4466,8 +4568,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listHyperparameterTuningJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4486,12 +4592,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listHyperparameterTuningJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4506,15 +4615,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchPredictionJob() @@ -4530,11 +4636,14 @@ describe('v1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listBatchPredictionJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listBatchPredictionJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBatchPredictionJobs without error using callback', async () => { @@ -4546,15 +4655,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchPredictionJob() @@ -4587,11 +4693,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listBatchPredictionJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBatchPredictionJobs with error', async () => { @@ -4603,15 +4712,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listBatchPredictionJobs = stubSimpleCall( undefined, @@ -4621,11 +4727,14 @@ describe('v1.JobServiceClient', () => { client.listBatchPredictionJobs(request), expectedError ); - assert( - (client.innerApiCalls.listBatchPredictionJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBatchPredictionJobsStream without error', async () => { @@ -4637,8 +4746,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchPredictionJob() @@ -4679,12 +4792,15 @@ describe('v1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listBatchPredictionJobs, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listBatchPredictionJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4697,8 +4813,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listBatchPredictionJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4728,12 +4848,15 @@ describe('v1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listBatchPredictionJobs, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listBatchPredictionJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4746,8 +4869,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchPredictionJob() @@ -4775,12 +4902,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listBatchPredictionJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4793,8 +4923,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listBatchPredictionJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4813,12 +4947,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listBatchPredictionJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4833,15 +4970,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelMonitoringStatsAnomalies() @@ -4858,14 +4992,16 @@ describe('v1.JobServiceClient', () => { const [response] = await client.searchModelDeploymentMonitoringStatsAnomalies(request); assert.deepStrictEqual(response, expectedResponse); - assert( - ( - client.innerApiCalls - .searchModelDeploymentMonitoringStatsAnomalies as SinonStub - ) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchModelDeploymentMonitoringStatsAnomalies without error using callback', async () => { @@ -4877,15 +5013,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelMonitoringStatsAnomalies() @@ -4918,14 +5051,16 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - ( - client.innerApiCalls - .searchModelDeploymentMonitoringStatsAnomalies as SinonStub - ) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchModelDeploymentMonitoringStatsAnomalies with error', async () => { @@ -4937,15 +5072,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.searchModelDeploymentMonitoringStatsAnomalies = stubSimpleCall(undefined, expectedError); @@ -4953,14 +5085,16 @@ describe('v1.JobServiceClient', () => { client.searchModelDeploymentMonitoringStatsAnomalies(request), expectedError ); - assert( - ( - client.innerApiCalls - .searchModelDeploymentMonitoringStatsAnomalies as SinonStub - ) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchModelDeploymentMonitoringStatsAnomaliesStream without error', async () => { @@ -4972,8 +5106,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelMonitoringStatsAnomalies() @@ -5020,12 +5158,15 @@ describe('v1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5038,8 +5179,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5075,12 +5220,15 @@ describe('v1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5093,8 +5241,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelMonitoringStatsAnomalies() @@ -5123,12 +5275,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5141,8 +5296,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5162,12 +5321,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5182,15 +5344,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob() @@ -5208,11 +5367,14 @@ describe('v1.JobServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelDeploymentMonitoringJobs without error using callback', async () => { @@ -5224,15 +5386,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob() @@ -5265,11 +5424,14 @@ describe('v1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelDeploymentMonitoringJobs with error', async () => { @@ -5281,15 +5443,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModelDeploymentMonitoringJobs = stubSimpleCall( undefined, @@ -5299,11 +5458,14 @@ describe('v1.JobServiceClient', () => { client.listModelDeploymentMonitoringJobs(request), expectedError ); - assert( - (client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelDeploymentMonitoringJobsStream without error', async () => { @@ -5315,8 +5477,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob() @@ -5362,12 +5528,15 @@ describe('v1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelDeploymentMonitoringJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5380,8 +5549,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelDeploymentMonitoringJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5416,12 +5589,15 @@ describe('v1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelDeploymentMonitoringJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5434,8 +5610,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelDeploymentMonitoringJob() @@ -5463,12 +5643,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelDeploymentMonitoringJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5481,8 +5664,12 @@ describe('v1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelDeploymentMonitoringJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5501,12 +5688,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelDeploymentMonitoringJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5981,12 +6171,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -6017,12 +6210,15 @@ describe('v1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_job_service_v1beta1.ts b/test/gapic_job_service_v1beta1.ts index 5f34fd22..b2ac2581 100644 --- a/test/gapic_job_service_v1beta1.ts +++ b/test/gapic_job_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -258,26 +273,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateCustomJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CustomJob() ); client.innerApiCalls.createCustomJob = stubSimpleCall(expectedResponse); const [response] = await client.createCustomJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomJob without error using callback', async () => { @@ -289,15 +303,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateCustomJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CustomJob() ); @@ -320,11 +330,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomJob with error', async () => { @@ -336,26 +349,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateCustomJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateCustomJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createCustomJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createCustomJob(request), expectedError); - assert( - (client.innerApiCalls.createCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createCustomJob with closed client', async () => { @@ -367,7 +379,10 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateCustomJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateCustomJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createCustomJob(request), expectedError); @@ -384,26 +399,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CustomJob() ); client.innerApiCalls.getCustomJob = stubSimpleCall(expectedResponse); const [response] = await client.getCustomJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomJob without error using callback', async () => { @@ -415,15 +429,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CustomJob() ); @@ -446,11 +456,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomJob with error', async () => { @@ -462,26 +475,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getCustomJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getCustomJob(request), expectedError); - assert( - (client.innerApiCalls.getCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getCustomJob with closed client', async () => { @@ -493,7 +505,10 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetCustomJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getCustomJob(request), expectedError); @@ -510,26 +525,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.cancelCustomJob = stubSimpleCall(expectedResponse); const [response] = await client.cancelCustomJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelCustomJob without error using callback', async () => { @@ -541,15 +555,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -572,11 +582,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelCustomJob with error', async () => { @@ -588,26 +601,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelCustomJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.cancelCustomJob(request), expectedError); - assert( - (client.innerApiCalls.cancelCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelCustomJob with closed client', async () => { @@ -619,7 +631,10 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelCustomJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('CancelCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.cancelCustomJob(request), expectedError); @@ -636,15 +651,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDataLabelingJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDataLabelingJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataLabelingJob() ); @@ -652,11 +664,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createDataLabelingJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataLabelingJob without error using callback', async () => { @@ -668,15 +683,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDataLabelingJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDataLabelingJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataLabelingJob() ); @@ -699,11 +711,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataLabelingJob with error', async () => { @@ -715,15 +730,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDataLabelingJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateDataLabelingJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createDataLabelingJob = stubSimpleCall( undefined, @@ -733,11 +745,14 @@ describe('v1beta1.JobServiceClient', () => { client.createDataLabelingJob(request), expectedError ); - assert( - (client.innerApiCalls.createDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createDataLabelingJob with closed client', async () => { @@ -749,7 +764,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateDataLabelingJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateDataLabelingJobRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -769,15 +788,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDataLabelingJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataLabelingJob() ); @@ -785,11 +800,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getDataLabelingJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataLabelingJob without error using callback', async () => { @@ -801,15 +819,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDataLabelingJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataLabelingJob() ); @@ -832,11 +846,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataLabelingJob with error', async () => { @@ -848,26 +865,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetDataLabelingJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getDataLabelingJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getDataLabelingJob(request), expectedError); - assert( - (client.innerApiCalls.getDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getDataLabelingJob with closed client', async () => { @@ -879,7 +895,10 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetDataLabelingJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetDataLabelingJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getDataLabelingJob(request), expectedError); @@ -896,15 +915,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -912,11 +928,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.cancelDataLabelingJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelDataLabelingJob without error using callback', async () => { @@ -928,15 +947,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -959,11 +975,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelDataLabelingJob with error', async () => { @@ -975,15 +994,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelDataLabelingJob = stubSimpleCall( undefined, @@ -993,11 +1009,14 @@ describe('v1beta1.JobServiceClient', () => { client.cancelDataLabelingJob(request), expectedError ); - assert( - (client.innerApiCalls.cancelDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelDataLabelingJob with closed client', async () => { @@ -1009,7 +1028,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelDataLabelingJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'CancelDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1029,15 +1052,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateHyperparameterTuningJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateHyperparameterTuningJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob() ); @@ -1045,11 +1065,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createHyperparameterTuningJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createHyperparameterTuningJob without error using callback', async () => { @@ -1061,15 +1084,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateHyperparameterTuningJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateHyperparameterTuningJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob() ); @@ -1092,11 +1112,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createHyperparameterTuningJob with error', async () => { @@ -1108,15 +1131,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateHyperparameterTuningJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateHyperparameterTuningJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createHyperparameterTuningJob = stubSimpleCall( undefined, @@ -1126,11 +1146,14 @@ describe('v1beta1.JobServiceClient', () => { client.createHyperparameterTuningJob(request), expectedError ); - assert( - (client.innerApiCalls.createHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createHyperparameterTuningJob with closed client', async () => { @@ -1142,7 +1165,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateHyperparameterTuningJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateHyperparameterTuningJobRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1162,15 +1189,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob() ); @@ -1178,11 +1202,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getHyperparameterTuningJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getHyperparameterTuningJob without error using callback', async () => { @@ -1194,15 +1221,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob() ); @@ -1225,11 +1249,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getHyperparameterTuningJob with error', async () => { @@ -1241,15 +1268,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getHyperparameterTuningJob = stubSimpleCall( undefined, @@ -1259,11 +1283,14 @@ describe('v1beta1.JobServiceClient', () => { client.getHyperparameterTuningJob(request), expectedError ); - assert( - (client.innerApiCalls.getHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getHyperparameterTuningJob with closed client', async () => { @@ -1275,7 +1302,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetHyperparameterTuningJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1295,15 +1326,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1311,11 +1339,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.cancelHyperparameterTuningJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelHyperparameterTuningJob without error using callback', async () => { @@ -1327,15 +1358,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1358,11 +1386,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelHyperparameterTuningJob with error', async () => { @@ -1374,15 +1405,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelHyperparameterTuningJob = stubSimpleCall( undefined, @@ -1392,11 +1420,14 @@ describe('v1beta1.JobServiceClient', () => { client.cancelHyperparameterTuningJob(request), expectedError ); - assert( - (client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelHyperparameterTuningJob with closed client', async () => { @@ -1408,7 +1439,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelHyperparameterTuningJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'CancelHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1428,15 +1463,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateBatchPredictionJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateBatchPredictionJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchPredictionJob() ); @@ -1444,11 +1476,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createBatchPredictionJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBatchPredictionJob without error using callback', async () => { @@ -1460,15 +1495,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateBatchPredictionJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateBatchPredictionJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchPredictionJob() ); @@ -1491,11 +1523,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBatchPredictionJob with error', async () => { @@ -1507,15 +1542,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateBatchPredictionJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateBatchPredictionJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createBatchPredictionJob = stubSimpleCall( undefined, @@ -1525,11 +1557,14 @@ describe('v1beta1.JobServiceClient', () => { client.createBatchPredictionJob(request), expectedError ); - assert( - (client.innerApiCalls.createBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createBatchPredictionJob with closed client', async () => { @@ -1541,7 +1576,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateBatchPredictionJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateBatchPredictionJobRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1561,15 +1600,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchPredictionJob() ); @@ -1577,11 +1613,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getBatchPredictionJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBatchPredictionJob without error using callback', async () => { @@ -1593,15 +1632,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchPredictionJob() ); @@ -1624,11 +1660,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBatchPredictionJob with error', async () => { @@ -1640,15 +1679,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getBatchPredictionJob = stubSimpleCall( undefined, @@ -1658,11 +1694,14 @@ describe('v1beta1.JobServiceClient', () => { client.getBatchPredictionJob(request), expectedError ); - assert( - (client.innerApiCalls.getBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getBatchPredictionJob with closed client', async () => { @@ -1674,7 +1713,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetBatchPredictionJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1694,15 +1737,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1710,11 +1750,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.cancelBatchPredictionJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelBatchPredictionJob without error using callback', async () => { @@ -1726,15 +1769,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1757,11 +1797,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelBatchPredictionJob with error', async () => { @@ -1773,15 +1816,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelBatchPredictionJob = stubSimpleCall( undefined, @@ -1791,11 +1831,14 @@ describe('v1beta1.JobServiceClient', () => { client.cancelBatchPredictionJob(request), expectedError ); - assert( - (client.innerApiCalls.cancelBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelBatchPredictionJob with closed client', async () => { @@ -1807,7 +1850,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelBatchPredictionJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'CancelBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1827,15 +1874,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateModelDeploymentMonitoringJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateModelDeploymentMonitoringJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelDeploymentMonitoringJob() ); @@ -1845,11 +1889,14 @@ describe('v1beta1.JobServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createModelDeploymentMonitoringJob without error using callback', async () => { @@ -1861,15 +1908,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateModelDeploymentMonitoringJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateModelDeploymentMonitoringJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelDeploymentMonitoringJob() ); @@ -1892,11 +1936,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createModelDeploymentMonitoringJob with error', async () => { @@ -1908,15 +1955,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateModelDeploymentMonitoringJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateModelDeploymentMonitoringJobRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createModelDeploymentMonitoringJob = stubSimpleCall( undefined, @@ -1926,11 +1970,14 @@ describe('v1beta1.JobServiceClient', () => { client.createModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createModelDeploymentMonitoringJob with closed client', async () => { @@ -1942,7 +1989,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateModelDeploymentMonitoringJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateModelDeploymentMonitoringJobRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1962,15 +2013,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelDeploymentMonitoringJob() ); @@ -1978,11 +2026,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getModelDeploymentMonitoringJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelDeploymentMonitoringJob without error using callback', async () => { @@ -1992,17 +2043,14 @@ describe('v1beta1.JobServiceClient', () => { }); client.initialize(); const request = generateSampleMessage( - new protos.google.cloud.aiplatform.v1beta1.GetModelDeploymentMonitoringJobRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + new protos.google.cloud.aiplatform.v1beta1.GetModelDeploymentMonitoringJobRequest() + ); + const defaultValue1 = getTypeDefaultValue( + 'GetModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelDeploymentMonitoringJob() ); @@ -2025,11 +2073,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelDeploymentMonitoringJob with error', async () => { @@ -2041,15 +2092,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getModelDeploymentMonitoringJob = stubSimpleCall( undefined, @@ -2059,11 +2107,14 @@ describe('v1beta1.JobServiceClient', () => { client.getModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelDeploymentMonitoringJob with closed client', async () => { @@ -2075,7 +2126,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelDeploymentMonitoringJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2095,15 +2150,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PauseModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -2113,11 +2165,14 @@ describe('v1beta1.JobServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseModelDeploymentMonitoringJob without error using callback', async () => { @@ -2129,15 +2184,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PauseModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -2160,11 +2212,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseModelDeploymentMonitoringJob with error', async () => { @@ -2176,15 +2231,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PauseModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'PauseModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.pauseModelDeploymentMonitoringJob = stubSimpleCall( undefined, @@ -2194,11 +2246,14 @@ describe('v1beta1.JobServiceClient', () => { client.pauseModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes pauseModelDeploymentMonitoringJob with closed client', async () => { @@ -2210,7 +2265,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PauseModelDeploymentMonitoringJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'PauseModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2230,15 +2289,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ResumeModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -2248,11 +2304,14 @@ describe('v1beta1.JobServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeModelDeploymentMonitoringJob without error using callback', async () => { @@ -2264,15 +2323,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ResumeModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -2295,11 +2351,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeModelDeploymentMonitoringJob with error', async () => { @@ -2311,15 +2370,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ResumeModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ResumeModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.resumeModelDeploymentMonitoringJob = stubSimpleCall( undefined, @@ -2329,11 +2385,14 @@ describe('v1beta1.JobServiceClient', () => { client.resumeModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes resumeModelDeploymentMonitoringJob with closed client', async () => { @@ -2345,7 +2404,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ResumeModelDeploymentMonitoringJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'ResumeModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2365,15 +2428,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2382,11 +2441,14 @@ describe('v1beta1.JobServiceClient', () => { const [operation] = await client.deleteCustomJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomJob without error using callback', async () => { @@ -2398,15 +2460,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2436,11 +2494,14 @@ describe('v1beta1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomJob with call error', async () => { @@ -2452,26 +2513,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteCustomJob = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteCustomJob(request), expectedError); - assert( - (client.innerApiCalls.deleteCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteCustomJob with LRO error', async () => { @@ -2483,15 +2543,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteCustomJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteCustomJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteCustomJob = stubLongRunningCall( undefined, @@ -2500,11 +2556,14 @@ describe('v1beta1.JobServiceClient', () => { ); const [operation] = await client.deleteCustomJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteCustomJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteCustomJobProgress without error', async () => { @@ -2559,15 +2618,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2576,11 +2632,14 @@ describe('v1beta1.JobServiceClient', () => { const [operation] = await client.deleteDataLabelingJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataLabelingJob without error using callback', async () => { @@ -2592,15 +2651,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2630,11 +2686,14 @@ describe('v1beta1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataLabelingJob with call error', async () => { @@ -2646,15 +2705,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDataLabelingJob = stubLongRunningCall( undefined, @@ -2664,11 +2720,14 @@ describe('v1beta1.JobServiceClient', () => { client.deleteDataLabelingJob(request), expectedError ); - assert( - (client.innerApiCalls.deleteDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteDataLabelingJob with LRO error', async () => { @@ -2680,15 +2739,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteDataLabelingJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteDataLabelingJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteDataLabelingJob = stubLongRunningCall( undefined, @@ -2697,11 +2753,14 @@ describe('v1beta1.JobServiceClient', () => { ); const [operation] = await client.deleteDataLabelingJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteDataLabelingJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDataLabelingJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteDataLabelingJobProgress without error', async () => { @@ -2756,15 +2815,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2773,11 +2829,14 @@ describe('v1beta1.JobServiceClient', () => { const [operation] = await client.deleteHyperparameterTuningJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteHyperparameterTuningJob without error using callback', async () => { @@ -2789,15 +2848,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2827,11 +2883,14 @@ describe('v1beta1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteHyperparameterTuningJob with call error', async () => { @@ -2843,15 +2902,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteHyperparameterTuningJob = stubLongRunningCall( undefined, @@ -2861,11 +2917,14 @@ describe('v1beta1.JobServiceClient', () => { client.deleteHyperparameterTuningJob(request), expectedError ); - assert( - (client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteHyperparameterTuningJob with LRO error', async () => { @@ -2877,15 +2936,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteHyperparameterTuningJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteHyperparameterTuningJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteHyperparameterTuningJob = stubLongRunningCall( undefined, @@ -2894,11 +2950,14 @@ describe('v1beta1.JobServiceClient', () => { ); const [operation] = await client.deleteHyperparameterTuningJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteHyperparameterTuningJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteHyperparameterTuningJobProgress without error', async () => { @@ -2954,15 +3013,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2971,11 +3027,14 @@ describe('v1beta1.JobServiceClient', () => { const [operation] = await client.deleteBatchPredictionJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBatchPredictionJob without error using callback', async () => { @@ -2987,15 +3046,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3025,11 +3081,14 @@ describe('v1beta1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBatchPredictionJob with call error', async () => { @@ -3041,15 +3100,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteBatchPredictionJob = stubLongRunningCall( undefined, @@ -3059,11 +3115,14 @@ describe('v1beta1.JobServiceClient', () => { client.deleteBatchPredictionJob(request), expectedError ); - assert( - (client.innerApiCalls.deleteBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteBatchPredictionJob with LRO error', async () => { @@ -3075,15 +3134,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteBatchPredictionJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteBatchPredictionJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteBatchPredictionJob = stubLongRunningCall( undefined, @@ -3092,11 +3148,14 @@ describe('v1beta1.JobServiceClient', () => { ); const [operation] = await client.deleteBatchPredictionJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteBatchPredictionJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteBatchPredictionJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteBatchPredictionJobProgress without error', async () => { @@ -3152,17 +3211,13 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateModelDeploymentMonitoringJobRequest() ); - request.modelDeploymentMonitoringJob = {}; - request.modelDeploymentMonitoringJob.name = ''; - const expectedHeaderRequestParams = - 'model_deployment_monitoring_job.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.modelDeploymentMonitoringJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateModelDeploymentMonitoringJobRequest', + ['modelDeploymentMonitoringJob', 'name'] + ); + request.modelDeploymentMonitoringJob.name = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3173,11 +3228,14 @@ describe('v1beta1.JobServiceClient', () => { ); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModelDeploymentMonitoringJob without error using callback', async () => { @@ -3189,17 +3247,13 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateModelDeploymentMonitoringJobRequest() ); - request.modelDeploymentMonitoringJob = {}; - request.modelDeploymentMonitoringJob.name = ''; - const expectedHeaderRequestParams = - 'model_deployment_monitoring_job.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.modelDeploymentMonitoringJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateModelDeploymentMonitoringJobRequest', + ['modelDeploymentMonitoringJob', 'name'] + ); + request.modelDeploymentMonitoringJob.name = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3229,11 +3283,14 @@ describe('v1beta1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModelDeploymentMonitoringJob with call error', async () => { @@ -3245,17 +3302,13 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateModelDeploymentMonitoringJobRequest() ); - request.modelDeploymentMonitoringJob = {}; - request.modelDeploymentMonitoringJob.name = ''; - const expectedHeaderRequestParams = - 'model_deployment_monitoring_job.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.modelDeploymentMonitoringJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateModelDeploymentMonitoringJobRequest', + ['modelDeploymentMonitoringJob', 'name'] + ); + request.modelDeploymentMonitoringJob.name = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateModelDeploymentMonitoringJob = stubLongRunningCall(undefined, expectedError); @@ -3263,11 +3316,14 @@ describe('v1beta1.JobServiceClient', () => { client.updateModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModelDeploymentMonitoringJob with LRO error', async () => { @@ -3279,17 +3335,13 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateModelDeploymentMonitoringJobRequest() ); - request.modelDeploymentMonitoringJob = {}; - request.modelDeploymentMonitoringJob.name = ''; - const expectedHeaderRequestParams = - 'model_deployment_monitoring_job.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.modelDeploymentMonitoringJob ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateModelDeploymentMonitoringJobRequest', + ['modelDeploymentMonitoringJob', 'name'] + ); + request.modelDeploymentMonitoringJob.name = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateModelDeploymentMonitoringJob = stubLongRunningCall(undefined, undefined, expectedError); @@ -3297,11 +3349,14 @@ describe('v1beta1.JobServiceClient', () => { request ); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateModelDeploymentMonitoringJobProgress without error', async () => { @@ -3357,15 +3412,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3376,11 +3428,14 @@ describe('v1beta1.JobServiceClient', () => { ); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelDeploymentMonitoringJob without error using callback', async () => { @@ -3392,15 +3447,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3430,11 +3482,14 @@ describe('v1beta1.JobServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelDeploymentMonitoringJob with call error', async () => { @@ -3446,15 +3501,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModelDeploymentMonitoringJob = stubLongRunningCall(undefined, expectedError); @@ -3462,11 +3514,14 @@ describe('v1beta1.JobServiceClient', () => { client.deleteModelDeploymentMonitoringJob(request), expectedError ); - assert( - (client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelDeploymentMonitoringJob with LRO error', async () => { @@ -3478,15 +3533,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelDeploymentMonitoringJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteModelDeploymentMonitoringJobRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModelDeploymentMonitoringJob = stubLongRunningCall(undefined, undefined, expectedError); @@ -3494,11 +3546,14 @@ describe('v1beta1.JobServiceClient', () => { request ); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelDeploymentMonitoringJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteModelDeploymentMonitoringJobProgress without error', async () => { @@ -3554,15 +3609,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CustomJob() @@ -3577,11 +3628,14 @@ describe('v1beta1.JobServiceClient', () => { client.innerApiCalls.listCustomJobs = stubSimpleCall(expectedResponse); const [response] = await client.listCustomJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listCustomJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomJobs without error using callback', async () => { @@ -3593,15 +3647,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CustomJob() @@ -3632,11 +3682,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listCustomJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomJobs with error', async () => { @@ -3648,26 +3701,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listCustomJobs = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listCustomJobs(request), expectedError); - assert( - (client.innerApiCalls.listCustomJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listCustomJobsStream without error', async () => { @@ -3679,8 +3731,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CustomJob() @@ -3718,11 +3773,12 @@ describe('v1beta1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listCustomJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listCustomJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3735,8 +3791,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listCustomJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3763,11 +3822,12 @@ describe('v1beta1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listCustomJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listCustomJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3780,8 +3840,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CustomJob() @@ -3807,11 +3870,12 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listCustomJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3824,8 +3888,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListCustomJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListCustomJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listCustomJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3843,11 +3910,12 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listCustomJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listCustomJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3862,15 +3930,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataLabelingJob() @@ -3886,11 +3950,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listDataLabelingJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDataLabelingJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataLabelingJobs without error using callback', async () => { @@ -3902,15 +3969,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataLabelingJob() @@ -3943,11 +4006,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listDataLabelingJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataLabelingJobs with error', async () => { @@ -3959,26 +4025,25 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listDataLabelingJobs = stubSimpleCall( undefined, - expectedError - ); - await assert.rejects(client.listDataLabelingJobs(request), expectedError); - assert( - (client.innerApiCalls.listDataLabelingJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) + expectedError ); + await assert.rejects(client.listDataLabelingJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDataLabelingJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listDataLabelingJobsStream without error', async () => { @@ -3990,8 +4055,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataLabelingJob() @@ -4031,11 +4099,12 @@ describe('v1beta1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDataLabelingJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDataLabelingJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataLabelingJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4048,8 +4117,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDataLabelingJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4078,11 +4150,12 @@ describe('v1beta1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listDataLabelingJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listDataLabelingJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataLabelingJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4095,8 +4168,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DataLabelingJob() @@ -4123,11 +4199,12 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDataLabelingJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataLabelingJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4140,8 +4217,11 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListDataLabelingJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListDataLabelingJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listDataLabelingJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4159,11 +4239,12 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listDataLabelingJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listDataLabelingJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4178,15 +4259,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob() @@ -4202,11 +4280,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listHyperparameterTuningJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listHyperparameterTuningJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listHyperparameterTuningJobs without error using callback', async () => { @@ -4218,15 +4299,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob() @@ -4259,11 +4337,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listHyperparameterTuningJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listHyperparameterTuningJobs with error', async () => { @@ -4275,15 +4356,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listHyperparameterTuningJobs = stubSimpleCall( undefined, @@ -4293,11 +4371,14 @@ describe('v1beta1.JobServiceClient', () => { client.listHyperparameterTuningJobs(request), expectedError ); - assert( - (client.innerApiCalls.listHyperparameterTuningJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listHyperparameterTuningJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listHyperparameterTuningJobsStream without error', async () => { @@ -4309,8 +4390,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob() @@ -4356,12 +4441,15 @@ describe('v1beta1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.listHyperparameterTuningJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4374,8 +4462,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listHyperparameterTuningJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4410,12 +4502,15 @@ describe('v1beta1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.listHyperparameterTuningJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4428,8 +4523,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob() @@ -4457,12 +4556,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listHyperparameterTuningJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4475,8 +4577,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListHyperparameterTuningJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListHyperparameterTuningJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listHyperparameterTuningJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4495,12 +4601,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listHyperparameterTuningJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4515,15 +4624,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchPredictionJob() @@ -4539,11 +4645,14 @@ describe('v1beta1.JobServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listBatchPredictionJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listBatchPredictionJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBatchPredictionJobs without error using callback', async () => { @@ -4555,15 +4664,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchPredictionJob() @@ -4596,11 +4702,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listBatchPredictionJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBatchPredictionJobs with error', async () => { @@ -4612,15 +4721,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listBatchPredictionJobs = stubSimpleCall( undefined, @@ -4630,11 +4736,14 @@ describe('v1beta1.JobServiceClient', () => { client.listBatchPredictionJobs(request), expectedError ); - assert( - (client.innerApiCalls.listBatchPredictionJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBatchPredictionJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listBatchPredictionJobsStream without error', async () => { @@ -4646,8 +4755,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchPredictionJob() @@ -4690,12 +4803,15 @@ describe('v1beta1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listBatchPredictionJobs, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listBatchPredictionJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4708,8 +4824,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listBatchPredictionJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4741,12 +4861,15 @@ describe('v1beta1.JobServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listBatchPredictionJobs, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listBatchPredictionJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4759,8 +4882,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchPredictionJob() @@ -4788,12 +4915,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listBatchPredictionJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4806,8 +4936,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListBatchPredictionJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListBatchPredictionJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listBatchPredictionJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4826,12 +4960,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listBatchPredictionJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4846,15 +4983,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelMonitoringStatsAnomalies() @@ -4871,14 +5005,16 @@ describe('v1beta1.JobServiceClient', () => { const [response] = await client.searchModelDeploymentMonitoringStatsAnomalies(request); assert.deepStrictEqual(response, expectedResponse); - assert( - ( - client.innerApiCalls - .searchModelDeploymentMonitoringStatsAnomalies as SinonStub - ) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchModelDeploymentMonitoringStatsAnomalies without error using callback', async () => { @@ -4890,15 +5026,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelMonitoringStatsAnomalies() @@ -4931,14 +5064,16 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - ( - client.innerApiCalls - .searchModelDeploymentMonitoringStatsAnomalies as SinonStub - ) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchModelDeploymentMonitoringStatsAnomalies with error', async () => { @@ -4950,15 +5085,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.searchModelDeploymentMonitoringStatsAnomalies = stubSimpleCall(undefined, expectedError); @@ -4966,14 +5098,16 @@ describe('v1beta1.JobServiceClient', () => { client.searchModelDeploymentMonitoringStatsAnomalies(request), expectedError ); - assert( - ( - client.innerApiCalls - .searchModelDeploymentMonitoringStatsAnomalies as SinonStub - ) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls + .searchModelDeploymentMonitoringStatsAnomalies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchModelDeploymentMonitoringStatsAnomaliesStream without error', async () => { @@ -4985,8 +5119,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelMonitoringStatsAnomalies() @@ -5033,12 +5171,15 @@ describe('v1beta1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5051,8 +5192,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5088,12 +5233,15 @@ describe('v1beta1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5106,8 +5254,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelMonitoringStatsAnomalies() @@ -5136,12 +5288,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5154,8 +5309,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchModelDeploymentMonitoringStatsAnomaliesRequest() ); - request.modelDeploymentMonitoringJob = ''; - const expectedHeaderRequestParams = 'model_deployment_monitoring_job='; + const defaultValue1 = getTypeDefaultValue( + 'SearchModelDeploymentMonitoringStatsAnomaliesRequest', + ['modelDeploymentMonitoringJob'] + ); + request.modelDeploymentMonitoringJob = defaultValue1; + const expectedHeaderRequestParams = `model_deployment_monitoring_job=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5175,12 +5334,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.searchModelDeploymentMonitoringStatsAnomalies .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5195,15 +5357,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelDeploymentMonitoringJob() @@ -5221,11 +5380,14 @@ describe('v1beta1.JobServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelDeploymentMonitoringJobs without error using callback', async () => { @@ -5237,15 +5399,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelDeploymentMonitoringJob() @@ -5278,11 +5437,14 @@ describe('v1beta1.JobServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelDeploymentMonitoringJobs with error', async () => { @@ -5294,15 +5456,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModelDeploymentMonitoringJobs = stubSimpleCall( undefined, @@ -5312,11 +5471,14 @@ describe('v1beta1.JobServiceClient', () => { client.listModelDeploymentMonitoringJobs(request), expectedError ); - assert( - (client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelDeploymentMonitoringJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelDeploymentMonitoringJobsStream without error', async () => { @@ -5328,8 +5490,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelDeploymentMonitoringJob() @@ -5375,12 +5541,15 @@ describe('v1beta1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelDeploymentMonitoringJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5393,8 +5562,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelDeploymentMonitoringJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5429,12 +5602,15 @@ describe('v1beta1.JobServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelDeploymentMonitoringJobs .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5447,8 +5623,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelDeploymentMonitoringJob() @@ -5476,12 +5656,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelDeploymentMonitoringJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5494,8 +5677,12 @@ describe('v1beta1.JobServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelDeploymentMonitoringJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelDeploymentMonitoringJobsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelDeploymentMonitoringJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5514,12 +5701,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelDeploymentMonitoringJobs .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5994,12 +6184,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -6030,12 +6223,15 @@ describe('v1beta1.JobServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_metadata_service_v1.ts b/test/gapic_metadata_service_v1.ts index a8215865..17f88e6c 100644 --- a/test/gapic_metadata_service_v1.ts +++ b/test/gapic_metadata_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataStore() ); client.innerApiCalls.getMetadataStore = stubSimpleCall(expectedResponse); const [response] = await client.getMetadataStore(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataStore without error using callback', async () => { @@ -291,15 +305,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataStore() ); @@ -322,11 +332,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataStore with error', async () => { @@ -338,26 +351,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getMetadataStore = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getMetadataStore(request), expectedError); - assert( - (client.innerApiCalls.getMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataStore with closed client', async () => { @@ -369,7 +381,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetMetadataStoreRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getMetadataStore(request), expectedError); @@ -386,26 +401,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateArtifactRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateArtifactRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Artifact() ); client.innerApiCalls.createArtifact = stubSimpleCall(expectedResponse); const [response] = await client.createArtifact(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createArtifact without error using callback', async () => { @@ -417,15 +431,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateArtifactRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateArtifactRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Artifact() ); @@ -448,11 +458,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createArtifact with error', async () => { @@ -464,26 +477,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateArtifactRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateArtifactRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createArtifact = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createArtifact(request), expectedError); - assert( - (client.innerApiCalls.createArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createArtifact with closed client', async () => { @@ -495,7 +507,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateArtifactRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateArtifactRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createArtifact(request), expectedError); @@ -512,26 +527,23 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetArtifactRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Artifact() ); client.innerApiCalls.getArtifact = stubSimpleCall(expectedResponse); const [response] = await client.getArtifact(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getArtifact without error using callback', async () => { @@ -543,15 +555,9 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetArtifactRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Artifact() ); @@ -574,11 +580,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getArtifact with error', async () => { @@ -590,26 +599,23 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetArtifactRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getArtifact = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getArtifact(request), expectedError); - assert( - (client.innerApiCalls.getArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getArtifact with closed client', async () => { @@ -621,7 +627,8 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetArtifactRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetArtifactRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getArtifact(request), expectedError); @@ -638,27 +645,27 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateArtifactRequest() ); - request.artifact = {}; - request.artifact.name = ''; - const expectedHeaderRequestParams = 'artifact.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.artifact ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateArtifactRequest', [ + 'artifact', + 'name', + ]); + request.artifact.name = defaultValue1; + const expectedHeaderRequestParams = `artifact.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Artifact() ); client.innerApiCalls.updateArtifact = stubSimpleCall(expectedResponse); const [response] = await client.updateArtifact(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateArtifact without error using callback', async () => { @@ -670,16 +677,13 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateArtifactRequest() ); - request.artifact = {}; - request.artifact.name = ''; - const expectedHeaderRequestParams = 'artifact.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.artifact ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateArtifactRequest', [ + 'artifact', + 'name', + ]); + request.artifact.name = defaultValue1; + const expectedHeaderRequestParams = `artifact.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Artifact() ); @@ -702,11 +706,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateArtifact with error', async () => { @@ -718,27 +725,27 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateArtifactRequest() ); - request.artifact = {}; - request.artifact.name = ''; - const expectedHeaderRequestParams = 'artifact.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.artifact ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateArtifactRequest', [ + 'artifact', + 'name', + ]); + request.artifact.name = defaultValue1; + const expectedHeaderRequestParams = `artifact.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateArtifact = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateArtifact(request), expectedError); - assert( - (client.innerApiCalls.updateArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateArtifact with closed client', async () => { @@ -750,8 +757,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateArtifactRequest() ); - request.artifact = {}; - request.artifact.name = ''; + request.artifact ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateArtifactRequest', [ + 'artifact', + 'name', + ]); + request.artifact.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateArtifact(request), expectedError); @@ -768,26 +779,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateContextRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateContextRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Context() ); client.innerApiCalls.createContext = stubSimpleCall(expectedResponse); const [response] = await client.createContext(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createContext without error using callback', async () => { @@ -799,15 +809,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateContextRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateContextRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Context() ); @@ -830,11 +836,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createContext with error', async () => { @@ -846,26 +855,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateContextRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateContextRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createContext = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createContext(request), expectedError); - assert( - (client.innerApiCalls.createContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createContext with closed client', async () => { @@ -877,7 +885,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateContextRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateContextRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createContext(request), expectedError); @@ -894,26 +905,23 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetContextRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Context() ); client.innerApiCalls.getContext = stubSimpleCall(expectedResponse); const [response] = await client.getContext(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getContext without error using callback', async () => { @@ -925,15 +933,9 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetContextRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Context() ); @@ -956,11 +958,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getContext with error', async () => { @@ -972,26 +977,23 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetContextRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getContext = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getContext(request), expectedError); - assert( - (client.innerApiCalls.getContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getContext with closed client', async () => { @@ -1003,7 +1005,8 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetContextRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetContextRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getContext(request), expectedError); @@ -1020,27 +1023,27 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateContextRequest() ); - request.context = {}; - request.context.name = ''; - const expectedHeaderRequestParams = 'context.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.context ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateContextRequest', [ + 'context', + 'name', + ]); + request.context.name = defaultValue1; + const expectedHeaderRequestParams = `context.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Context() ); client.innerApiCalls.updateContext = stubSimpleCall(expectedResponse); const [response] = await client.updateContext(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateContext without error using callback', async () => { @@ -1052,16 +1055,13 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateContextRequest() ); - request.context = {}; - request.context.name = ''; - const expectedHeaderRequestParams = 'context.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.context ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateContextRequest', [ + 'context', + 'name', + ]); + request.context.name = defaultValue1; + const expectedHeaderRequestParams = `context.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Context() ); @@ -1084,11 +1084,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateContext with error', async () => { @@ -1100,27 +1103,27 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateContextRequest() ); - request.context = {}; - request.context.name = ''; - const expectedHeaderRequestParams = 'context.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.context ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateContextRequest', [ + 'context', + 'name', + ]); + request.context.name = defaultValue1; + const expectedHeaderRequestParams = `context.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateContext = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateContext(request), expectedError); - assert( - (client.innerApiCalls.updateContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateContext with closed client', async () => { @@ -1132,8 +1135,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateContextRequest() ); - request.context = {}; - request.context.name = ''; + request.context ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateContextRequest', [ + 'context', + 'name', + ]); + request.context.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateContext(request), expectedError); @@ -1150,15 +1157,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextArtifactsAndExecutionsRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddContextArtifactsAndExecutionsRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextArtifactsAndExecutionsResponse() ); @@ -1166,11 +1170,14 @@ describe('v1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addContextArtifactsAndExecutions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextArtifactsAndExecutions without error using callback', async () => { @@ -1182,15 +1189,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextArtifactsAndExecutionsRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddContextArtifactsAndExecutionsRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextArtifactsAndExecutionsResponse() ); @@ -1213,11 +1217,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextArtifactsAndExecutions with error', async () => { @@ -1229,15 +1236,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextArtifactsAndExecutionsRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddContextArtifactsAndExecutionsRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addContextArtifactsAndExecutions = stubSimpleCall( undefined, @@ -1247,11 +1251,14 @@ describe('v1.MetadataServiceClient', () => { client.addContextArtifactsAndExecutions(request), expectedError ); - assert( - (client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextArtifactsAndExecutions with closed client', async () => { @@ -1263,7 +1270,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextArtifactsAndExecutionsRequest() ); - request.context = ''; + const defaultValue1 = getTypeDefaultValue( + 'AddContextArtifactsAndExecutionsRequest', + ['context'] + ); + request.context = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1283,15 +1294,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextChildrenRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddContextChildrenRequest', [ + 'context', + ]); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextChildrenResponse() ); @@ -1299,11 +1306,14 @@ describe('v1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addContextChildren(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addContextChildren as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextChildren without error using callback', async () => { @@ -1315,15 +1325,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextChildrenRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddContextChildrenRequest', [ + 'context', + ]); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextChildrenResponse() ); @@ -1346,11 +1352,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addContextChildren as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextChildren with error', async () => { @@ -1362,26 +1371,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextChildrenRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddContextChildrenRequest', [ + 'context', + ]); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addContextChildren = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.addContextChildren(request), expectedError); - assert( - (client.innerApiCalls.addContextChildren as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextChildren with closed client', async () => { @@ -1393,7 +1401,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddContextChildrenRequest() ); - request.context = ''; + const defaultValue1 = getTypeDefaultValue('AddContextChildrenRequest', [ + 'context', + ]); + request.context = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.addContextChildren(request), expectedError); @@ -1410,15 +1421,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryContextLineageSubgraphRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryContextLineageSubgraphRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LineageSubgraph() ); @@ -1426,11 +1434,14 @@ describe('v1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.queryContextLineageSubgraph(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryContextLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryContextLineageSubgraph without error using callback', async () => { @@ -1442,15 +1453,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryContextLineageSubgraphRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryContextLineageSubgraphRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LineageSubgraph() ); @@ -1473,11 +1481,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryContextLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryContextLineageSubgraph with error', async () => { @@ -1489,15 +1500,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryContextLineageSubgraphRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryContextLineageSubgraphRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.queryContextLineageSubgraph = stubSimpleCall( undefined, @@ -1507,11 +1515,14 @@ describe('v1.MetadataServiceClient', () => { client.queryContextLineageSubgraph(request), expectedError ); - assert( - (client.innerApiCalls.queryContextLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryContextLineageSubgraph with closed client', async () => { @@ -1523,7 +1534,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryContextLineageSubgraphRequest() ); - request.context = ''; + const defaultValue1 = getTypeDefaultValue( + 'QueryContextLineageSubgraphRequest', + ['context'] + ); + request.context = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1543,26 +1558,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateExecutionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateExecutionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() ); client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); const [response] = await client.createExecution(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createExecution without error using callback', async () => { @@ -1574,15 +1588,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateExecutionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateExecutionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() ); @@ -1605,11 +1615,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createExecution with error', async () => { @@ -1621,26 +1634,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateExecutionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateExecutionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createExecution = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createExecution(request), expectedError); - assert( - (client.innerApiCalls.createExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createExecution with closed client', async () => { @@ -1652,7 +1664,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateExecutionRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateExecutionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createExecution(request), expectedError); @@ -1669,26 +1684,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() ); client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); const [response] = await client.getExecution(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getExecution without error using callback', async () => { @@ -1700,15 +1714,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() ); @@ -1731,11 +1741,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getExecution with error', async () => { @@ -1747,26 +1760,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getExecution = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getExecution(request), expectedError); - assert( - (client.innerApiCalls.getExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getExecution with closed client', async () => { @@ -1778,7 +1790,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetExecutionRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getExecution(request), expectedError); @@ -1795,27 +1810,27 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateExecutionRequest() ); - request.execution = {}; - request.execution.name = ''; - const expectedHeaderRequestParams = 'execution.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.execution ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateExecutionRequest', [ + 'execution', + 'name', + ]); + request.execution.name = defaultValue1; + const expectedHeaderRequestParams = `execution.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() ); client.innerApiCalls.updateExecution = stubSimpleCall(expectedResponse); const [response] = await client.updateExecution(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExecution without error using callback', async () => { @@ -1827,16 +1842,13 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateExecutionRequest() ); - request.execution = {}; - request.execution.name = ''; - const expectedHeaderRequestParams = 'execution.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.execution ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateExecutionRequest', [ + 'execution', + 'name', + ]); + request.execution.name = defaultValue1; + const expectedHeaderRequestParams = `execution.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() ); @@ -1859,11 +1871,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExecution with error', async () => { @@ -1875,27 +1890,27 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateExecutionRequest() ); - request.execution = {}; - request.execution.name = ''; - const expectedHeaderRequestParams = 'execution.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.execution ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateExecutionRequest', [ + 'execution', + 'name', + ]); + request.execution.name = defaultValue1; + const expectedHeaderRequestParams = `execution.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateExecution = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateExecution(request), expectedError); - assert( - (client.innerApiCalls.updateExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExecution with closed client', async () => { @@ -1907,8 +1922,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateExecutionRequest() ); - request.execution = {}; - request.execution.name = ''; + request.execution ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateExecutionRequest', [ + 'execution', + 'name', + ]); + request.execution.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateExecution(request), expectedError); @@ -1925,15 +1944,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddExecutionEventsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddExecutionEventsRequest', [ + 'execution', + ]); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddExecutionEventsResponse() ); @@ -1941,11 +1956,14 @@ describe('v1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addExecutionEvents(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addExecutionEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addExecutionEvents without error using callback', async () => { @@ -1957,15 +1975,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddExecutionEventsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddExecutionEventsRequest', [ + 'execution', + ]); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddExecutionEventsResponse() ); @@ -1988,11 +2002,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addExecutionEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addExecutionEvents with error', async () => { @@ -2004,26 +2021,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddExecutionEventsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddExecutionEventsRequest', [ + 'execution', + ]); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addExecutionEvents = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.addExecutionEvents(request), expectedError); - assert( - (client.innerApiCalls.addExecutionEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addExecutionEvents with closed client', async () => { @@ -2035,7 +2051,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddExecutionEventsRequest() ); - request.execution = ''; + const defaultValue1 = getTypeDefaultValue('AddExecutionEventsRequest', [ + 'execution', + ]); + request.execution = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.addExecutionEvents(request), expectedError); @@ -2052,15 +2071,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryExecutionInputsAndOutputsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryExecutionInputsAndOutputsRequest', + ['execution'] + ); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LineageSubgraph() ); @@ -2068,11 +2084,14 @@ describe('v1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.queryExecutionInputsAndOutputs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryExecutionInputsAndOutputs without error using callback', async () => { @@ -2084,15 +2103,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryExecutionInputsAndOutputsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryExecutionInputsAndOutputsRequest', + ['execution'] + ); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LineageSubgraph() ); @@ -2115,11 +2131,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryExecutionInputsAndOutputs with error', async () => { @@ -2131,15 +2150,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryExecutionInputsAndOutputsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryExecutionInputsAndOutputsRequest', + ['execution'] + ); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.queryExecutionInputsAndOutputs = stubSimpleCall( undefined, @@ -2149,11 +2165,14 @@ describe('v1.MetadataServiceClient', () => { client.queryExecutionInputsAndOutputs(request), expectedError ); - assert( - (client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryExecutionInputsAndOutputs with closed client', async () => { @@ -2165,7 +2184,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryExecutionInputsAndOutputsRequest() ); - request.execution = ''; + const defaultValue1 = getTypeDefaultValue( + 'QueryExecutionInputsAndOutputsRequest', + ['execution'] + ); + request.execution = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2185,15 +2208,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateMetadataSchemaRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataSchemaRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataSchema() ); @@ -2201,11 +2220,14 @@ describe('v1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createMetadataSchema(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataSchema without error using callback', async () => { @@ -2217,15 +2239,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateMetadataSchemaRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataSchemaRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataSchema() ); @@ -2248,11 +2266,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataSchema with error', async () => { @@ -2264,26 +2285,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateMetadataSchemaRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataSchemaRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMetadataSchema = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createMetadataSchema(request), expectedError); - assert( - (client.innerApiCalls.createMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataSchema with closed client', async () => { @@ -2295,7 +2315,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateMetadataSchemaRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateMetadataSchemaRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createMetadataSchema(request), expectedError); @@ -2312,26 +2335,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetMetadataSchemaRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataSchemaRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataSchema() ); client.innerApiCalls.getMetadataSchema = stubSimpleCall(expectedResponse); const [response] = await client.getMetadataSchema(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataSchema without error using callback', async () => { @@ -2343,15 +2365,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetMetadataSchemaRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataSchemaRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataSchema() ); @@ -2374,11 +2392,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataSchema with error', async () => { @@ -2390,26 +2411,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetMetadataSchemaRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataSchemaRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getMetadataSchema = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getMetadataSchema(request), expectedError); - assert( - (client.innerApiCalls.getMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataSchema with closed client', async () => { @@ -2421,7 +2441,10 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetMetadataSchemaRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetMetadataSchemaRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getMetadataSchema(request), expectedError); @@ -2438,15 +2461,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryArtifactLineageSubgraphRequest() ); - request.artifact = ''; - const expectedHeaderRequestParams = 'artifact='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryArtifactLineageSubgraphRequest', + ['artifact'] + ); + request.artifact = defaultValue1; + const expectedHeaderRequestParams = `artifact=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LineageSubgraph() ); @@ -2454,11 +2474,14 @@ describe('v1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.queryArtifactLineageSubgraph(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryArtifactLineageSubgraph without error using callback', async () => { @@ -2470,15 +2493,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryArtifactLineageSubgraphRequest() ); - request.artifact = ''; - const expectedHeaderRequestParams = 'artifact='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryArtifactLineageSubgraphRequest', + ['artifact'] + ); + request.artifact = defaultValue1; + const expectedHeaderRequestParams = `artifact=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LineageSubgraph() ); @@ -2501,11 +2521,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryArtifactLineageSubgraph with error', async () => { @@ -2517,15 +2540,12 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryArtifactLineageSubgraphRequest() ); - request.artifact = ''; - const expectedHeaderRequestParams = 'artifact='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryArtifactLineageSubgraphRequest', + ['artifact'] + ); + request.artifact = defaultValue1; + const expectedHeaderRequestParams = `artifact=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.queryArtifactLineageSubgraph = stubSimpleCall( undefined, @@ -2535,11 +2555,14 @@ describe('v1.MetadataServiceClient', () => { client.queryArtifactLineageSubgraph(request), expectedError ); - assert( - (client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryArtifactLineageSubgraph with closed client', async () => { @@ -2551,7 +2574,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.QueryArtifactLineageSubgraphRequest() ); - request.artifact = ''; + const defaultValue1 = getTypeDefaultValue( + 'QueryArtifactLineageSubgraphRequest', + ['artifact'] + ); + request.artifact = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2571,15 +2598,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateMetadataStoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataStoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2588,11 +2611,14 @@ describe('v1.MetadataServiceClient', () => { const [operation] = await client.createMetadataStore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataStore without error using callback', async () => { @@ -2604,15 +2630,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateMetadataStoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataStoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2642,11 +2664,14 @@ describe('v1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataStore with call error', async () => { @@ -2658,26 +2683,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateMetadataStoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataStoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMetadataStore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createMetadataStore(request), expectedError); - assert( - (client.innerApiCalls.createMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataStore with LRO error', async () => { @@ -2689,15 +2713,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateMetadataStoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataStoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMetadataStore = stubLongRunningCall( undefined, @@ -2706,11 +2726,14 @@ describe('v1.MetadataServiceClient', () => { ); const [operation] = await client.createMetadataStore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateMetadataStoreProgress without error', async () => { @@ -2765,15 +2788,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2782,11 +2801,14 @@ describe('v1.MetadataServiceClient', () => { const [operation] = await client.deleteMetadataStore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMetadataStore without error using callback', async () => { @@ -2798,15 +2820,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2836,11 +2854,14 @@ describe('v1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMetadataStore with call error', async () => { @@ -2852,26 +2873,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteMetadataStore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteMetadataStore(request), expectedError); - assert( - (client.innerApiCalls.deleteMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMetadataStore with LRO error', async () => { @@ -2883,15 +2903,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteMetadataStore = stubLongRunningCall( undefined, @@ -2900,11 +2916,14 @@ describe('v1.MetadataServiceClient', () => { ); const [operation] = await client.deleteMetadataStore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteMetadataStoreProgress without error', async () => { @@ -2959,15 +2978,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteArtifactRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2976,11 +2991,14 @@ describe('v1.MetadataServiceClient', () => { const [operation] = await client.deleteArtifact(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteArtifact without error using callback', async () => { @@ -2992,15 +3010,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteArtifactRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3030,11 +3044,14 @@ describe('v1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteArtifact with call error', async () => { @@ -3046,26 +3063,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteArtifactRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteArtifact = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteArtifact(request), expectedError); - assert( - (client.innerApiCalls.deleteArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteArtifact with LRO error', async () => { @@ -3077,15 +3093,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteArtifactRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteArtifact = stubLongRunningCall( undefined, @@ -3094,11 +3106,14 @@ describe('v1.MetadataServiceClient', () => { ); const [operation] = await client.deleteArtifact(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteArtifactProgress without error', async () => { @@ -3153,15 +3168,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3170,11 +3181,14 @@ describe('v1.MetadataServiceClient', () => { const [operation] = await client.purgeArtifacts(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeArtifacts without error using callback', async () => { @@ -3186,15 +3200,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3224,11 +3234,14 @@ describe('v1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeArtifacts with call error', async () => { @@ -3240,26 +3253,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeArtifacts = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeArtifacts(request), expectedError); - assert( - (client.innerApiCalls.purgeArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeArtifacts with LRO error', async () => { @@ -3271,15 +3283,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeArtifacts = stubLongRunningCall( undefined, @@ -3288,11 +3296,14 @@ describe('v1.MetadataServiceClient', () => { ); const [operation] = await client.purgeArtifacts(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeArtifactsProgress without error', async () => { @@ -3347,15 +3358,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteContextRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3364,11 +3371,14 @@ describe('v1.MetadataServiceClient', () => { const [operation] = await client.deleteContext(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteContext without error using callback', async () => { @@ -3380,15 +3390,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteContextRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3418,11 +3424,14 @@ describe('v1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteContext with call error', async () => { @@ -3434,26 +3443,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteContextRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteContext = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteContext(request), expectedError); - assert( - (client.innerApiCalls.deleteContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteContext with LRO error', async () => { @@ -3465,15 +3473,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteContextRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteContext = stubLongRunningCall( undefined, @@ -3482,11 +3486,14 @@ describe('v1.MetadataServiceClient', () => { ); const [operation] = await client.deleteContext(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteContextProgress without error', async () => { @@ -3541,15 +3548,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3558,11 +3561,14 @@ describe('v1.MetadataServiceClient', () => { const [operation] = await client.purgeContexts(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeContexts without error using callback', async () => { @@ -3574,15 +3580,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3612,11 +3614,14 @@ describe('v1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeContexts with call error', async () => { @@ -3628,26 +3633,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeContexts = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeContexts(request), expectedError); - assert( - (client.innerApiCalls.purgeContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeContexts with LRO error', async () => { @@ -3659,15 +3663,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeContexts = stubLongRunningCall( undefined, @@ -3676,11 +3676,14 @@ describe('v1.MetadataServiceClient', () => { ); const [operation] = await client.purgeContexts(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeContextsProgress without error', async () => { @@ -3735,15 +3738,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3752,11 +3751,14 @@ describe('v1.MetadataServiceClient', () => { const [operation] = await client.deleteExecution(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteExecution without error using callback', async () => { @@ -3768,15 +3770,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3806,11 +3804,14 @@ describe('v1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteExecution with call error', async () => { @@ -3822,26 +3823,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteExecution = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteExecution(request), expectedError); - assert( - (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteExecution with LRO error', async () => { @@ -3853,15 +3853,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteExecution = stubLongRunningCall( undefined, @@ -3870,11 +3866,14 @@ describe('v1.MetadataServiceClient', () => { ); const [operation] = await client.deleteExecution(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteExecutionProgress without error', async () => { @@ -3929,15 +3928,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3946,11 +3941,14 @@ describe('v1.MetadataServiceClient', () => { const [operation] = await client.purgeExecutions(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeExecutions without error using callback', async () => { @@ -3962,15 +3960,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -4000,11 +3994,14 @@ describe('v1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeExecutions with call error', async () => { @@ -4016,26 +4013,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeExecutions = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeExecutions(request), expectedError); - assert( - (client.innerApiCalls.purgeExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeExecutions with LRO error', async () => { @@ -4047,15 +4043,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PurgeExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeExecutions = stubLongRunningCall( undefined, @@ -4064,11 +4056,14 @@ describe('v1.MetadataServiceClient', () => { ); const [operation] = await client.purgeExecutions(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeExecutionsProgress without error', async () => { @@ -4123,15 +4118,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataStore() @@ -4146,12 +4137,15 @@ describe('v1.MetadataServiceClient', () => { client.innerApiCalls.listMetadataStores = stubSimpleCall(expectedResponse); const [response] = await client.listMetadataStores(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMetadataStores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataStores without error using callback', async () => { @@ -4163,15 +4157,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataStore() @@ -4202,11 +4192,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMetadataStores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataStores with error', async () => { @@ -4218,26 +4211,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listMetadataStores = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listMetadataStores(request), expectedError); - assert( - (client.innerApiCalls.listMetadataStores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataStoresStream without error', async () => { @@ -4249,8 +4241,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataStore() @@ -4287,11 +4282,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMetadataStores, request) ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataStores.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataStores.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4304,8 +4300,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMetadataStores.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4331,11 +4330,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMetadataStores, request) ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataStores.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataStores.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4348,8 +4348,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataStore() @@ -4375,11 +4378,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataStores.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataStores.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4392,8 +4396,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMetadataStores.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4411,11 +4418,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataStores.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataStores.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4430,15 +4438,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Artifact()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Artifact()), @@ -4447,11 +4451,14 @@ describe('v1.MetadataServiceClient', () => { client.innerApiCalls.listArtifacts = stubSimpleCall(expectedResponse); const [response] = await client.listArtifacts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listArtifacts without error using callback', async () => { @@ -4463,15 +4470,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Artifact()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Artifact()), @@ -4496,11 +4499,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listArtifacts with error', async () => { @@ -4512,26 +4518,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listArtifacts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listArtifacts(request), expectedError); - assert( - (client.innerApiCalls.listArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listArtifactsStream without error', async () => { @@ -4543,8 +4548,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Artifact()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Artifact()), @@ -4575,11 +4583,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listArtifacts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listArtifacts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listArtifacts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4592,8 +4601,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listArtifacts.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4619,11 +4631,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listArtifacts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listArtifacts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listArtifacts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4636,8 +4649,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Artifact()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Artifact()), @@ -4657,11 +4673,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listArtifacts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listArtifacts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4674,8 +4691,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listArtifacts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4692,11 +4712,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listArtifacts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listArtifacts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4711,15 +4732,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Context()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Context()), @@ -4728,11 +4745,14 @@ describe('v1.MetadataServiceClient', () => { client.innerApiCalls.listContexts = stubSimpleCall(expectedResponse); const [response] = await client.listContexts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listContexts without error using callback', async () => { @@ -4744,15 +4764,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Context()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Context()), @@ -4777,11 +4793,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listContexts with error', async () => { @@ -4793,26 +4812,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listContexts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listContexts(request), expectedError); - assert( - (client.innerApiCalls.listContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listContextsStream without error', async () => { @@ -4824,8 +4842,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Context()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Context()), @@ -4856,11 +4877,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listContexts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listContexts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listContexts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4873,8 +4895,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listContexts.createStream = stubPageStreamingCall( undefined, @@ -4902,11 +4927,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listContexts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listContexts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listContexts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4919,8 +4945,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Context()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Context()), @@ -4940,11 +4969,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listContexts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listContexts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4957,8 +4987,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listContexts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4975,11 +5008,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listContexts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listContexts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4994,15 +5028,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() @@ -5017,11 +5047,14 @@ describe('v1.MetadataServiceClient', () => { client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); const [response] = await client.listExecutions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listExecutions without error using callback', async () => { @@ -5033,15 +5066,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() @@ -5072,11 +5101,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listExecutions with error', async () => { @@ -5088,26 +5120,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listExecutions = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listExecutions(request), expectedError); - assert( - (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listExecutionsStream without error', async () => { @@ -5119,8 +5150,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() @@ -5157,11 +5191,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listExecutions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listExecutions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5174,8 +5209,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5201,11 +5239,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listExecutions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listExecutions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5218,8 +5257,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Execution() @@ -5245,11 +5287,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listExecutions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5262,8 +5305,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5280,11 +5326,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listExecutions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5299,15 +5346,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataSchema() @@ -5323,11 +5366,14 @@ describe('v1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listMetadataSchemas(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMetadataSchemas as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataSchemas without error using callback', async () => { @@ -5339,15 +5385,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataSchema() @@ -5378,11 +5420,14 @@ describe('v1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMetadataSchemas as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataSchemas with error', async () => { @@ -5394,26 +5439,25 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listMetadataSchemas = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listMetadataSchemas(request), expectedError); - assert( - (client.innerApiCalls.listMetadataSchemas as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataSchemasStream without error', async () => { @@ -5425,8 +5469,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataSchema() @@ -5464,11 +5511,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMetadataSchemas, request) ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataSchemas.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataSchemas.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5481,8 +5529,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMetadataSchemas.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5509,11 +5560,12 @@ describe('v1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMetadataSchemas, request) ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataSchemas.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataSchemas.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5526,8 +5578,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MetadataSchema() @@ -5553,11 +5608,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataSchemas.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataSchemas.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5570,8 +5626,11 @@ describe('v1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMetadataSchemas.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5589,11 +5648,12 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataSchemas.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataSchemas.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -6068,12 +6128,15 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -6104,12 +6167,15 @@ describe('v1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_metadata_service_v1beta1.ts b/test/gapic_metadata_service_v1beta1.ts index bb145fbb..5fff4422 100644 --- a/test/gapic_metadata_service_v1beta1.ts +++ b/test/gapic_metadata_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataStore() ); client.innerApiCalls.getMetadataStore = stubSimpleCall(expectedResponse); const [response] = await client.getMetadataStore(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataStore without error using callback', async () => { @@ -291,15 +305,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataStore() ); @@ -322,11 +332,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataStore with error', async () => { @@ -338,26 +351,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getMetadataStore = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getMetadataStore(request), expectedError); - assert( - (client.innerApiCalls.getMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataStore with closed client', async () => { @@ -369,7 +381,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetMetadataStoreRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getMetadataStore(request), expectedError); @@ -386,26 +401,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateArtifactRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateArtifactRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() ); client.innerApiCalls.createArtifact = stubSimpleCall(expectedResponse); const [response] = await client.createArtifact(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createArtifact without error using callback', async () => { @@ -417,15 +431,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateArtifactRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateArtifactRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() ); @@ -448,11 +458,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createArtifact with error', async () => { @@ -464,26 +477,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateArtifactRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateArtifactRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createArtifact = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createArtifact(request), expectedError); - assert( - (client.innerApiCalls.createArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createArtifact with closed client', async () => { @@ -495,7 +507,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateArtifactRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateArtifactRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createArtifact(request), expectedError); @@ -512,26 +527,23 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetArtifactRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() ); client.innerApiCalls.getArtifact = stubSimpleCall(expectedResponse); const [response] = await client.getArtifact(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getArtifact without error using callback', async () => { @@ -543,15 +555,9 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetArtifactRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() ); @@ -574,11 +580,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getArtifact with error', async () => { @@ -590,26 +599,23 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetArtifactRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getArtifact = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getArtifact(request), expectedError); - assert( - (client.innerApiCalls.getArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getArtifact with closed client', async () => { @@ -621,7 +627,8 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetArtifactRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetArtifactRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getArtifact(request), expectedError); @@ -638,27 +645,27 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateArtifactRequest() ); - request.artifact = {}; - request.artifact.name = ''; - const expectedHeaderRequestParams = 'artifact.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.artifact ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateArtifactRequest', [ + 'artifact', + 'name', + ]); + request.artifact.name = defaultValue1; + const expectedHeaderRequestParams = `artifact.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() ); client.innerApiCalls.updateArtifact = stubSimpleCall(expectedResponse); const [response] = await client.updateArtifact(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateArtifact without error using callback', async () => { @@ -670,16 +677,13 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateArtifactRequest() ); - request.artifact = {}; - request.artifact.name = ''; - const expectedHeaderRequestParams = 'artifact.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.artifact ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateArtifactRequest', [ + 'artifact', + 'name', + ]); + request.artifact.name = defaultValue1; + const expectedHeaderRequestParams = `artifact.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() ); @@ -702,11 +706,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateArtifact with error', async () => { @@ -718,27 +725,27 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateArtifactRequest() ); - request.artifact = {}; - request.artifact.name = ''; - const expectedHeaderRequestParams = 'artifact.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.artifact ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateArtifactRequest', [ + 'artifact', + 'name', + ]); + request.artifact.name = defaultValue1; + const expectedHeaderRequestParams = `artifact.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateArtifact = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateArtifact(request), expectedError); - assert( - (client.innerApiCalls.updateArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateArtifact with closed client', async () => { @@ -750,8 +757,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateArtifactRequest() ); - request.artifact = {}; - request.artifact.name = ''; + request.artifact ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateArtifactRequest', [ + 'artifact', + 'name', + ]); + request.artifact.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateArtifact(request), expectedError); @@ -768,26 +779,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateContextRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateContextRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() ); client.innerApiCalls.createContext = stubSimpleCall(expectedResponse); const [response] = await client.createContext(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createContext without error using callback', async () => { @@ -799,15 +809,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateContextRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateContextRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() ); @@ -830,11 +836,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createContext with error', async () => { @@ -846,26 +855,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateContextRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateContextRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createContext = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createContext(request), expectedError); - assert( - (client.innerApiCalls.createContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createContext with closed client', async () => { @@ -877,7 +885,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateContextRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateContextRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createContext(request), expectedError); @@ -894,26 +905,23 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetContextRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() ); client.innerApiCalls.getContext = stubSimpleCall(expectedResponse); const [response] = await client.getContext(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getContext without error using callback', async () => { @@ -925,15 +933,9 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetContextRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() ); @@ -956,11 +958,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getContext with error', async () => { @@ -972,26 +977,23 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetContextRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getContext = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getContext(request), expectedError); - assert( - (client.innerApiCalls.getContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getContext with closed client', async () => { @@ -1003,7 +1005,8 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetContextRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetContextRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getContext(request), expectedError); @@ -1020,27 +1023,27 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateContextRequest() ); - request.context = {}; - request.context.name = ''; - const expectedHeaderRequestParams = 'context.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.context ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateContextRequest', [ + 'context', + 'name', + ]); + request.context.name = defaultValue1; + const expectedHeaderRequestParams = `context.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() ); client.innerApiCalls.updateContext = stubSimpleCall(expectedResponse); const [response] = await client.updateContext(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateContext without error using callback', async () => { @@ -1052,16 +1055,13 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateContextRequest() ); - request.context = {}; - request.context.name = ''; - const expectedHeaderRequestParams = 'context.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.context ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateContextRequest', [ + 'context', + 'name', + ]); + request.context.name = defaultValue1; + const expectedHeaderRequestParams = `context.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() ); @@ -1084,11 +1084,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateContext with error', async () => { @@ -1100,27 +1103,27 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateContextRequest() ); - request.context = {}; - request.context.name = ''; - const expectedHeaderRequestParams = 'context.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.context ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateContextRequest', [ + 'context', + 'name', + ]); + request.context.name = defaultValue1; + const expectedHeaderRequestParams = `context.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateContext = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateContext(request), expectedError); - assert( - (client.innerApiCalls.updateContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateContext with closed client', async () => { @@ -1132,8 +1135,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateContextRequest() ); - request.context = {}; - request.context.name = ''; + request.context ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateContextRequest', [ + 'context', + 'name', + ]); + request.context.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateContext(request), expectedError); @@ -1150,15 +1157,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextArtifactsAndExecutionsRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddContextArtifactsAndExecutionsRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextArtifactsAndExecutionsResponse() ); @@ -1166,11 +1170,14 @@ describe('v1beta1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addContextArtifactsAndExecutions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextArtifactsAndExecutions without error using callback', async () => { @@ -1182,15 +1189,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextArtifactsAndExecutionsRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddContextArtifactsAndExecutionsRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextArtifactsAndExecutionsResponse() ); @@ -1213,11 +1217,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextArtifactsAndExecutions with error', async () => { @@ -1229,15 +1236,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextArtifactsAndExecutionsRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'AddContextArtifactsAndExecutionsRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addContextArtifactsAndExecutions = stubSimpleCall( undefined, @@ -1247,11 +1251,14 @@ describe('v1beta1.MetadataServiceClient', () => { client.addContextArtifactsAndExecutions(request), expectedError ); - assert( - (client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextArtifactsAndExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextArtifactsAndExecutions with closed client', async () => { @@ -1263,7 +1270,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextArtifactsAndExecutionsRequest() ); - request.context = ''; + const defaultValue1 = getTypeDefaultValue( + 'AddContextArtifactsAndExecutionsRequest', + ['context'] + ); + request.context = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1283,15 +1294,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextChildrenRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddContextChildrenRequest', [ + 'context', + ]); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextChildrenResponse() ); @@ -1299,11 +1306,14 @@ describe('v1beta1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addContextChildren(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addContextChildren as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextChildren without error using callback', async () => { @@ -1315,15 +1325,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextChildrenRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddContextChildrenRequest', [ + 'context', + ]); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextChildrenResponse() ); @@ -1346,11 +1352,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addContextChildren as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextChildren with error', async () => { @@ -1362,26 +1371,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextChildrenRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddContextChildrenRequest', [ + 'context', + ]); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addContextChildren = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.addContextChildren(request), expectedError); - assert( - (client.innerApiCalls.addContextChildren as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addContextChildren as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addContextChildren with closed client', async () => { @@ -1393,7 +1401,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddContextChildrenRequest() ); - request.context = ''; + const defaultValue1 = getTypeDefaultValue('AddContextChildrenRequest', [ + 'context', + ]); + request.context = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.addContextChildren(request), expectedError); @@ -1410,15 +1421,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryContextLineageSubgraphRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryContextLineageSubgraphRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LineageSubgraph() ); @@ -1426,11 +1434,14 @@ describe('v1beta1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.queryContextLineageSubgraph(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryContextLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryContextLineageSubgraph without error using callback', async () => { @@ -1442,15 +1453,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryContextLineageSubgraphRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryContextLineageSubgraphRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LineageSubgraph() ); @@ -1473,11 +1481,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryContextLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryContextLineageSubgraph with error', async () => { @@ -1489,15 +1500,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryContextLineageSubgraphRequest() ); - request.context = ''; - const expectedHeaderRequestParams = 'context='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryContextLineageSubgraphRequest', + ['context'] + ); + request.context = defaultValue1; + const expectedHeaderRequestParams = `context=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.queryContextLineageSubgraph = stubSimpleCall( undefined, @@ -1507,11 +1515,14 @@ describe('v1beta1.MetadataServiceClient', () => { client.queryContextLineageSubgraph(request), expectedError ); - assert( - (client.innerApiCalls.queryContextLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryContextLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryContextLineageSubgraph with closed client', async () => { @@ -1523,7 +1534,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryContextLineageSubgraphRequest() ); - request.context = ''; + const defaultValue1 = getTypeDefaultValue( + 'QueryContextLineageSubgraphRequest', + ['context'] + ); + request.context = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1543,26 +1558,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateExecutionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateExecutionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() ); client.innerApiCalls.createExecution = stubSimpleCall(expectedResponse); const [response] = await client.createExecution(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createExecution without error using callback', async () => { @@ -1574,15 +1588,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateExecutionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateExecutionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() ); @@ -1605,11 +1615,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createExecution with error', async () => { @@ -1621,26 +1634,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateExecutionRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateExecutionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createExecution = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createExecution(request), expectedError); - assert( - (client.innerApiCalls.createExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createExecution with closed client', async () => { @@ -1652,7 +1664,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateExecutionRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateExecutionRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createExecution(request), expectedError); @@ -1669,26 +1684,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() ); client.innerApiCalls.getExecution = stubSimpleCall(expectedResponse); const [response] = await client.getExecution(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getExecution without error using callback', async () => { @@ -1700,15 +1714,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() ); @@ -1731,11 +1741,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getExecution with error', async () => { @@ -1747,26 +1760,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getExecution = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getExecution(request), expectedError); - assert( - (client.innerApiCalls.getExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getExecution with closed client', async () => { @@ -1778,7 +1790,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetExecutionRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getExecution(request), expectedError); @@ -1795,27 +1810,27 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateExecutionRequest() ); - request.execution = {}; - request.execution.name = ''; - const expectedHeaderRequestParams = 'execution.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.execution ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateExecutionRequest', [ + 'execution', + 'name', + ]); + request.execution.name = defaultValue1; + const expectedHeaderRequestParams = `execution.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() ); client.innerApiCalls.updateExecution = stubSimpleCall(expectedResponse); const [response] = await client.updateExecution(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExecution without error using callback', async () => { @@ -1827,16 +1842,13 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateExecutionRequest() ); - request.execution = {}; - request.execution.name = ''; - const expectedHeaderRequestParams = 'execution.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.execution ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateExecutionRequest', [ + 'execution', + 'name', + ]); + request.execution.name = defaultValue1; + const expectedHeaderRequestParams = `execution.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() ); @@ -1859,11 +1871,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExecution with error', async () => { @@ -1875,27 +1890,27 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateExecutionRequest() ); - request.execution = {}; - request.execution.name = ''; - const expectedHeaderRequestParams = 'execution.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.execution ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateExecutionRequest', [ + 'execution', + 'name', + ]); + request.execution.name = defaultValue1; + const expectedHeaderRequestParams = `execution.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateExecution = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateExecution(request), expectedError); - assert( - (client.innerApiCalls.updateExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExecution with closed client', async () => { @@ -1907,8 +1922,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateExecutionRequest() ); - request.execution = {}; - request.execution.name = ''; + request.execution ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateExecutionRequest', [ + 'execution', + 'name', + ]); + request.execution.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateExecution(request), expectedError); @@ -1925,15 +1944,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddExecutionEventsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddExecutionEventsRequest', [ + 'execution', + ]); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddExecutionEventsResponse() ); @@ -1941,11 +1956,14 @@ describe('v1beta1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addExecutionEvents(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addExecutionEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addExecutionEvents without error using callback', async () => { @@ -1957,15 +1975,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddExecutionEventsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddExecutionEventsRequest', [ + 'execution', + ]); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddExecutionEventsResponse() ); @@ -1988,11 +2002,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addExecutionEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addExecutionEvents with error', async () => { @@ -2004,26 +2021,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddExecutionEventsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddExecutionEventsRequest', [ + 'execution', + ]); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addExecutionEvents = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.addExecutionEvents(request), expectedError); - assert( - (client.innerApiCalls.addExecutionEvents as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addExecutionEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addExecutionEvents with closed client', async () => { @@ -2035,7 +2051,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddExecutionEventsRequest() ); - request.execution = ''; + const defaultValue1 = getTypeDefaultValue('AddExecutionEventsRequest', [ + 'execution', + ]); + request.execution = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.addExecutionEvents(request), expectedError); @@ -2052,15 +2071,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryExecutionInputsAndOutputsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryExecutionInputsAndOutputsRequest', + ['execution'] + ); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LineageSubgraph() ); @@ -2068,11 +2084,14 @@ describe('v1beta1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.queryExecutionInputsAndOutputs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryExecutionInputsAndOutputs without error using callback', async () => { @@ -2084,15 +2103,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryExecutionInputsAndOutputsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryExecutionInputsAndOutputsRequest', + ['execution'] + ); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LineageSubgraph() ); @@ -2115,11 +2131,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryExecutionInputsAndOutputs with error', async () => { @@ -2131,15 +2150,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryExecutionInputsAndOutputsRequest() ); - request.execution = ''; - const expectedHeaderRequestParams = 'execution='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryExecutionInputsAndOutputsRequest', + ['execution'] + ); + request.execution = defaultValue1; + const expectedHeaderRequestParams = `execution=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.queryExecutionInputsAndOutputs = stubSimpleCall( undefined, @@ -2149,11 +2165,14 @@ describe('v1beta1.MetadataServiceClient', () => { client.queryExecutionInputsAndOutputs(request), expectedError ); - assert( - (client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryExecutionInputsAndOutputs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryExecutionInputsAndOutputs with closed client', async () => { @@ -2165,7 +2184,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryExecutionInputsAndOutputsRequest() ); - request.execution = ''; + const defaultValue1 = getTypeDefaultValue( + 'QueryExecutionInputsAndOutputsRequest', + ['execution'] + ); + request.execution = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2185,15 +2208,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateMetadataSchemaRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataSchemaRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataSchema() ); @@ -2201,11 +2220,14 @@ describe('v1beta1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createMetadataSchema(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataSchema without error using callback', async () => { @@ -2217,15 +2239,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateMetadataSchemaRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataSchemaRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataSchema() ); @@ -2248,11 +2266,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataSchema with error', async () => { @@ -2264,26 +2285,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateMetadataSchemaRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataSchemaRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMetadataSchema = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createMetadataSchema(request), expectedError); - assert( - (client.innerApiCalls.createMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataSchema with closed client', async () => { @@ -2295,7 +2315,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateMetadataSchemaRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateMetadataSchemaRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createMetadataSchema(request), expectedError); @@ -2312,26 +2335,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetMetadataSchemaRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataSchemaRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataSchema() ); client.innerApiCalls.getMetadataSchema = stubSimpleCall(expectedResponse); const [response] = await client.getMetadataSchema(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataSchema without error using callback', async () => { @@ -2343,15 +2365,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetMetadataSchemaRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataSchemaRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataSchema() ); @@ -2374,11 +2392,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataSchema with error', async () => { @@ -2390,26 +2411,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetMetadataSchemaRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetMetadataSchemaRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getMetadataSchema = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getMetadataSchema(request), expectedError); - assert( - (client.innerApiCalls.getMetadataSchema as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMetadataSchema as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getMetadataSchema with closed client', async () => { @@ -2421,7 +2441,10 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetMetadataSchemaRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetMetadataSchemaRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getMetadataSchema(request), expectedError); @@ -2438,15 +2461,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryArtifactLineageSubgraphRequest() ); - request.artifact = ''; - const expectedHeaderRequestParams = 'artifact='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryArtifactLineageSubgraphRequest', + ['artifact'] + ); + request.artifact = defaultValue1; + const expectedHeaderRequestParams = `artifact=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LineageSubgraph() ); @@ -2454,11 +2474,14 @@ describe('v1beta1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.queryArtifactLineageSubgraph(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryArtifactLineageSubgraph without error using callback', async () => { @@ -2470,15 +2493,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryArtifactLineageSubgraphRequest() ); - request.artifact = ''; - const expectedHeaderRequestParams = 'artifact='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryArtifactLineageSubgraphRequest', + ['artifact'] + ); + request.artifact = defaultValue1; + const expectedHeaderRequestParams = `artifact=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LineageSubgraph() ); @@ -2501,11 +2521,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryArtifactLineageSubgraph with error', async () => { @@ -2517,15 +2540,12 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryArtifactLineageSubgraphRequest() ); - request.artifact = ''; - const expectedHeaderRequestParams = 'artifact='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'QueryArtifactLineageSubgraphRequest', + ['artifact'] + ); + request.artifact = defaultValue1; + const expectedHeaderRequestParams = `artifact=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.queryArtifactLineageSubgraph = stubSimpleCall( undefined, @@ -2535,11 +2555,14 @@ describe('v1beta1.MetadataServiceClient', () => { client.queryArtifactLineageSubgraph(request), expectedError ); - assert( - (client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryArtifactLineageSubgraph as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes queryArtifactLineageSubgraph with closed client', async () => { @@ -2551,7 +2574,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.QueryArtifactLineageSubgraphRequest() ); - request.artifact = ''; + const defaultValue1 = getTypeDefaultValue( + 'QueryArtifactLineageSubgraphRequest', + ['artifact'] + ); + request.artifact = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2571,15 +2598,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateMetadataStoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataStoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2588,11 +2611,14 @@ describe('v1beta1.MetadataServiceClient', () => { const [operation] = await client.createMetadataStore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataStore without error using callback', async () => { @@ -2604,15 +2630,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateMetadataStoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataStoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2642,11 +2664,14 @@ describe('v1beta1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataStore with call error', async () => { @@ -2658,26 +2683,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateMetadataStoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataStoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMetadataStore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createMetadataStore(request), expectedError); - assert( - (client.innerApiCalls.createMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createMetadataStore with LRO error', async () => { @@ -2689,15 +2713,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateMetadataStoreRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateMetadataStoreRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createMetadataStore = stubLongRunningCall( undefined, @@ -2706,11 +2726,14 @@ describe('v1beta1.MetadataServiceClient', () => { ); const [operation] = await client.createMetadataStore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateMetadataStoreProgress without error', async () => { @@ -2765,15 +2788,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2782,11 +2801,14 @@ describe('v1beta1.MetadataServiceClient', () => { const [operation] = await client.deleteMetadataStore(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMetadataStore without error using callback', async () => { @@ -2798,15 +2820,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2836,11 +2854,14 @@ describe('v1beta1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMetadataStore with call error', async () => { @@ -2852,26 +2873,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteMetadataStore = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteMetadataStore(request), expectedError); - assert( - (client.innerApiCalls.deleteMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteMetadataStore with LRO error', async () => { @@ -2883,15 +2903,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteMetadataStoreRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteMetadataStoreRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteMetadataStore = stubLongRunningCall( undefined, @@ -2900,11 +2916,14 @@ describe('v1beta1.MetadataServiceClient', () => { ); const [operation] = await client.deleteMetadataStore(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteMetadataStore as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMetadataStore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteMetadataStoreProgress without error', async () => { @@ -2959,15 +2978,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteArtifactRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2976,11 +2991,14 @@ describe('v1beta1.MetadataServiceClient', () => { const [operation] = await client.deleteArtifact(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteArtifact without error using callback', async () => { @@ -2992,15 +3010,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteArtifactRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3030,11 +3044,14 @@ describe('v1beta1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteArtifact with call error', async () => { @@ -3046,26 +3063,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteArtifactRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteArtifact = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteArtifact(request), expectedError); - assert( - (client.innerApiCalls.deleteArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteArtifact with LRO error', async () => { @@ -3077,15 +3093,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteArtifactRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteArtifactRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteArtifact = stubLongRunningCall( undefined, @@ -3094,11 +3106,14 @@ describe('v1beta1.MetadataServiceClient', () => { ); const [operation] = await client.deleteArtifact(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteArtifact as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteArtifact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteArtifactProgress without error', async () => { @@ -3153,15 +3168,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3170,11 +3181,14 @@ describe('v1beta1.MetadataServiceClient', () => { const [operation] = await client.purgeArtifacts(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeArtifacts without error using callback', async () => { @@ -3186,15 +3200,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3224,11 +3234,14 @@ describe('v1beta1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeArtifacts with call error', async () => { @@ -3240,26 +3253,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeArtifacts = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeArtifacts(request), expectedError); - assert( - (client.innerApiCalls.purgeArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeArtifacts with LRO error', async () => { @@ -3271,15 +3283,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeArtifacts = stubLongRunningCall( undefined, @@ -3288,11 +3296,14 @@ describe('v1beta1.MetadataServiceClient', () => { ); const [operation] = await client.purgeArtifacts(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeArtifactsProgress without error', async () => { @@ -3347,15 +3358,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteContextRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3364,11 +3371,14 @@ describe('v1beta1.MetadataServiceClient', () => { const [operation] = await client.deleteContext(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteContext without error using callback', async () => { @@ -3380,15 +3390,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteContextRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3418,11 +3424,14 @@ describe('v1beta1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteContext with call error', async () => { @@ -3434,26 +3443,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteContextRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteContext = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteContext(request), expectedError); - assert( - (client.innerApiCalls.deleteContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteContext with LRO error', async () => { @@ -3465,15 +3473,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteContextRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteContextRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteContext = stubLongRunningCall( undefined, @@ -3482,11 +3486,14 @@ describe('v1beta1.MetadataServiceClient', () => { ); const [operation] = await client.deleteContext(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteContext as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteContext as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteContextProgress without error', async () => { @@ -3541,15 +3548,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3558,11 +3561,14 @@ describe('v1beta1.MetadataServiceClient', () => { const [operation] = await client.purgeContexts(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeContexts without error using callback', async () => { @@ -3574,15 +3580,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3612,11 +3614,14 @@ describe('v1beta1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeContexts with call error', async () => { @@ -3628,26 +3633,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeContexts = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeContexts(request), expectedError); - assert( - (client.innerApiCalls.purgeContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeContexts with LRO error', async () => { @@ -3659,15 +3663,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeContexts = stubLongRunningCall( undefined, @@ -3676,11 +3676,14 @@ describe('v1beta1.MetadataServiceClient', () => { ); const [operation] = await client.purgeContexts(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeContextsProgress without error', async () => { @@ -3735,15 +3738,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3752,11 +3751,14 @@ describe('v1beta1.MetadataServiceClient', () => { const [operation] = await client.deleteExecution(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteExecution without error using callback', async () => { @@ -3768,15 +3770,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3806,11 +3804,14 @@ describe('v1beta1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteExecution with call error', async () => { @@ -3822,26 +3823,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteExecution = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteExecution(request), expectedError); - assert( - (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteExecution with LRO error', async () => { @@ -3853,15 +3853,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteExecutionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteExecutionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteExecution = stubLongRunningCall( undefined, @@ -3870,11 +3866,14 @@ describe('v1beta1.MetadataServiceClient', () => { ); const [operation] = await client.deleteExecution(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteExecution as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteExecution as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteExecutionProgress without error', async () => { @@ -3929,15 +3928,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3946,11 +3941,14 @@ describe('v1beta1.MetadataServiceClient', () => { const [operation] = await client.purgeExecutions(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeExecutions without error using callback', async () => { @@ -3962,15 +3960,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -4000,11 +3994,14 @@ describe('v1beta1.MetadataServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeExecutions with call error', async () => { @@ -4016,26 +4013,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeExecutions = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeExecutions(request), expectedError); - assert( - (client.innerApiCalls.purgeExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeExecutions with LRO error', async () => { @@ -4047,15 +4043,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PurgeExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PurgeExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeExecutions = stubLongRunningCall( undefined, @@ -4064,11 +4056,14 @@ describe('v1beta1.MetadataServiceClient', () => { ); const [operation] = await client.purgeExecutions(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeExecutionsProgress without error', async () => { @@ -4123,15 +4118,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataStore() @@ -4146,12 +4137,15 @@ describe('v1beta1.MetadataServiceClient', () => { client.innerApiCalls.listMetadataStores = stubSimpleCall(expectedResponse); const [response] = await client.listMetadataStores(request); - assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMetadataStores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataStores without error using callback', async () => { @@ -4163,15 +4157,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataStore() @@ -4204,11 +4194,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMetadataStores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataStores with error', async () => { @@ -4220,26 +4213,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listMetadataStores = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listMetadataStores(request), expectedError); - assert( - (client.innerApiCalls.listMetadataStores as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataStores as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataStoresStream without error', async () => { @@ -4251,8 +4243,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataStore() @@ -4290,11 +4285,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMetadataStores, request) ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataStores.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataStores.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4307,8 +4303,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMetadataStores.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4335,11 +4334,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMetadataStores, request) ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataStores.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataStores.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4352,8 +4352,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataStore() @@ -4380,11 +4383,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataStores.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataStores.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4397,8 +4401,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataStoresRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataStoresRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMetadataStores.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4416,11 +4423,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataStores.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataStores.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4435,15 +4443,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() @@ -4458,11 +4462,14 @@ describe('v1beta1.MetadataServiceClient', () => { client.innerApiCalls.listArtifacts = stubSimpleCall(expectedResponse); const [response] = await client.listArtifacts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listArtifacts without error using callback', async () => { @@ -4474,15 +4481,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() @@ -4513,11 +4516,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listArtifacts with error', async () => { @@ -4529,26 +4535,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listArtifacts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listArtifacts(request), expectedError); - assert( - (client.innerApiCalls.listArtifacts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listArtifacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listArtifactsStream without error', async () => { @@ -4560,8 +4565,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() @@ -4598,11 +4606,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listArtifacts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listArtifacts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listArtifacts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4615,8 +4624,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listArtifacts.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4642,11 +4654,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listArtifacts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listArtifacts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listArtifacts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4659,8 +4672,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Artifact() @@ -4686,11 +4702,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listArtifacts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listArtifacts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4703,8 +4720,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListArtifactsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListArtifactsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listArtifacts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4722,11 +4742,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listArtifacts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listArtifacts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4741,15 +4762,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() @@ -4764,11 +4781,14 @@ describe('v1beta1.MetadataServiceClient', () => { client.innerApiCalls.listContexts = stubSimpleCall(expectedResponse); const [response] = await client.listContexts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listContexts without error using callback', async () => { @@ -4780,15 +4800,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() @@ -4819,11 +4835,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listContexts with error', async () => { @@ -4835,26 +4854,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listContexts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listContexts(request), expectedError); - assert( - (client.innerApiCalls.listContexts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listContexts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listContextsStream without error', async () => { @@ -4866,8 +4884,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() @@ -4904,11 +4925,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listContexts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listContexts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listContexts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4921,8 +4943,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listContexts.createStream = stubPageStreamingCall( undefined, @@ -4950,11 +4975,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listContexts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listContexts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listContexts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4967,8 +4993,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Context() @@ -4994,11 +5023,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listContexts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listContexts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5011,8 +5041,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListContextsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListContextsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listContexts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5029,11 +5062,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listContexts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listContexts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5048,15 +5082,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() @@ -5071,11 +5101,14 @@ describe('v1beta1.MetadataServiceClient', () => { client.innerApiCalls.listExecutions = stubSimpleCall(expectedResponse); const [response] = await client.listExecutions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listExecutions without error using callback', async () => { @@ -5087,15 +5120,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() @@ -5126,11 +5155,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listExecutions with error', async () => { @@ -5142,26 +5174,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listExecutions = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listExecutions(request), expectedError); - assert( - (client.innerApiCalls.listExecutions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listExecutions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listExecutionsStream without error', async () => { @@ -5173,8 +5204,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() @@ -5212,11 +5246,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listExecutions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listExecutions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5229,8 +5264,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listExecutions.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5257,11 +5295,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listExecutions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listExecutions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listExecutions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5274,8 +5313,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Execution() @@ -5301,11 +5343,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listExecutions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5318,8 +5361,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListExecutionsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListExecutionsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listExecutions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5337,11 +5383,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listExecutions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listExecutions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5356,15 +5403,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataSchema() @@ -5380,11 +5423,14 @@ describe('v1beta1.MetadataServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listMetadataSchemas(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMetadataSchemas as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataSchemas without error using callback', async () => { @@ -5396,15 +5442,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataSchema() @@ -5437,11 +5479,14 @@ describe('v1beta1.MetadataServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listMetadataSchemas as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataSchemas with error', async () => { @@ -5453,26 +5498,25 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listMetadataSchemas = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listMetadataSchemas(request), expectedError); - assert( - (client.innerApiCalls.listMetadataSchemas as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMetadataSchemas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listMetadataSchemasStream without error', async () => { @@ -5484,8 +5528,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataSchema() @@ -5523,11 +5570,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMetadataSchemas, request) ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataSchemas.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataSchemas.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5540,8 +5588,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMetadataSchemas.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5568,11 +5619,12 @@ describe('v1beta1.MetadataServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listMetadataSchemas, request) ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataSchemas.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataSchemas.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5585,8 +5637,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MetadataSchema() @@ -5613,11 +5668,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataSchemas.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataSchemas.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5630,8 +5686,11 @@ describe('v1beta1.MetadataServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListMetadataSchemasRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListMetadataSchemasRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listMetadataSchemas.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5649,11 +5708,12 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listMetadataSchemas.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listMetadataSchemas.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -6128,12 +6188,15 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -6164,12 +6227,15 @@ describe('v1beta1.MetadataServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_migration_service_v1.ts b/test/gapic_migration_service_v1.ts index b1324c06..f4b33379 100644 --- a/test/gapic_migration_service_v1.ts +++ b/test/gapic_migration_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,15 +275,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchMigrateResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchMigrateResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -277,11 +289,14 @@ describe('v1.MigrationServiceClient', () => { const [operation] = await client.batchMigrateResources(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchMigrateResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchMigrateResources without error using callback', async () => { @@ -293,15 +308,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchMigrateResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchMigrateResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -331,11 +343,14 @@ describe('v1.MigrationServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchMigrateResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchMigrateResources with call error', async () => { @@ -347,15 +362,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchMigrateResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchMigrateResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchMigrateResources = stubLongRunningCall( undefined, @@ -365,11 +377,14 @@ describe('v1.MigrationServiceClient', () => { client.batchMigrateResources(request), expectedError ); - assert( - (client.innerApiCalls.batchMigrateResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchMigrateResources with LRO error', async () => { @@ -381,15 +396,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchMigrateResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchMigrateResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchMigrateResources = stubLongRunningCall( undefined, @@ -398,11 +410,14 @@ describe('v1.MigrationServiceClient', () => { ); const [operation] = await client.batchMigrateResources(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.batchMigrateResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkBatchMigrateResourcesProgress without error', async () => { @@ -457,15 +472,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MigratableResource() @@ -481,11 +493,14 @@ describe('v1.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.searchMigratableResources(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchMigratableResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchMigratableResources without error using callback', async () => { @@ -497,15 +512,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MigratableResource() @@ -538,11 +550,14 @@ describe('v1.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchMigratableResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchMigratableResources with error', async () => { @@ -554,15 +569,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.searchMigratableResources = stubSimpleCall( undefined, @@ -572,11 +584,14 @@ describe('v1.MigrationServiceClient', () => { client.searchMigratableResources(request), expectedError ); - assert( - (client.innerApiCalls.searchMigratableResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchMigratableResourcesStream without error', async () => { @@ -588,8 +603,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MigratableResource() @@ -630,12 +649,15 @@ describe('v1.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.searchMigratableResources, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.searchMigratableResources .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -648,8 +670,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchMigratableResources.createStream = stubPageStreamingCall(undefined, expectedError); @@ -679,12 +705,15 @@ describe('v1.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.searchMigratableResources, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.searchMigratableResources .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -697,8 +726,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.MigratableResource() @@ -726,12 +759,15 @@ describe('v1.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.searchMigratableResources .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -744,8 +780,12 @@ describe('v1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchMigratableResources.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -764,12 +804,15 @@ describe('v1.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.searchMigratableResources .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1244,12 +1287,15 @@ describe('v1.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1280,12 +1326,15 @@ describe('v1.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_migration_service_v1beta1.ts b/test/gapic_migration_service_v1beta1.ts index 3ce1bd84..91031cdc 100644 --- a/test/gapic_migration_service_v1beta1.ts +++ b/test/gapic_migration_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -261,15 +276,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchMigrateResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchMigrateResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -278,11 +290,14 @@ describe('v1beta1.MigrationServiceClient', () => { const [operation] = await client.batchMigrateResources(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchMigrateResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchMigrateResources without error using callback', async () => { @@ -294,15 +309,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchMigrateResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchMigrateResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -332,11 +344,14 @@ describe('v1beta1.MigrationServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchMigrateResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchMigrateResources with call error', async () => { @@ -348,15 +363,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchMigrateResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchMigrateResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchMigrateResources = stubLongRunningCall( undefined, @@ -366,11 +378,14 @@ describe('v1beta1.MigrationServiceClient', () => { client.batchMigrateResources(request), expectedError ); - assert( - (client.innerApiCalls.batchMigrateResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchMigrateResources with LRO error', async () => { @@ -382,15 +397,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchMigrateResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchMigrateResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchMigrateResources = stubLongRunningCall( undefined, @@ -399,11 +411,14 @@ describe('v1beta1.MigrationServiceClient', () => { ); const [operation] = await client.batchMigrateResources(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.batchMigrateResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchMigrateResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkBatchMigrateResourcesProgress without error', async () => { @@ -458,15 +473,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MigratableResource() @@ -482,11 +494,14 @@ describe('v1beta1.MigrationServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.searchMigratableResources(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchMigratableResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchMigratableResources without error using callback', async () => { @@ -498,15 +513,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MigratableResource() @@ -539,11 +551,14 @@ describe('v1beta1.MigrationServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.searchMigratableResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchMigratableResources with error', async () => { @@ -555,15 +570,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.searchMigratableResources = stubSimpleCall( undefined, @@ -573,11 +585,14 @@ describe('v1beta1.MigrationServiceClient', () => { client.searchMigratableResources(request), expectedError ); - assert( - (client.innerApiCalls.searchMigratableResources as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchMigratableResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes searchMigratableResourcesStream without error', async () => { @@ -589,8 +604,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MigratableResource() @@ -633,12 +652,15 @@ describe('v1beta1.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.searchMigratableResources, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.searchMigratableResources .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -651,8 +673,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchMigratableResources.createStream = stubPageStreamingCall(undefined, expectedError); @@ -684,12 +710,15 @@ describe('v1beta1.MigrationServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.searchMigratableResources, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.searchMigratableResources .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -702,8 +731,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MigratableResource() @@ -731,12 +764,15 @@ describe('v1beta1.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.searchMigratableResources .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -749,8 +785,12 @@ describe('v1beta1.MigrationServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SearchMigratableResourcesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'SearchMigratableResourcesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.searchMigratableResources.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -769,12 +809,15 @@ describe('v1beta1.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.searchMigratableResources .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1249,12 +1292,15 @@ describe('v1beta1.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1285,12 +1331,15 @@ describe('v1beta1.MigrationServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_model_service_v1.ts b/test/gapic_model_service_v1.ts index 9b934fa7..0d724f48 100644 --- a/test/gapic_model_service_v1.ts +++ b/test/gapic_model_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -258,26 +273,23 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Model() ); client.innerApiCalls.getModel = stubSimpleCall(expectedResponse); const [response] = await client.getModel(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModel without error using callback', async () => { @@ -289,15 +301,9 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Model() ); @@ -320,11 +326,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModel with error', async () => { @@ -336,23 +345,20 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getModel = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getModel(request), expectedError); - assert( - (client.innerApiCalls.getModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModel with closed client', async () => { @@ -364,7 +370,8 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetModelRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getModel(request), expectedError); @@ -381,27 +388,27 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateModelRequest() ); - request.model = {}; - request.model.name = ''; - const expectedHeaderRequestParams = 'model.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateModelRequest', [ + 'model', + 'name', + ]); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Model() ); client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); const [response] = await client.updateModel(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModel without error using callback', async () => { @@ -413,16 +420,13 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateModelRequest() ); - request.model = {}; - request.model.name = ''; - const expectedHeaderRequestParams = 'model.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateModelRequest', [ + 'model', + 'name', + ]); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Model() ); @@ -445,11 +449,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModel with error', async () => { @@ -461,27 +468,27 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateModelRequest() ); - request.model = {}; - request.model.name = ''; - const expectedHeaderRequestParams = 'model.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateModelRequest', [ + 'model', + 'name', + ]); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateModel = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateModel(request), expectedError); - assert( - (client.innerApiCalls.updateModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModel with closed client', async () => { @@ -493,8 +500,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateModelRequest() ); - request.model = {}; - request.model.name = ''; + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateModelRequest', [ + 'model', + 'name', + ]); + request.model.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateModel(request), expectedError); @@ -511,15 +522,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MergeVersionAliasesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MergeVersionAliasesRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Model() ); @@ -527,11 +534,14 @@ describe('v1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.mergeVersionAliases(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.mergeVersionAliases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mergeVersionAliases without error using callback', async () => { @@ -543,15 +553,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MergeVersionAliasesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MergeVersionAliasesRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Model() ); @@ -574,11 +580,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.mergeVersionAliases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mergeVersionAliases with error', async () => { @@ -590,26 +599,25 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MergeVersionAliasesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MergeVersionAliasesRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.mergeVersionAliases = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.mergeVersionAliases(request), expectedError); - assert( - (client.innerApiCalls.mergeVersionAliases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mergeVersionAliases with closed client', async () => { @@ -621,7 +629,10 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.MergeVersionAliasesRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('MergeVersionAliasesRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.mergeVersionAliases(request), expectedError); @@ -638,15 +649,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportModelEvaluationRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ImportModelEvaluationRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluation() ); @@ -654,11 +662,14 @@ describe('v1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.importModelEvaluation(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importModelEvaluation without error using callback', async () => { @@ -670,15 +681,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportModelEvaluationRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ImportModelEvaluationRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluation() ); @@ -701,11 +709,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importModelEvaluation with error', async () => { @@ -717,15 +728,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportModelEvaluationRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ImportModelEvaluationRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importModelEvaluation = stubSimpleCall( undefined, @@ -735,11 +743,14 @@ describe('v1.ModelServiceClient', () => { client.importModelEvaluation(request), expectedError ); - assert( - (client.innerApiCalls.importModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importModelEvaluation with closed client', async () => { @@ -751,7 +762,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ImportModelEvaluationRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'ImportModelEvaluationRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -771,15 +786,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchImportModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchImportModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchImportModelEvaluationSlicesResponse() ); @@ -787,11 +799,14 @@ describe('v1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchImportModelEvaluationSlices(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchImportModelEvaluationSlices without error using callback', async () => { @@ -803,15 +818,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchImportModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchImportModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchImportModelEvaluationSlicesResponse() ); @@ -834,11 +846,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchImportModelEvaluationSlices with error', async () => { @@ -850,15 +865,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchImportModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchImportModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchImportModelEvaluationSlices = stubSimpleCall( undefined, @@ -868,11 +880,14 @@ describe('v1.ModelServiceClient', () => { client.batchImportModelEvaluationSlices(request), expectedError ); - assert( - (client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchImportModelEvaluationSlices with closed client', async () => { @@ -884,7 +899,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchImportModelEvaluationSlicesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'BatchImportModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -904,15 +923,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelEvaluationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelEvaluationRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluation() ); @@ -920,11 +935,14 @@ describe('v1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getModelEvaluation(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluation without error using callback', async () => { @@ -936,15 +954,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelEvaluationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelEvaluationRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluation() ); @@ -967,11 +981,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluation with error', async () => { @@ -983,26 +1000,25 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelEvaluationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelEvaluationRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getModelEvaluation = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getModelEvaluation(request), expectedError); - assert( - (client.innerApiCalls.getModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluation with closed client', async () => { @@ -1014,7 +1030,10 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelEvaluationRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetModelEvaluationRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getModelEvaluation(request), expectedError); @@ -1031,15 +1050,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelEvaluationSliceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelEvaluationSliceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluationSlice() ); @@ -1047,11 +1063,14 @@ describe('v1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getModelEvaluationSlice(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelEvaluationSlice as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluationSlice without error using callback', async () => { @@ -1063,15 +1082,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelEvaluationSliceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelEvaluationSliceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluationSlice() ); @@ -1094,11 +1110,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelEvaluationSlice as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluationSlice with error', async () => { @@ -1110,15 +1129,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelEvaluationSliceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelEvaluationSliceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getModelEvaluationSlice = stubSimpleCall( undefined, @@ -1128,11 +1144,14 @@ describe('v1.ModelServiceClient', () => { client.getModelEvaluationSlice(request), expectedError ); - assert( - (client.innerApiCalls.getModelEvaluationSlice as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluationSlice with closed client', async () => { @@ -1144,7 +1163,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetModelEvaluationSliceRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetModelEvaluationSliceRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1164,15 +1187,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UploadModelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UploadModelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1180,11 +1199,14 @@ describe('v1.ModelServiceClient', () => { const [operation] = await client.uploadModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.uploadModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes uploadModel without error using callback', async () => { @@ -1196,15 +1218,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UploadModelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UploadModelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1234,11 +1252,14 @@ describe('v1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.uploadModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes uploadModel with call error', async () => { @@ -1250,26 +1271,25 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UploadModelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UploadModelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.uploadModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.uploadModel(request), expectedError); - assert( - (client.innerApiCalls.uploadModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes uploadModel with LRO error', async () => { @@ -1281,15 +1301,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UploadModelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UploadModelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.uploadModel = stubLongRunningCall( undefined, @@ -1298,11 +1314,14 @@ describe('v1.ModelServiceClient', () => { ); const [operation] = await client.uploadModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.uploadModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUploadModelProgress without error', async () => { @@ -1354,15 +1373,9 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1370,11 +1383,14 @@ describe('v1.ModelServiceClient', () => { const [operation] = await client.deleteModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModel without error using callback', async () => { @@ -1386,15 +1402,9 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1424,11 +1434,14 @@ describe('v1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModel with call error', async () => { @@ -1440,26 +1453,23 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteModel(request), expectedError); - assert( - (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModel with LRO error', async () => { @@ -1471,15 +1481,9 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModel = stubLongRunningCall( undefined, @@ -1488,11 +1492,14 @@ describe('v1.ModelServiceClient', () => { ); const [operation] = await client.deleteModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteModelProgress without error', async () => { @@ -1544,15 +1551,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelVersionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelVersionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1561,11 +1564,14 @@ describe('v1.ModelServiceClient', () => { const [operation] = await client.deleteModelVersion(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModelVersion as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelVersion without error using callback', async () => { @@ -1577,15 +1583,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelVersionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelVersionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1615,11 +1617,14 @@ describe('v1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModelVersion as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelVersion with call error', async () => { @@ -1631,26 +1636,25 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelVersionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelVersionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModelVersion = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteModelVersion(request), expectedError); - assert( - (client.innerApiCalls.deleteModelVersion as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelVersion with LRO error', async () => { @@ -1662,15 +1666,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteModelVersionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelVersionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModelVersion = stubLongRunningCall( undefined, @@ -1679,11 +1679,14 @@ describe('v1.ModelServiceClient', () => { ); const [operation] = await client.deleteModelVersion(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteModelVersion as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteModelVersionProgress without error', async () => { @@ -1738,15 +1741,9 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1754,11 +1751,14 @@ describe('v1.ModelServiceClient', () => { const [operation] = await client.exportModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportModel without error using callback', async () => { @@ -1770,15 +1770,9 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1808,42 +1802,42 @@ describe('v1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportModel with call error', async () => { const client = new modelserviceModule.v1.ModelServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.aiplatform.v1.ExportModelRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.ExportModelRequest() + ); + const defaultValue1 = getTypeDefaultValue('ExportModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.exportModel(request), expectedError); - assert( - (client.innerApiCalls.exportModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportModel with LRO error', async () => { @@ -1855,15 +1849,9 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportModel = stubLongRunningCall( undefined, @@ -1872,11 +1860,14 @@ describe('v1.ModelServiceClient', () => { ); const [operation] = await client.exportModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.exportModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkExportModelProgress without error', async () => { @@ -1928,15 +1919,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), @@ -1945,11 +1932,14 @@ describe('v1.ModelServiceClient', () => { client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); const [response] = await client.listModels(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModels without error using callback', async () => { @@ -1961,15 +1951,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), @@ -1994,11 +1980,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModels with error', async () => { @@ -2010,26 +1999,25 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModels = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listModels(request), expectedError); - assert( - (client.innerApiCalls.listModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelsStream without error', async () => { @@ -2041,8 +2029,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), @@ -2073,11 +2064,12 @@ describe('v1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModels, request) ); - assert.strictEqual( - (client.descriptors.page.listModels.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2090,8 +2082,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModels.createStream = stubPageStreamingCall( undefined, @@ -2119,11 +2114,12 @@ describe('v1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModels, request) ); - assert.strictEqual( - (client.descriptors.page.listModels.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2136,8 +2132,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), @@ -2157,11 +2156,12 @@ describe('v1.ModelServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2174,8 +2174,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall( undefined, @@ -2194,11 +2197,12 @@ describe('v1.ModelServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2213,15 +2217,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), @@ -2230,11 +2230,14 @@ describe('v1.ModelServiceClient', () => { client.innerApiCalls.listModelVersions = stubSimpleCall(expectedResponse); const [response] = await client.listModelVersions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelVersions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelVersions without error using callback', async () => { @@ -2246,15 +2249,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), @@ -2279,11 +2278,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelVersions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelVersions with error', async () => { @@ -2295,26 +2297,25 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModelVersions = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listModelVersions(request), expectedError); - assert( - (client.innerApiCalls.listModelVersions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelVersionsStream without error', async () => { @@ -2326,8 +2327,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), @@ -2358,11 +2362,12 @@ describe('v1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelVersions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listModelVersions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2375,8 +2380,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelVersions.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2402,11 +2410,12 @@ describe('v1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelVersions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listModelVersions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2419,8 +2428,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Model()), @@ -2440,11 +2452,12 @@ describe('v1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listModelVersions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2457,8 +2470,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2475,11 +2491,12 @@ describe('v1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listModelVersions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2494,15 +2511,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluation() @@ -2518,11 +2531,14 @@ describe('v1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listModelEvaluations(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelEvaluations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluations without error using callback', async () => { @@ -2534,15 +2550,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluation() @@ -2573,11 +2585,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelEvaluations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluations with error', async () => { @@ -2589,26 +2604,25 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModelEvaluations = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listModelEvaluations(request), expectedError); - assert( - (client.innerApiCalls.listModelEvaluations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluationsStream without error', async () => { @@ -2620,8 +2634,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluation() @@ -2659,11 +2676,12 @@ describe('v1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelEvaluations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listModelEvaluations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelEvaluations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2676,8 +2694,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelEvaluations.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2704,11 +2725,12 @@ describe('v1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelEvaluations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listModelEvaluations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelEvaluations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2721,8 +2743,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluation() @@ -2749,11 +2774,12 @@ describe('v1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listModelEvaluations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelEvaluations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2766,8 +2792,11 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelEvaluations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2785,11 +2814,12 @@ describe('v1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listModelEvaluations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelEvaluations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2804,15 +2834,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluationSlice() @@ -2828,11 +2855,14 @@ describe('v1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listModelEvaluationSlices(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluationSlices without error using callback', async () => { @@ -2844,15 +2874,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluationSlice() @@ -2885,11 +2912,14 @@ describe('v1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluationSlices with error', async () => { @@ -2901,15 +2931,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModelEvaluationSlices = stubSimpleCall( undefined, @@ -2919,11 +2946,14 @@ describe('v1.ModelServiceClient', () => { client.listModelEvaluationSlices(request), expectedError ); - assert( - (client.innerApiCalls.listModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluationSlicesStream without error', async () => { @@ -2935,8 +2965,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluationSlice() @@ -2979,12 +3013,15 @@ describe('v1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelEvaluationSlices, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelEvaluationSlices .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2997,8 +3034,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelEvaluationSlices.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3030,12 +3071,15 @@ describe('v1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelEvaluationSlices, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelEvaluationSlices .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3048,8 +3092,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.ModelEvaluationSlice() @@ -3077,12 +3125,15 @@ describe('v1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelEvaluationSlices .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3095,8 +3146,12 @@ describe('v1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelEvaluationSlices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3115,12 +3170,15 @@ describe('v1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelEvaluationSlices .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3595,12 +3653,15 @@ describe('v1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -3631,12 +3692,15 @@ describe('v1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_model_service_v1beta1.ts b/test/gapic_model_service_v1beta1.ts index 9939b846..c58ed31d 100644 --- a/test/gapic_model_service_v1beta1.ts +++ b/test/gapic_model_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,23 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() ); client.innerApiCalls.getModel = stubSimpleCall(expectedResponse); const [response] = await client.getModel(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModel without error using callback', async () => { @@ -291,15 +303,9 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() ); @@ -322,11 +328,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModel with error', async () => { @@ -338,23 +347,20 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getModel = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getModel(request), expectedError); - assert( - (client.innerApiCalls.getModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModel with closed client', async () => { @@ -366,7 +372,8 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetModelRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getModel(request), expectedError); @@ -383,27 +390,27 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateModelRequest() ); - request.model = {}; - request.model.name = ''; - const expectedHeaderRequestParams = 'model.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateModelRequest', [ + 'model', + 'name', + ]); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() ); client.innerApiCalls.updateModel = stubSimpleCall(expectedResponse); const [response] = await client.updateModel(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModel without error using callback', async () => { @@ -415,16 +422,13 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateModelRequest() ); - request.model = {}; - request.model.name = ''; - const expectedHeaderRequestParams = 'model.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateModelRequest', [ + 'model', + 'name', + ]); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() ); @@ -447,11 +451,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModel with error', async () => { @@ -463,27 +470,27 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateModelRequest() ); - request.model = {}; - request.model.name = ''; - const expectedHeaderRequestParams = 'model.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateModelRequest', [ + 'model', + 'name', + ]); + request.model.name = defaultValue1; + const expectedHeaderRequestParams = `model.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateModel = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateModel(request), expectedError); - assert( - (client.innerApiCalls.updateModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateModel with closed client', async () => { @@ -495,8 +502,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateModelRequest() ); - request.model = {}; - request.model.name = ''; + request.model ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateModelRequest', [ + 'model', + 'name', + ]); + request.model.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateModel(request), expectedError); @@ -513,15 +524,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MergeVersionAliasesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MergeVersionAliasesRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() ); @@ -529,11 +536,14 @@ describe('v1beta1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.mergeVersionAliases(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.mergeVersionAliases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mergeVersionAliases without error using callback', async () => { @@ -545,15 +555,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MergeVersionAliasesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MergeVersionAliasesRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() ); @@ -576,11 +582,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.mergeVersionAliases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mergeVersionAliases with error', async () => { @@ -592,26 +601,25 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MergeVersionAliasesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('MergeVersionAliasesRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.mergeVersionAliases = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.mergeVersionAliases(request), expectedError); - assert( - (client.innerApiCalls.mergeVersionAliases as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.mergeVersionAliases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes mergeVersionAliases with closed client', async () => { @@ -623,7 +631,10 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.MergeVersionAliasesRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('MergeVersionAliasesRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.mergeVersionAliases(request), expectedError); @@ -640,15 +651,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportModelEvaluationRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ImportModelEvaluationRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluation() ); @@ -656,11 +664,14 @@ describe('v1beta1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.importModelEvaluation(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importModelEvaluation without error using callback', async () => { @@ -672,15 +683,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportModelEvaluationRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ImportModelEvaluationRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluation() ); @@ -703,11 +711,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importModelEvaluation with error', async () => { @@ -719,15 +730,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportModelEvaluationRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ImportModelEvaluationRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importModelEvaluation = stubSimpleCall( undefined, @@ -737,11 +745,14 @@ describe('v1beta1.ModelServiceClient', () => { client.importModelEvaluation(request), expectedError ); - assert( - (client.innerApiCalls.importModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importModelEvaluation with closed client', async () => { @@ -753,7 +764,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ImportModelEvaluationRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'ImportModelEvaluationRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -773,15 +788,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchImportModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchImportModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchImportModelEvaluationSlicesResponse() ); @@ -789,11 +801,14 @@ describe('v1beta1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchImportModelEvaluationSlices(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchImportModelEvaluationSlices without error using callback', async () => { @@ -805,15 +820,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchImportModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchImportModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchImportModelEvaluationSlicesResponse() ); @@ -836,11 +848,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchImportModelEvaluationSlices with error', async () => { @@ -852,15 +867,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchImportModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchImportModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchImportModelEvaluationSlices = stubSimpleCall( undefined, @@ -870,11 +882,14 @@ describe('v1beta1.ModelServiceClient', () => { client.batchImportModelEvaluationSlices(request), expectedError ); - assert( - (client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchImportModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchImportModelEvaluationSlices with closed client', async () => { @@ -886,7 +901,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchImportModelEvaluationSlicesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'BatchImportModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -906,15 +925,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelEvaluationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelEvaluationRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluation() ); @@ -922,11 +937,14 @@ describe('v1beta1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getModelEvaluation(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluation without error using callback', async () => { @@ -938,15 +956,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelEvaluationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelEvaluationRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluation() ); @@ -969,11 +983,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluation with error', async () => { @@ -985,26 +1002,25 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelEvaluationRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetModelEvaluationRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getModelEvaluation = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getModelEvaluation(request), expectedError); - assert( - (client.innerApiCalls.getModelEvaluation as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluation with closed client', async () => { @@ -1016,7 +1032,10 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelEvaluationRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetModelEvaluationRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getModelEvaluation(request), expectedError); @@ -1033,15 +1052,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelEvaluationSliceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelEvaluationSliceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluationSlice() ); @@ -1049,11 +1065,14 @@ describe('v1beta1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getModelEvaluationSlice(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelEvaluationSlice as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluationSlice without error using callback', async () => { @@ -1065,15 +1084,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelEvaluationSliceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelEvaluationSliceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluationSlice() ); @@ -1096,11 +1112,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getModelEvaluationSlice as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluationSlice with error', async () => { @@ -1112,15 +1131,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelEvaluationSliceRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetModelEvaluationSliceRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getModelEvaluationSlice = stubSimpleCall( undefined, @@ -1130,11 +1146,14 @@ describe('v1beta1.ModelServiceClient', () => { client.getModelEvaluationSlice(request), expectedError ); - assert( - (client.innerApiCalls.getModelEvaluationSlice as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getModelEvaluationSlice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getModelEvaluationSlice with closed client', async () => { @@ -1146,7 +1165,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetModelEvaluationSliceRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetModelEvaluationSliceRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1166,15 +1189,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UploadModelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UploadModelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1182,11 +1201,14 @@ describe('v1beta1.ModelServiceClient', () => { const [operation] = await client.uploadModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.uploadModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes uploadModel without error using callback', async () => { @@ -1198,15 +1220,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UploadModelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UploadModelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1236,11 +1254,14 @@ describe('v1beta1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.uploadModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes uploadModel with call error', async () => { @@ -1252,26 +1273,25 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UploadModelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UploadModelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.uploadModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.uploadModel(request), expectedError); - assert( - (client.innerApiCalls.uploadModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes uploadModel with LRO error', async () => { @@ -1283,15 +1303,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UploadModelRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('UploadModelRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.uploadModel = stubLongRunningCall( undefined, @@ -1300,11 +1316,14 @@ describe('v1beta1.ModelServiceClient', () => { ); const [operation] = await client.uploadModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.uploadModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uploadModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUploadModelProgress without error', async () => { @@ -1356,15 +1375,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateExplanationDatasetRequest() ); - request.model = ''; - const expectedHeaderRequestParams = 'model='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'UpdateExplanationDatasetRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1373,11 +1389,14 @@ describe('v1beta1.ModelServiceClient', () => { const [operation] = await client.updateExplanationDataset(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateExplanationDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateExplanationDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExplanationDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExplanationDataset without error using callback', async () => { @@ -1389,15 +1408,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateExplanationDatasetRequest() ); - request.model = ''; - const expectedHeaderRequestParams = 'model='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'UpdateExplanationDatasetRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1427,11 +1443,14 @@ describe('v1beta1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateExplanationDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateExplanationDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExplanationDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExplanationDataset with call error', async () => { @@ -1443,15 +1462,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateExplanationDatasetRequest() ); - request.model = ''; - const expectedHeaderRequestParams = 'model='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'UpdateExplanationDatasetRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateExplanationDataset = stubLongRunningCall( undefined, @@ -1461,11 +1477,14 @@ describe('v1beta1.ModelServiceClient', () => { client.updateExplanationDataset(request), expectedError ); - assert( - (client.innerApiCalls.updateExplanationDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateExplanationDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExplanationDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateExplanationDataset with LRO error', async () => { @@ -1477,15 +1496,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateExplanationDatasetRequest() ); - request.model = ''; - const expectedHeaderRequestParams = 'model='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'UpdateExplanationDatasetRequest', + ['model'] + ); + request.model = defaultValue1; + const expectedHeaderRequestParams = `model=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateExplanationDataset = stubLongRunningCall( undefined, @@ -1494,11 +1510,14 @@ describe('v1beta1.ModelServiceClient', () => { ); const [operation] = await client.updateExplanationDataset(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateExplanationDataset as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateExplanationDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateExplanationDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateExplanationDatasetProgress without error', async () => { @@ -1554,15 +1573,9 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1570,11 +1583,14 @@ describe('v1beta1.ModelServiceClient', () => { const [operation] = await client.deleteModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModel without error using callback', async () => { @@ -1586,15 +1602,9 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1624,11 +1634,14 @@ describe('v1beta1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModel with call error', async () => { @@ -1640,26 +1653,23 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteModel(request), expectedError); - assert( - (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModel with LRO error', async () => { @@ -1671,15 +1681,9 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModel = stubLongRunningCall( undefined, @@ -1688,11 +1692,14 @@ describe('v1beta1.ModelServiceClient', () => { ); const [operation] = await client.deleteModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteModelProgress without error', async () => { @@ -1744,15 +1751,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelVersionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelVersionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1761,11 +1764,14 @@ describe('v1beta1.ModelServiceClient', () => { const [operation] = await client.deleteModelVersion(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModelVersion as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelVersion without error using callback', async () => { @@ -1777,15 +1783,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelVersionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelVersionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1815,11 +1817,14 @@ describe('v1beta1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteModelVersion as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelVersion with call error', async () => { @@ -1831,26 +1836,25 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelVersionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelVersionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModelVersion = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteModelVersion(request), expectedError); - assert( - (client.innerApiCalls.deleteModelVersion as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteModelVersion with LRO error', async () => { @@ -1862,15 +1866,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteModelVersionRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteModelVersionRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteModelVersion = stubLongRunningCall( undefined, @@ -1879,11 +1879,14 @@ describe('v1beta1.ModelServiceClient', () => { ); const [operation] = await client.deleteModelVersion(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteModelVersion as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteModelVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteModelVersionProgress without error', async () => { @@ -1938,15 +1941,9 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1954,11 +1951,14 @@ describe('v1beta1.ModelServiceClient', () => { const [operation] = await client.exportModel(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportModel without error using callback', async () => { @@ -1970,15 +1970,9 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2008,42 +2002,42 @@ describe('v1beta1.ModelServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportModel with call error', async () => { const client = new modelserviceModule.v1beta1.ModelServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.aiplatform.v1beta1.ExportModelRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.ExportModelRequest() + ); + const defaultValue1 = getTypeDefaultValue('ExportModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportModel = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.exportModel(request), expectedError); - assert( - (client.innerApiCalls.exportModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportModel with LRO error', async () => { @@ -2055,15 +2049,9 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportModelRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExportModelRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportModel = stubLongRunningCall( undefined, @@ -2072,11 +2060,14 @@ describe('v1beta1.ModelServiceClient', () => { ); const [operation] = await client.exportModel(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.exportModel as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportModel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkExportModelProgress without error', async () => { @@ -2128,15 +2119,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() @@ -2151,11 +2138,14 @@ describe('v1beta1.ModelServiceClient', () => { client.innerApiCalls.listModels = stubSimpleCall(expectedResponse); const [response] = await client.listModels(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModels without error using callback', async () => { @@ -2167,15 +2157,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() @@ -2206,11 +2192,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModels with error', async () => { @@ -2222,26 +2211,25 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModels = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listModels(request), expectedError); - assert( - (client.innerApiCalls.listModels as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModels as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelsStream without error', async () => { @@ -2253,8 +2241,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() @@ -2291,11 +2282,12 @@ describe('v1beta1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModels, request) ); - assert.strictEqual( - (client.descriptors.page.listModels.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2308,8 +2300,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModels.createStream = stubPageStreamingCall( undefined, @@ -2337,11 +2332,12 @@ describe('v1beta1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModels, request) ); - assert.strictEqual( - (client.descriptors.page.listModels.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModels.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2354,8 +2350,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() @@ -2381,11 +2380,12 @@ describe('v1beta1.ModelServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2398,8 +2398,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModels.asyncIterate = stubAsyncIterationCall( undefined, @@ -2418,11 +2421,12 @@ describe('v1beta1.ModelServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listModels.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModels.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2437,15 +2441,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() @@ -2460,11 +2460,14 @@ describe('v1beta1.ModelServiceClient', () => { client.innerApiCalls.listModelVersions = stubSimpleCall(expectedResponse); const [response] = await client.listModelVersions(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelVersions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelVersions without error using callback', async () => { @@ -2476,15 +2479,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() @@ -2515,11 +2514,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelVersions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelVersions with error', async () => { @@ -2531,26 +2533,25 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModelVersions = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listModelVersions(request), expectedError); - assert( - (client.innerApiCalls.listModelVersions as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelVersionsStream without error', async () => { @@ -2562,8 +2563,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() @@ -2600,11 +2604,12 @@ describe('v1beta1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelVersions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listModelVersions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2617,8 +2622,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelVersions.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2644,11 +2652,12 @@ describe('v1beta1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelVersions, request) ); - assert.strictEqual( - ( - client.descriptors.page.listModelVersions.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelVersions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2661,8 +2670,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Model() @@ -2688,11 +2700,12 @@ describe('v1beta1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listModelVersions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2705,8 +2718,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelVersionsRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue('ListModelVersionsRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2723,11 +2739,12 @@ describe('v1beta1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listModelVersions.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelVersions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2742,15 +2759,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluation() @@ -2766,11 +2779,14 @@ describe('v1beta1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listModelEvaluations(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelEvaluations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluations without error using callback', async () => { @@ -2782,15 +2798,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluation() @@ -2823,11 +2835,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelEvaluations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluations with error', async () => { @@ -2839,26 +2854,25 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModelEvaluations = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listModelEvaluations(request), expectedError); - assert( - (client.innerApiCalls.listModelEvaluations as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluationsStream without error', async () => { @@ -2870,8 +2884,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluation() @@ -2911,11 +2928,12 @@ describe('v1beta1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelEvaluations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listModelEvaluations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelEvaluations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2928,8 +2946,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelEvaluations.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2958,11 +2979,12 @@ describe('v1beta1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelEvaluations, request) ); - assert.strictEqual( - ( - client.descriptors.page.listModelEvaluations.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelEvaluations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2975,8 +2997,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluation() @@ -3003,11 +3028,12 @@ describe('v1beta1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listModelEvaluations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelEvaluations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3020,8 +3046,11 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListModelEvaluationsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelEvaluations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3039,11 +3068,12 @@ describe('v1beta1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listModelEvaluations.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listModelEvaluations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3058,15 +3088,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluationSlice() @@ -3082,11 +3109,14 @@ describe('v1beta1.ModelServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listModelEvaluationSlices(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluationSlices without error using callback', async () => { @@ -3098,15 +3128,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluationSlice() @@ -3139,11 +3166,14 @@ describe('v1beta1.ModelServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluationSlices with error', async () => { @@ -3155,15 +3185,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listModelEvaluationSlices = stubSimpleCall( undefined, @@ -3173,11 +3200,14 @@ describe('v1beta1.ModelServiceClient', () => { client.listModelEvaluationSlices(request), expectedError ); - assert( - (client.innerApiCalls.listModelEvaluationSlices as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listModelEvaluationSlices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listModelEvaluationSlicesStream without error', async () => { @@ -3189,8 +3219,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluationSlice() @@ -3233,12 +3267,15 @@ describe('v1beta1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelEvaluationSlices, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelEvaluationSlices .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3251,8 +3288,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelEvaluationSlices.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3284,12 +3325,15 @@ describe('v1beta1.ModelServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listModelEvaluationSlices, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelEvaluationSlices .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3302,8 +3346,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ModelEvaluationSlice() @@ -3331,12 +3379,15 @@ describe('v1beta1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelEvaluationSlices .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3349,8 +3400,12 @@ describe('v1beta1.ModelServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListModelEvaluationSlicesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListModelEvaluationSlicesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listModelEvaluationSlices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3369,12 +3424,15 @@ describe('v1beta1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listModelEvaluationSlices .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3849,12 +3907,15 @@ describe('v1beta1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -3885,12 +3946,15 @@ describe('v1beta1.ModelServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_pipeline_service_v1.ts b/test/gapic_pipeline_service_v1.ts index a751726a..34bf3190 100644 --- a/test/gapic_pipeline_service_v1.ts +++ b/test/gapic_pipeline_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,15 +275,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTrainingPipelineRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTrainingPipelineRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TrainingPipeline() ); @@ -276,11 +288,14 @@ describe('v1.PipelineServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createTrainingPipeline(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrainingPipeline without error using callback', async () => { @@ -292,15 +307,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTrainingPipelineRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTrainingPipelineRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TrainingPipeline() ); @@ -323,11 +335,14 @@ describe('v1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrainingPipeline with error', async () => { @@ -339,15 +354,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTrainingPipelineRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTrainingPipelineRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTrainingPipeline = stubSimpleCall( undefined, @@ -357,11 +369,14 @@ describe('v1.PipelineServiceClient', () => { client.createTrainingPipeline(request), expectedError ); - assert( - (client.innerApiCalls.createTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrainingPipeline with closed client', async () => { @@ -373,7 +388,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTrainingPipelineRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateTrainingPipelineRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -393,15 +412,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrainingPipelineRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TrainingPipeline() ); @@ -409,11 +424,14 @@ describe('v1.PipelineServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getTrainingPipeline(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrainingPipeline without error using callback', async () => { @@ -425,15 +443,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrainingPipelineRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TrainingPipeline() ); @@ -456,11 +470,14 @@ describe('v1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrainingPipeline with error', async () => { @@ -472,26 +489,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrainingPipelineRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTrainingPipeline = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getTrainingPipeline(request), expectedError); - assert( - (client.innerApiCalls.getTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrainingPipeline with closed client', async () => { @@ -503,7 +519,10 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTrainingPipelineRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetTrainingPipelineRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTrainingPipeline(request), expectedError); @@ -520,15 +539,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -536,11 +552,14 @@ describe('v1.PipelineServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.cancelTrainingPipeline(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelTrainingPipeline without error using callback', async () => { @@ -552,15 +571,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -583,11 +599,14 @@ describe('v1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelTrainingPipeline with error', async () => { @@ -599,15 +618,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelTrainingPipeline = stubSimpleCall( undefined, @@ -617,11 +633,14 @@ describe('v1.PipelineServiceClient', () => { client.cancelTrainingPipeline(request), expectedError ); - assert( - (client.innerApiCalls.cancelTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelTrainingPipeline with closed client', async () => { @@ -633,7 +652,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelTrainingPipelineRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'CancelTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -653,26 +676,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreatePipelineJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePipelineJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PipelineJob() ); client.innerApiCalls.createPipelineJob = stubSimpleCall(expectedResponse); const [response] = await client.createPipelineJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPipelineJob without error using callback', async () => { @@ -684,15 +706,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreatePipelineJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePipelineJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PipelineJob() ); @@ -715,11 +733,14 @@ describe('v1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPipelineJob with error', async () => { @@ -731,26 +752,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreatePipelineJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePipelineJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createPipelineJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createPipelineJob(request), expectedError); - assert( - (client.innerApiCalls.createPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPipelineJob with closed client', async () => { @@ -762,7 +782,10 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreatePipelineJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreatePipelineJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createPipelineJob(request), expectedError); @@ -779,26 +802,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PipelineJob() ); client.innerApiCalls.getPipelineJob = stubSimpleCall(expectedResponse); const [response] = await client.getPipelineJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPipelineJob without error using callback', async () => { @@ -810,15 +832,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PipelineJob() ); @@ -841,11 +859,14 @@ describe('v1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPipelineJob with error', async () => { @@ -857,26 +878,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getPipelineJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getPipelineJob(request), expectedError); - assert( - (client.innerApiCalls.getPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPipelineJob with closed client', async () => { @@ -888,7 +908,10 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetPipelineJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getPipelineJob(request), expectedError); @@ -905,26 +928,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.cancelPipelineJob = stubSimpleCall(expectedResponse); const [response] = await client.cancelPipelineJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelPipelineJob without error using callback', async () => { @@ -936,15 +958,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -967,11 +985,14 @@ describe('v1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelPipelineJob with error', async () => { @@ -983,26 +1004,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelPipelineJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.cancelPipelineJob(request), expectedError); - assert( - (client.innerApiCalls.cancelPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelPipelineJob with closed client', async () => { @@ -1014,7 +1034,10 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CancelPipelineJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('CancelPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.cancelPipelineJob(request), expectedError); @@ -1031,15 +1054,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1048,11 +1068,14 @@ describe('v1.PipelineServiceClient', () => { const [operation] = await client.deleteTrainingPipeline(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrainingPipeline without error using callback', async () => { @@ -1064,15 +1087,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1102,11 +1122,14 @@ describe('v1.PipelineServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrainingPipeline with call error', async () => { @@ -1118,15 +1141,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTrainingPipeline = stubLongRunningCall( undefined, @@ -1136,11 +1156,14 @@ describe('v1.PipelineServiceClient', () => { client.deleteTrainingPipeline(request), expectedError ); - assert( - (client.innerApiCalls.deleteTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrainingPipeline with LRO error', async () => { @@ -1152,15 +1175,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTrainingPipeline = stubLongRunningCall( undefined, @@ -1169,11 +1189,14 @@ describe('v1.PipelineServiceClient', () => { ); const [operation] = await client.deleteTrainingPipeline(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTrainingPipelineProgress without error', async () => { @@ -1228,15 +1251,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeletePipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1245,11 +1264,14 @@ describe('v1.PipelineServiceClient', () => { const [operation] = await client.deletePipelineJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePipelineJob without error using callback', async () => { @@ -1261,15 +1283,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeletePipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1299,11 +1317,14 @@ describe('v1.PipelineServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePipelineJob with call error', async () => { @@ -1315,26 +1336,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeletePipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deletePipelineJob = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deletePipelineJob(request), expectedError); - assert( - (client.innerApiCalls.deletePipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePipelineJob with LRO error', async () => { @@ -1346,15 +1366,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeletePipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deletePipelineJob = stubLongRunningCall( undefined, @@ -1363,11 +1379,14 @@ describe('v1.PipelineServiceClient', () => { ); const [operation] = await client.deletePipelineJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deletePipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeletePipelineJobProgress without error', async () => { @@ -1422,15 +1441,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TrainingPipeline() @@ -1446,11 +1462,14 @@ describe('v1.PipelineServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listTrainingPipelines(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTrainingPipelines as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrainingPipelines without error using callback', async () => { @@ -1462,15 +1481,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TrainingPipeline() @@ -1503,11 +1519,14 @@ describe('v1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTrainingPipelines as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrainingPipelines with error', async () => { @@ -1519,15 +1538,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTrainingPipelines = stubSimpleCall( undefined, @@ -1537,11 +1553,14 @@ describe('v1.PipelineServiceClient', () => { client.listTrainingPipelines(request), expectedError ); - assert( - (client.innerApiCalls.listTrainingPipelines as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrainingPipelinesStream without error', async () => { @@ -1553,8 +1572,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TrainingPipeline() @@ -1595,12 +1618,15 @@ describe('v1.PipelineServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTrainingPipelines, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTrainingPipelines .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1613,8 +1639,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTrainingPipelines.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1644,12 +1674,15 @@ describe('v1.PipelineServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTrainingPipelines, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTrainingPipelines .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1662,8 +1695,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TrainingPipeline() @@ -1691,12 +1728,15 @@ describe('v1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTrainingPipelines .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1709,8 +1749,12 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTrainingPipelines.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1729,12 +1773,15 @@ describe('v1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTrainingPipelines .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1749,15 +1796,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.PipelineJob() @@ -1772,11 +1815,14 @@ describe('v1.PipelineServiceClient', () => { client.innerApiCalls.listPipelineJobs = stubSimpleCall(expectedResponse); const [response] = await client.listPipelineJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listPipelineJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPipelineJobs without error using callback', async () => { @@ -1788,15 +1834,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.PipelineJob() @@ -1827,11 +1869,14 @@ describe('v1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listPipelineJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPipelineJobs with error', async () => { @@ -1843,26 +1888,25 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listPipelineJobs = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listPipelineJobs(request), expectedError); - assert( - (client.innerApiCalls.listPipelineJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPipelineJobsStream without error', async () => { @@ -1874,8 +1918,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.PipelineJob() @@ -1912,11 +1959,12 @@ describe('v1.PipelineServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listPipelineJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listPipelineJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPipelineJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1929,8 +1977,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listPipelineJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1956,11 +2007,12 @@ describe('v1.PipelineServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listPipelineJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listPipelineJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPipelineJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1973,8 +2025,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.PipelineJob() @@ -2000,11 +2055,12 @@ describe('v1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listPipelineJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPipelineJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2017,8 +2073,11 @@ describe('v1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listPipelineJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2035,11 +2094,12 @@ describe('v1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listPipelineJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPipelineJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2514,12 +2574,15 @@ describe('v1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -2550,12 +2613,15 @@ describe('v1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_pipeline_service_v1beta1.ts b/test/gapic_pipeline_service_v1beta1.ts index db654bda..059c1e05 100644 --- a/test/gapic_pipeline_service_v1beta1.ts +++ b/test/gapic_pipeline_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,15 +275,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTrainingPipelineRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTrainingPipelineRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TrainingPipeline() ); @@ -276,11 +288,14 @@ describe('v1beta1.PipelineServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createTrainingPipeline(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrainingPipeline without error using callback', async () => { @@ -292,15 +307,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTrainingPipelineRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTrainingPipelineRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TrainingPipeline() ); @@ -323,11 +335,14 @@ describe('v1beta1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrainingPipeline with error', async () => { @@ -339,15 +354,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTrainingPipelineRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTrainingPipelineRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTrainingPipeline = stubSimpleCall( undefined, @@ -357,11 +369,14 @@ describe('v1beta1.PipelineServiceClient', () => { client.createTrainingPipeline(request), expectedError ); - assert( - (client.innerApiCalls.createTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrainingPipeline with closed client', async () => { @@ -373,7 +388,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTrainingPipelineRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateTrainingPipelineRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -393,15 +412,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrainingPipelineRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TrainingPipeline() ); @@ -409,11 +424,14 @@ describe('v1beta1.PipelineServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getTrainingPipeline(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrainingPipeline without error using callback', async () => { @@ -425,15 +443,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrainingPipelineRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TrainingPipeline() ); @@ -456,11 +470,14 @@ describe('v1beta1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrainingPipeline with error', async () => { @@ -472,26 +489,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrainingPipelineRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTrainingPipeline = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getTrainingPipeline(request), expectedError); - assert( - (client.innerApiCalls.getTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrainingPipeline with closed client', async () => { @@ -503,7 +519,10 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTrainingPipelineRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetTrainingPipelineRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTrainingPipeline(request), expectedError); @@ -520,15 +539,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -536,11 +552,14 @@ describe('v1beta1.PipelineServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.cancelTrainingPipeline(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelTrainingPipeline without error using callback', async () => { @@ -552,15 +571,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -583,11 +599,14 @@ describe('v1beta1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelTrainingPipeline with error', async () => { @@ -599,15 +618,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CancelTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelTrainingPipeline = stubSimpleCall( undefined, @@ -617,11 +633,14 @@ describe('v1beta1.PipelineServiceClient', () => { client.cancelTrainingPipeline(request), expectedError ); - assert( - (client.innerApiCalls.cancelTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelTrainingPipeline with closed client', async () => { @@ -633,7 +652,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelTrainingPipelineRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'CancelTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -653,26 +676,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreatePipelineJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePipelineJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PipelineJob() ); client.innerApiCalls.createPipelineJob = stubSimpleCall(expectedResponse); const [response] = await client.createPipelineJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPipelineJob without error using callback', async () => { @@ -684,15 +706,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreatePipelineJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePipelineJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PipelineJob() ); @@ -715,11 +733,14 @@ describe('v1beta1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPipelineJob with error', async () => { @@ -731,26 +752,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreatePipelineJobRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreatePipelineJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createPipelineJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createPipelineJob(request), expectedError); - assert( - (client.innerApiCalls.createPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createPipelineJob with closed client', async () => { @@ -762,7 +782,10 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreatePipelineJobRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreatePipelineJobRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createPipelineJob(request), expectedError); @@ -779,26 +802,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PipelineJob() ); client.innerApiCalls.getPipelineJob = stubSimpleCall(expectedResponse); const [response] = await client.getPipelineJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPipelineJob without error using callback', async () => { @@ -810,15 +832,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PipelineJob() ); @@ -841,11 +859,14 @@ describe('v1beta1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPipelineJob with error', async () => { @@ -857,26 +878,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getPipelineJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getPipelineJob(request), expectedError); - assert( - (client.innerApiCalls.getPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getPipelineJob with closed client', async () => { @@ -888,7 +908,10 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetPipelineJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getPipelineJob(request), expectedError); @@ -905,26 +928,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.cancelPipelineJob = stubSimpleCall(expectedResponse); const [response] = await client.cancelPipelineJob(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelPipelineJob without error using callback', async () => { @@ -936,15 +958,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -967,11 +985,14 @@ describe('v1beta1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.cancelPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelPipelineJob with error', async () => { @@ -983,26 +1004,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelPipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CancelPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.cancelPipelineJob = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.cancelPipelineJob(request), expectedError); - assert( - (client.innerApiCalls.cancelPipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelPipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes cancelPipelineJob with closed client', async () => { @@ -1014,7 +1034,10 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CancelPipelineJobRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('CancelPipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.cancelPipelineJob(request), expectedError); @@ -1031,15 +1054,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1048,11 +1068,14 @@ describe('v1beta1.PipelineServiceClient', () => { const [operation] = await client.deleteTrainingPipeline(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrainingPipeline without error using callback', async () => { @@ -1064,15 +1087,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1102,11 +1122,14 @@ describe('v1beta1.PipelineServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrainingPipeline with call error', async () => { @@ -1118,15 +1141,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTrainingPipeline = stubLongRunningCall( undefined, @@ -1136,11 +1156,14 @@ describe('v1beta1.PipelineServiceClient', () => { client.deleteTrainingPipeline(request), expectedError ); - assert( - (client.innerApiCalls.deleteTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrainingPipeline with LRO error', async () => { @@ -1152,15 +1175,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTrainingPipelineRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTrainingPipelineRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTrainingPipeline = stubLongRunningCall( undefined, @@ -1169,11 +1189,14 @@ describe('v1beta1.PipelineServiceClient', () => { ); const [operation] = await client.deleteTrainingPipeline(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTrainingPipeline as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrainingPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTrainingPipelineProgress without error', async () => { @@ -1228,15 +1251,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeletePipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1245,11 +1264,14 @@ describe('v1beta1.PipelineServiceClient', () => { const [operation] = await client.deletePipelineJob(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePipelineJob without error using callback', async () => { @@ -1261,15 +1283,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeletePipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1299,11 +1317,14 @@ describe('v1beta1.PipelineServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deletePipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePipelineJob with call error', async () => { @@ -1315,26 +1336,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeletePipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deletePipelineJob = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deletePipelineJob(request), expectedError); - assert( - (client.innerApiCalls.deletePipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deletePipelineJob with LRO error', async () => { @@ -1346,15 +1366,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeletePipelineJobRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeletePipelineJobRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deletePipelineJob = stubLongRunningCall( undefined, @@ -1363,11 +1379,14 @@ describe('v1beta1.PipelineServiceClient', () => { ); const [operation] = await client.deletePipelineJob(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deletePipelineJob as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePipelineJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeletePipelineJobProgress without error', async () => { @@ -1422,15 +1441,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TrainingPipeline() @@ -1446,11 +1462,14 @@ describe('v1beta1.PipelineServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listTrainingPipelines(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTrainingPipelines as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrainingPipelines without error using callback', async () => { @@ -1462,15 +1481,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TrainingPipeline() @@ -1503,11 +1519,14 @@ describe('v1beta1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTrainingPipelines as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrainingPipelines with error', async () => { @@ -1519,15 +1538,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTrainingPipelines = stubSimpleCall( undefined, @@ -1537,11 +1553,14 @@ describe('v1beta1.PipelineServiceClient', () => { client.listTrainingPipelines(request), expectedError ); - assert( - (client.innerApiCalls.listTrainingPipelines as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrainingPipelines as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrainingPipelinesStream without error', async () => { @@ -1553,8 +1572,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TrainingPipeline() @@ -1597,12 +1620,15 @@ describe('v1beta1.PipelineServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTrainingPipelines, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTrainingPipelines .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1615,8 +1641,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTrainingPipelines.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1648,12 +1678,15 @@ describe('v1beta1.PipelineServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTrainingPipelines, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTrainingPipelines .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1666,8 +1699,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TrainingPipeline() @@ -1695,12 +1732,15 @@ describe('v1beta1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTrainingPipelines .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1713,8 +1753,12 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrainingPipelinesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTrainingPipelinesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTrainingPipelines.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1733,12 +1777,15 @@ describe('v1beta1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTrainingPipelines .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1753,15 +1800,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PipelineJob() @@ -1776,11 +1819,14 @@ describe('v1beta1.PipelineServiceClient', () => { client.innerApiCalls.listPipelineJobs = stubSimpleCall(expectedResponse); const [response] = await client.listPipelineJobs(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listPipelineJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPipelineJobs without error using callback', async () => { @@ -1792,15 +1838,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PipelineJob() @@ -1833,11 +1875,14 @@ describe('v1beta1.PipelineServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listPipelineJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPipelineJobs with error', async () => { @@ -1849,26 +1894,25 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listPipelineJobs = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listPipelineJobs(request), expectedError); - assert( - (client.innerApiCalls.listPipelineJobs as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPipelineJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listPipelineJobsStream without error', async () => { @@ -1880,8 +1924,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PipelineJob() @@ -1919,11 +1966,12 @@ describe('v1beta1.PipelineServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listPipelineJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listPipelineJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPipelineJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1936,8 +1984,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listPipelineJobs.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1964,11 +2015,12 @@ describe('v1beta1.PipelineServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listPipelineJobs, request) ); - assert.strictEqual( - ( - client.descriptors.page.listPipelineJobs.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPipelineJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1981,8 +2033,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PipelineJob() @@ -2009,11 +2064,12 @@ describe('v1beta1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listPipelineJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPipelineJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2026,8 +2082,11 @@ describe('v1beta1.PipelineServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListPipelineJobsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListPipelineJobsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listPipelineJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2045,11 +2104,12 @@ describe('v1beta1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listPipelineJobs.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listPipelineJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2524,12 +2584,15 @@ describe('v1beta1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -2560,12 +2623,15 @@ describe('v1beta1.PipelineServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_prediction_service_v1.ts b/test/gapic_prediction_service_v1.ts index be5d8d5c..15792681 100644 --- a/test/gapic_prediction_service_v1.ts +++ b/test/gapic_prediction_service_v1.ts @@ -30,6 +30,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -187,26 +202,23 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PredictRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PredictResponse() ); client.innerApiCalls.predict = stubSimpleCall(expectedResponse); const [response] = await client.predict(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.predict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes predict without error using callback', async () => { @@ -218,15 +230,9 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PredictRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PredictResponse() ); @@ -249,11 +255,14 @@ describe('v1.PredictionServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.predict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes predict with error', async () => { @@ -265,23 +274,20 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PredictRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); await assert.rejects(client.predict(request), expectedError); - assert( - (client.innerApiCalls.predict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes predict with closed client', async () => { @@ -293,7 +299,8 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.PredictRequest() ); - request.endpoint = ''; + const defaultValue1 = getTypeDefaultValue('PredictRequest', ['endpoint']); + request.endpoint = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.predict(request), expectedError); @@ -310,26 +317,25 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RawPredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RawPredictRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.api.HttpBody() ); client.innerApiCalls.rawPredict = stubSimpleCall(expectedResponse); const [response] = await client.rawPredict(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.rawPredict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rawPredict without error using callback', async () => { @@ -341,15 +347,11 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RawPredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RawPredictRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.api.HttpBody() ); @@ -369,11 +371,14 @@ describe('v1.PredictionServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.rawPredict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rawPredict with error', async () => { @@ -385,26 +390,25 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RawPredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RawPredictRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.rawPredict = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.rawPredict(request), expectedError); - assert( - (client.innerApiCalls.rawPredict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rawPredict with closed client', async () => { @@ -416,7 +420,10 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.RawPredictRequest() ); - request.endpoint = ''; + const defaultValue1 = getTypeDefaultValue('RawPredictRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.rawPredict(request), expectedError); @@ -433,26 +440,23 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExplainRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExplainRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExplainResponse() ); client.innerApiCalls.explain = stubSimpleCall(expectedResponse); const [response] = await client.explain(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.explain as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.explain as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.explain as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes explain without error using callback', async () => { @@ -464,15 +468,9 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExplainRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExplainRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExplainResponse() ); @@ -495,11 +493,14 @@ describe('v1.PredictionServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.explain as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = (client.innerApiCalls.explain as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.explain as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes explain with error', async () => { @@ -511,23 +512,20 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExplainRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExplainRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.explain = stubSimpleCall(undefined, expectedError); await assert.rejects(client.explain(request), expectedError); - assert( - (client.innerApiCalls.explain as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.explain as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.explain as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes explain with closed client', async () => { @@ -539,7 +537,8 @@ describe('v1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExplainRequest() ); - request.endpoint = ''; + const defaultValue1 = getTypeDefaultValue('ExplainRequest', ['endpoint']); + request.endpoint = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.explain(request), expectedError); @@ -1016,12 +1015,15 @@ describe('v1.PredictionServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1052,12 +1054,15 @@ describe('v1.PredictionServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_prediction_service_v1beta1.ts b/test/gapic_prediction_service_v1beta1.ts index 6ee97a53..d442dcea 100644 --- a/test/gapic_prediction_service_v1beta1.ts +++ b/test/gapic_prediction_service_v1beta1.ts @@ -30,6 +30,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -195,26 +210,23 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PredictRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PredictResponse() ); client.innerApiCalls.predict = stubSimpleCall(expectedResponse); const [response] = await client.predict(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.predict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes predict without error using callback', async () => { @@ -227,15 +239,9 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PredictRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PredictResponse() ); @@ -258,11 +264,14 @@ describe('v1beta1.PredictionServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.predict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes predict with error', async () => { @@ -275,23 +284,20 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('PredictRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.predict = stubSimpleCall(undefined, expectedError); await assert.rejects(client.predict(request), expectedError); - assert( - (client.innerApiCalls.predict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.predict as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.predict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes predict with closed client', async () => { @@ -304,7 +310,8 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.PredictRequest() ); - request.endpoint = ''; + const defaultValue1 = getTypeDefaultValue('PredictRequest', ['endpoint']); + request.endpoint = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.predict(request), expectedError); @@ -322,26 +329,25 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RawPredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RawPredictRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.api.HttpBody() ); client.innerApiCalls.rawPredict = stubSimpleCall(expectedResponse); const [response] = await client.rawPredict(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.rawPredict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rawPredict without error using callback', async () => { @@ -354,15 +360,11 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RawPredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RawPredictRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.api.HttpBody() ); @@ -382,11 +384,14 @@ describe('v1beta1.PredictionServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.rawPredict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rawPredict with error', async () => { @@ -399,26 +404,25 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RawPredictRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('RawPredictRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.rawPredict = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.rawPredict(request), expectedError); - assert( - (client.innerApiCalls.rawPredict as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawPredict as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes rawPredict with closed client', async () => { @@ -431,7 +435,10 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.RawPredictRequest() ); - request.endpoint = ''; + const defaultValue1 = getTypeDefaultValue('RawPredictRequest', [ + 'endpoint', + ]); + request.endpoint = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.rawPredict(request), expectedError); @@ -449,26 +456,23 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExplainRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExplainRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExplainResponse() ); client.innerApiCalls.explain = stubSimpleCall(expectedResponse); const [response] = await client.explain(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.explain as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.explain as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.explain as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes explain without error using callback', async () => { @@ -481,15 +485,9 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExplainRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExplainRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExplainResponse() ); @@ -512,11 +510,14 @@ describe('v1beta1.PredictionServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.explain as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = (client.innerApiCalls.explain as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.explain as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes explain with error', async () => { @@ -529,23 +530,20 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExplainRequest() ); - request.endpoint = ''; - const expectedHeaderRequestParams = 'endpoint='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ExplainRequest', ['endpoint']); + request.endpoint = defaultValue1; + const expectedHeaderRequestParams = `endpoint=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.explain = stubSimpleCall(undefined, expectedError); await assert.rejects(client.explain(request), expectedError); - assert( - (client.innerApiCalls.explain as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = (client.innerApiCalls.explain as SinonStub).getCall( + 0 + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.explain as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes explain with closed client', async () => { @@ -558,7 +556,8 @@ describe('v1beta1.PredictionServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExplainRequest() ); - request.endpoint = ''; + const defaultValue1 = getTypeDefaultValue('ExplainRequest', ['endpoint']); + request.endpoint = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.explain(request), expectedError); @@ -1048,12 +1047,15 @@ describe('v1beta1.PredictionServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1085,12 +1087,15 @@ describe('v1beta1.PredictionServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_specialist_pool_service_v1.ts b/test/gapic_specialist_pool_service_v1.ts index 22821057..c1c91378 100644 --- a/test/gapic_specialist_pool_service_v1.ts +++ b/test/gapic_specialist_pool_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -269,26 +284,25 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SpecialistPool() ); client.innerApiCalls.getSpecialistPool = stubSimpleCall(expectedResponse); const [response] = await client.getSpecialistPool(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSpecialistPool without error using callback', async () => { @@ -301,15 +315,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SpecialistPool() ); @@ -332,11 +342,14 @@ describe('v1.SpecialistPoolServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSpecialistPool with error', async () => { @@ -349,26 +362,25 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getSpecialistPool = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getSpecialistPool(request), expectedError); - assert( - (client.innerApiCalls.getSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSpecialistPool with closed client', async () => { @@ -381,7 +393,10 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetSpecialistPoolRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getSpecialistPool(request), expectedError); @@ -399,15 +414,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateSpecialistPoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSpecialistPoolRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -416,11 +427,14 @@ describe('v1.SpecialistPoolServiceClient', () => { const [operation] = await client.createSpecialistPool(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSpecialistPool without error using callback', async () => { @@ -433,15 +447,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateSpecialistPoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSpecialistPoolRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -471,11 +481,14 @@ describe('v1.SpecialistPoolServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSpecialistPool with call error', async () => { @@ -488,26 +501,25 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateSpecialistPoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSpecialistPoolRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createSpecialistPool = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createSpecialistPool(request), expectedError); - assert( - (client.innerApiCalls.createSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSpecialistPool with LRO error', async () => { @@ -520,15 +532,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateSpecialistPoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSpecialistPoolRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createSpecialistPool = stubLongRunningCall( undefined, @@ -537,11 +545,14 @@ describe('v1.SpecialistPoolServiceClient', () => { ); const [operation] = await client.createSpecialistPool(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateSpecialistPoolProgress without error', async () => { @@ -599,15 +610,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -616,11 +623,14 @@ describe('v1.SpecialistPoolServiceClient', () => { const [operation] = await client.deleteSpecialistPool(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSpecialistPool without error using callback', async () => { @@ -633,15 +643,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -671,11 +677,14 @@ describe('v1.SpecialistPoolServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSpecialistPool with call error', async () => { @@ -688,26 +697,25 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteSpecialistPool = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteSpecialistPool(request), expectedError); - assert( - (client.innerApiCalls.deleteSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSpecialistPool with LRO error', async () => { @@ -720,15 +728,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteSpecialistPool = stubLongRunningCall( undefined, @@ -737,11 +741,14 @@ describe('v1.SpecialistPoolServiceClient', () => { ); const [operation] = await client.deleteSpecialistPool(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteSpecialistPoolProgress without error', async () => { @@ -799,16 +806,13 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateSpecialistPoolRequest() ); - request.specialistPool = {}; - request.specialistPool.name = ''; - const expectedHeaderRequestParams = 'specialist_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.specialistPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateSpecialistPoolRequest', [ + 'specialistPool', + 'name', + ]); + request.specialistPool.name = defaultValue1; + const expectedHeaderRequestParams = `specialist_pool.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -817,11 +821,14 @@ describe('v1.SpecialistPoolServiceClient', () => { const [operation] = await client.updateSpecialistPool(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateSpecialistPool without error using callback', async () => { @@ -834,16 +841,13 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateSpecialistPoolRequest() ); - request.specialistPool = {}; - request.specialistPool.name = ''; - const expectedHeaderRequestParams = 'specialist_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.specialistPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateSpecialistPoolRequest', [ + 'specialistPool', + 'name', + ]); + request.specialistPool.name = defaultValue1; + const expectedHeaderRequestParams = `specialist_pool.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -873,11 +877,14 @@ describe('v1.SpecialistPoolServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateSpecialistPool with call error', async () => { @@ -890,27 +897,27 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateSpecialistPoolRequest() ); - request.specialistPool = {}; - request.specialistPool.name = ''; - const expectedHeaderRequestParams = 'specialist_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.specialistPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateSpecialistPoolRequest', [ + 'specialistPool', + 'name', + ]); + request.specialistPool.name = defaultValue1; + const expectedHeaderRequestParams = `specialist_pool.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateSpecialistPool = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateSpecialistPool(request), expectedError); - assert( - (client.innerApiCalls.updateSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateSpecialistPool with LRO error', async () => { @@ -923,16 +930,13 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateSpecialistPoolRequest() ); - request.specialistPool = {}; - request.specialistPool.name = ''; - const expectedHeaderRequestParams = 'specialist_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.specialistPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateSpecialistPoolRequest', [ + 'specialistPool', + 'name', + ]); + request.specialistPool.name = defaultValue1; + const expectedHeaderRequestParams = `specialist_pool.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateSpecialistPool = stubLongRunningCall( undefined, @@ -941,11 +945,14 @@ describe('v1.SpecialistPoolServiceClient', () => { ); const [operation] = await client.updateSpecialistPool(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateSpecialistPoolProgress without error', async () => { @@ -1003,15 +1010,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.SpecialistPool() @@ -1027,11 +1030,14 @@ describe('v1.SpecialistPoolServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listSpecialistPools(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSpecialistPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSpecialistPools without error using callback', async () => { @@ -1044,15 +1050,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.SpecialistPool() @@ -1083,11 +1085,14 @@ describe('v1.SpecialistPoolServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSpecialistPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSpecialistPools with error', async () => { @@ -1100,26 +1105,25 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listSpecialistPools = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listSpecialistPools(request), expectedError); - assert( - (client.innerApiCalls.listSpecialistPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSpecialistPoolsStream without error', async () => { @@ -1132,8 +1136,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.SpecialistPool() @@ -1171,11 +1178,12 @@ describe('v1.SpecialistPoolServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSpecialistPools, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSpecialistPools.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSpecialistPools.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1189,8 +1197,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSpecialistPools.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1217,11 +1228,12 @@ describe('v1.SpecialistPoolServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSpecialistPools, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSpecialistPools.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSpecialistPools.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1235,8 +1247,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.SpecialistPool() @@ -1262,11 +1277,12 @@ describe('v1.SpecialistPoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSpecialistPools.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSpecialistPools.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1280,8 +1296,11 @@ describe('v1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSpecialistPools.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1299,11 +1318,12 @@ describe('v1.SpecialistPoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSpecialistPools.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSpecialistPools.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1791,12 +1811,15 @@ describe('v1.SpecialistPoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1828,12 +1851,15 @@ describe('v1.SpecialistPoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_specialist_pool_service_v1beta1.ts b/test/gapic_specialist_pool_service_v1beta1.ts index 431440ed..6317c3d7 100644 --- a/test/gapic_specialist_pool_service_v1beta1.ts +++ b/test/gapic_specialist_pool_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -271,26 +286,25 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SpecialistPool() ); client.innerApiCalls.getSpecialistPool = stubSimpleCall(expectedResponse); const [response] = await client.getSpecialistPool(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSpecialistPool without error using callback', async () => { @@ -303,15 +317,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SpecialistPool() ); @@ -334,11 +344,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSpecialistPool with error', async () => { @@ -351,26 +364,25 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getSpecialistPool = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getSpecialistPool(request), expectedError); - assert( - (client.innerApiCalls.getSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getSpecialistPool with closed client', async () => { @@ -383,7 +395,10 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetSpecialistPoolRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getSpecialistPool(request), expectedError); @@ -401,15 +416,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateSpecialistPoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSpecialistPoolRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -418,11 +429,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const [operation] = await client.createSpecialistPool(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSpecialistPool without error using callback', async () => { @@ -435,15 +449,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateSpecialistPoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSpecialistPoolRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -473,11 +483,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSpecialistPool with call error', async () => { @@ -490,26 +503,25 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateSpecialistPoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSpecialistPoolRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createSpecialistPool = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createSpecialistPool(request), expectedError); - assert( - (client.innerApiCalls.createSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createSpecialistPool with LRO error', async () => { @@ -522,15 +534,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateSpecialistPoolRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateSpecialistPoolRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createSpecialistPool = stubLongRunningCall( undefined, @@ -539,11 +547,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { ); const [operation] = await client.createSpecialistPool(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateSpecialistPoolProgress without error', async () => { @@ -601,15 +612,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -618,11 +625,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const [operation] = await client.deleteSpecialistPool(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSpecialistPool without error using callback', async () => { @@ -635,15 +645,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -673,11 +679,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSpecialistPool with call error', async () => { @@ -690,26 +699,25 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteSpecialistPool = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteSpecialistPool(request), expectedError); - assert( - (client.innerApiCalls.deleteSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteSpecialistPool with LRO error', async () => { @@ -722,15 +730,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteSpecialistPoolRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteSpecialistPoolRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteSpecialistPool = stubLongRunningCall( undefined, @@ -739,11 +743,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { ); const [operation] = await client.deleteSpecialistPool(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteSpecialistPoolProgress without error', async () => { @@ -801,16 +808,13 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateSpecialistPoolRequest() ); - request.specialistPool = {}; - request.specialistPool.name = ''; - const expectedHeaderRequestParams = 'specialist_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.specialistPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateSpecialistPoolRequest', [ + 'specialistPool', + 'name', + ]); + request.specialistPool.name = defaultValue1; + const expectedHeaderRequestParams = `specialist_pool.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -819,11 +823,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const [operation] = await client.updateSpecialistPool(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateSpecialistPool without error using callback', async () => { @@ -836,16 +843,13 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateSpecialistPoolRequest() ); - request.specialistPool = {}; - request.specialistPool.name = ''; - const expectedHeaderRequestParams = 'specialist_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.specialistPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateSpecialistPoolRequest', [ + 'specialistPool', + 'name', + ]); + request.specialistPool.name = defaultValue1; + const expectedHeaderRequestParams = `specialist_pool.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -875,11 +879,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateSpecialistPool with call error', async () => { @@ -892,27 +899,27 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateSpecialistPoolRequest() ); - request.specialistPool = {}; - request.specialistPool.name = ''; - const expectedHeaderRequestParams = 'specialist_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.specialistPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateSpecialistPoolRequest', [ + 'specialistPool', + 'name', + ]); + request.specialistPool.name = defaultValue1; + const expectedHeaderRequestParams = `specialist_pool.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateSpecialistPool = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateSpecialistPool(request), expectedError); - assert( - (client.innerApiCalls.updateSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateSpecialistPool with LRO error', async () => { @@ -925,16 +932,13 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateSpecialistPoolRequest() ); - request.specialistPool = {}; - request.specialistPool.name = ''; - const expectedHeaderRequestParams = 'specialist_pool.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.specialistPool ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateSpecialistPoolRequest', [ + 'specialistPool', + 'name', + ]); + request.specialistPool.name = defaultValue1; + const expectedHeaderRequestParams = `specialist_pool.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateSpecialistPool = stubLongRunningCall( undefined, @@ -943,11 +947,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { ); const [operation] = await client.updateSpecialistPool(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateSpecialistPool as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateSpecialistPool as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateSpecialistPoolProgress without error', async () => { @@ -1005,15 +1012,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SpecialistPool() @@ -1029,11 +1032,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listSpecialistPools(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSpecialistPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSpecialistPools without error using callback', async () => { @@ -1046,15 +1052,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SpecialistPool() @@ -1087,11 +1089,14 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listSpecialistPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSpecialistPools with error', async () => { @@ -1104,26 +1109,25 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listSpecialistPools = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listSpecialistPools(request), expectedError); - assert( - (client.innerApiCalls.listSpecialistPools as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSpecialistPools as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listSpecialistPoolsStream without error', async () => { @@ -1136,8 +1140,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SpecialistPool() @@ -1175,11 +1182,12 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSpecialistPools, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSpecialistPools.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSpecialistPools.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1193,8 +1201,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSpecialistPools.createStream = stubPageStreamingCall(undefined, expectedError); @@ -1221,11 +1232,12 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listSpecialistPools, request) ); - assert.strictEqual( - ( - client.descriptors.page.listSpecialistPools.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSpecialistPools.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1239,8 +1251,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SpecialistPool() @@ -1267,11 +1282,12 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSpecialistPools.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSpecialistPools.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -1285,8 +1301,11 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListSpecialistPoolsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListSpecialistPoolsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listSpecialistPools.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -1304,11 +1323,12 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listSpecialistPools.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listSpecialistPools.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -1796,12 +1816,15 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -1833,12 +1856,15 @@ describe('v1beta1.SpecialistPoolServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_tensorboard_service_v1.ts b/test/gapic_tensorboard_service_v1.ts index 275f41c8..b02dfee5 100644 --- a/test/gapic_tensorboard_service_v1.ts +++ b/test/gapic_tensorboard_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -281,26 +296,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Tensorboard() ); client.innerApiCalls.getTensorboard = stubSimpleCall(expectedResponse); const [response] = await client.getTensorboard(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboard without error using callback', async () => { @@ -312,15 +326,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Tensorboard() ); @@ -343,11 +353,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboard with error', async () => { @@ -359,26 +372,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTensorboard = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getTensorboard(request), expectedError); - assert( - (client.innerApiCalls.getTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboard with closed client', async () => { @@ -390,7 +402,10 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTensorboard(request), expectedError); @@ -407,15 +422,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardExperimentRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardExperimentRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() ); @@ -423,11 +435,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createTensorboardExperiment(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardExperiment without error using callback', async () => { @@ -439,15 +454,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardExperimentRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardExperimentRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() ); @@ -470,11 +482,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardExperiment with error', async () => { @@ -486,15 +501,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardExperimentRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardExperimentRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboardExperiment = stubSimpleCall( undefined, @@ -504,11 +516,14 @@ describe('v1.TensorboardServiceClient', () => { client.createTensorboardExperiment(request), expectedError ); - assert( - (client.innerApiCalls.createTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardExperiment with closed client', async () => { @@ -520,7 +535,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardExperimentRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardExperimentRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -540,15 +559,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() ); @@ -556,11 +572,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getTensorboardExperiment(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardExperiment without error using callback', async () => { @@ -572,15 +591,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() ); @@ -603,11 +619,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardExperiment with error', async () => { @@ -619,15 +638,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTensorboardExperiment = stubSimpleCall( undefined, @@ -637,11 +653,14 @@ describe('v1.TensorboardServiceClient', () => { client.getTensorboardExperiment(request), expectedError ); - assert( - (client.innerApiCalls.getTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardExperiment with closed client', async () => { @@ -653,7 +672,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardExperimentRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -673,16 +696,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardExperimentRequest() ); - request.tensorboardExperiment = {}; - request.tensorboardExperiment.name = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardExperiment ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardExperimentRequest', + ['tensorboardExperiment', 'name'] + ); + request.tensorboardExperiment.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() ); @@ -690,11 +710,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.updateTensorboardExperiment(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardExperiment without error using callback', async () => { @@ -706,16 +729,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardExperimentRequest() ); - request.tensorboardExperiment = {}; - request.tensorboardExperiment.name = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardExperiment ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardExperimentRequest', + ['tensorboardExperiment', 'name'] + ); + request.tensorboardExperiment.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() ); @@ -738,11 +758,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardExperiment with error', async () => { @@ -754,16 +777,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardExperimentRequest() ); - request.tensorboardExperiment = {}; - request.tensorboardExperiment.name = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardExperiment ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardExperimentRequest', + ['tensorboardExperiment', 'name'] + ); + request.tensorboardExperiment.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboardExperiment = stubSimpleCall( undefined, @@ -773,11 +793,14 @@ describe('v1.TensorboardServiceClient', () => { client.updateTensorboardExperiment(request), expectedError ); - assert( - (client.innerApiCalls.updateTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardExperiment with closed client', async () => { @@ -789,8 +812,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardExperimentRequest() ); - request.tensorboardExperiment = {}; - request.tensorboardExperiment.name = ''; + request.tensorboardExperiment ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardExperimentRequest', + ['tensorboardExperiment', 'name'] + ); + request.tensorboardExperiment.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -810,15 +837,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardRunRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRunRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() ); @@ -826,11 +849,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createTensorboardRun(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardRun without error using callback', async () => { @@ -842,15 +868,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardRunRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRunRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() ); @@ -873,11 +895,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardRun with error', async () => { @@ -889,26 +914,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardRunRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRunRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboardRun = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createTensorboardRun(request), expectedError); - assert( - (client.innerApiCalls.createTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardRun with closed client', async () => { @@ -920,7 +944,10 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardRunRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRunRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createTensorboardRun(request), expectedError); @@ -937,15 +964,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardRunsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardRunsResponse() ); @@ -953,11 +977,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchCreateTensorboardRuns(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardRuns without error using callback', async () => { @@ -969,15 +996,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardRunsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardRunsResponse() ); @@ -1000,11 +1024,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardRuns with error', async () => { @@ -1016,15 +1043,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardRunsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateTensorboardRuns = stubSimpleCall( undefined, @@ -1034,11 +1058,14 @@ describe('v1.TensorboardServiceClient', () => { client.batchCreateTensorboardRuns(request), expectedError ); - assert( - (client.innerApiCalls.batchCreateTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardRuns with closed client', async () => { @@ -1050,7 +1077,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardRunsRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardRunsRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1070,26 +1101,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() ); client.innerApiCalls.getTensorboardRun = stubSimpleCall(expectedResponse); const [response] = await client.getTensorboardRun(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardRun without error using callback', async () => { @@ -1101,15 +1131,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() ); @@ -1132,11 +1158,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardRun with error', async () => { @@ -1148,26 +1177,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTensorboardRun = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getTensorboardRun(request), expectedError); - assert( - (client.innerApiCalls.getTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardRun with closed client', async () => { @@ -1179,7 +1207,10 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardRunRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTensorboardRun(request), expectedError); @@ -1196,16 +1227,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardRunRequest() ); - request.tensorboardRun = {}; - request.tensorboardRun.name = ''; - const expectedHeaderRequestParams = 'tensorboard_run.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardRun ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRunRequest', [ + 'tensorboardRun', + 'name', + ]); + request.tensorboardRun.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() ); @@ -1213,11 +1241,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.updateTensorboardRun(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardRun without error using callback', async () => { @@ -1229,16 +1260,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardRunRequest() ); - request.tensorboardRun = {}; - request.tensorboardRun.name = ''; - const expectedHeaderRequestParams = 'tensorboard_run.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardRun ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRunRequest', [ + 'tensorboardRun', + 'name', + ]); + request.tensorboardRun.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() ); @@ -1261,11 +1289,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardRun with error', async () => { @@ -1277,27 +1308,27 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardRunRequest() ); - request.tensorboardRun = {}; - request.tensorboardRun.name = ''; - const expectedHeaderRequestParams = 'tensorboard_run.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardRun ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRunRequest', [ + 'tensorboardRun', + 'name', + ]); + request.tensorboardRun.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboardRun = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateTensorboardRun(request), expectedError); - assert( - (client.innerApiCalls.updateTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardRun with closed client', async () => { @@ -1309,8 +1340,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardRunRequest() ); - request.tensorboardRun = {}; - request.tensorboardRun.name = ''; + request.tensorboardRun ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRunRequest', [ + 'tensorboardRun', + 'name', + ]); + request.tensorboardRun.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateTensorboardRun(request), expectedError); @@ -1327,15 +1362,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardTimeSeriesResponse() ); @@ -1343,11 +1375,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchCreateTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardTimeSeries without error using callback', async () => { @@ -1359,15 +1394,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardTimeSeriesResponse() ); @@ -1390,11 +1422,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardTimeSeries with error', async () => { @@ -1406,15 +1441,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateTensorboardTimeSeries = stubSimpleCall( undefined, @@ -1424,11 +1456,14 @@ describe('v1.TensorboardServiceClient', () => { client.batchCreateTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardTimeSeries with closed client', async () => { @@ -1440,7 +1475,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchCreateTensorboardTimeSeriesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1460,15 +1499,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() ); @@ -1476,11 +1512,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardTimeSeries without error using callback', async () => { @@ -1492,15 +1531,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() ); @@ -1523,11 +1559,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardTimeSeries with error', async () => { @@ -1539,15 +1578,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboardTimeSeries = stubSimpleCall( undefined, @@ -1557,11 +1593,14 @@ describe('v1.TensorboardServiceClient', () => { client.createTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.createTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardTimeSeries with closed client', async () => { @@ -1573,7 +1612,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardTimeSeriesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1593,15 +1636,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() ); @@ -1609,11 +1649,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardTimeSeries without error using callback', async () => { @@ -1625,15 +1668,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() ); @@ -1656,11 +1696,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardTimeSeries with error', async () => { @@ -1672,15 +1715,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTensorboardTimeSeries = stubSimpleCall( undefined, @@ -1690,11 +1730,14 @@ describe('v1.TensorboardServiceClient', () => { client.getTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.getTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardTimeSeries with closed client', async () => { @@ -1706,7 +1749,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTensorboardTimeSeriesRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1726,16 +1773,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardTimeSeriesRequest() ); - request.tensorboardTimeSeries = {}; - request.tensorboardTimeSeries.name = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardTimeSeries ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardTimeSeriesRequest', + ['tensorboardTimeSeries', 'name'] + ); + request.tensorboardTimeSeries.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() ); @@ -1743,11 +1787,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.updateTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardTimeSeries without error using callback', async () => { @@ -1759,16 +1806,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardTimeSeriesRequest() ); - request.tensorboardTimeSeries = {}; - request.tensorboardTimeSeries.name = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardTimeSeries ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardTimeSeriesRequest', + ['tensorboardTimeSeries', 'name'] + ); + request.tensorboardTimeSeries.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() ); @@ -1791,11 +1835,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardTimeSeries with error', async () => { @@ -1807,16 +1854,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardTimeSeriesRequest() ); - request.tensorboardTimeSeries = {}; - request.tensorboardTimeSeries.name = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardTimeSeries ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardTimeSeriesRequest', + ['tensorboardTimeSeries', 'name'] + ); + request.tensorboardTimeSeries.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboardTimeSeries = stubSimpleCall( undefined, @@ -1826,11 +1870,14 @@ describe('v1.TensorboardServiceClient', () => { client.updateTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.updateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardTimeSeries with closed client', async () => { @@ -1842,8 +1889,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardTimeSeriesRequest() ); - request.tensorboardTimeSeries = {}; - request.tensorboardTimeSeries.name = ''; + request.tensorboardTimeSeries ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardTimeSeriesRequest', + ['tensorboardTimeSeries', 'name'] + ); + request.tensorboardTimeSeries.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1863,15 +1914,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadTensorboardTimeSeriesDataRequest() ); - request.tensorboard = ''; - const expectedHeaderRequestParams = 'tensorboard='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadTensorboardTimeSeriesDataRequest', + ['tensorboard'] + ); + request.tensorboard = defaultValue1; + const expectedHeaderRequestParams = `tensorboard=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadTensorboardTimeSeriesDataResponse() ); @@ -1881,11 +1929,14 @@ describe('v1.TensorboardServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadTensorboardTimeSeriesData without error using callback', async () => { @@ -1897,15 +1948,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadTensorboardTimeSeriesDataRequest() ); - request.tensorboard = ''; - const expectedHeaderRequestParams = 'tensorboard='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadTensorboardTimeSeriesDataRequest', + ['tensorboard'] + ); + request.tensorboard = defaultValue1; + const expectedHeaderRequestParams = `tensorboard=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadTensorboardTimeSeriesDataResponse() ); @@ -1928,11 +1976,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadTensorboardTimeSeriesData with error', async () => { @@ -1944,15 +1995,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadTensorboardTimeSeriesDataRequest() ); - request.tensorboard = ''; - const expectedHeaderRequestParams = 'tensorboard='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadTensorboardTimeSeriesDataRequest', + ['tensorboard'] + ); + request.tensorboard = defaultValue1; + const expectedHeaderRequestParams = `tensorboard=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchReadTensorboardTimeSeriesData = stubSimpleCall( undefined, @@ -1962,11 +2010,14 @@ describe('v1.TensorboardServiceClient', () => { client.batchReadTensorboardTimeSeriesData(request), expectedError ); - assert( - (client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadTensorboardTimeSeriesData with closed client', async () => { @@ -1978,7 +2029,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.BatchReadTensorboardTimeSeriesDataRequest() ); - request.tensorboard = ''; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadTensorboardTimeSeriesDataRequest', + ['tensorboard'] + ); + request.tensorboard = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1998,15 +2053,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardTimeSeriesDataResponse() ); @@ -2014,11 +2066,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.readTensorboardTimeSeriesData(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardTimeSeriesData without error using callback', async () => { @@ -2030,15 +2085,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardTimeSeriesDataResponse() ); @@ -2061,11 +2113,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardTimeSeriesData with error', async () => { @@ -2077,15 +2132,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.readTensorboardTimeSeriesData = stubSimpleCall( undefined, @@ -2095,11 +2147,14 @@ describe('v1.TensorboardServiceClient', () => { client.readTensorboardTimeSeriesData(request), expectedError ); - assert( - (client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardTimeSeriesData with closed client', async () => { @@ -2111,7 +2166,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2131,15 +2190,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardExperimentDataRequest() ); - request.tensorboardExperiment = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardExperimentDataRequest', + ['tensorboardExperiment'] + ); + request.tensorboardExperiment = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardExperimentDataResponse() ); @@ -2147,11 +2203,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.writeTensorboardExperimentData(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeTensorboardExperimentData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardExperimentData without error using callback', async () => { @@ -2163,15 +2222,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardExperimentDataRequest() ); - request.tensorboardExperiment = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardExperimentDataRequest', + ['tensorboardExperiment'] + ); + request.tensorboardExperiment = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardExperimentDataResponse() ); @@ -2194,11 +2250,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeTensorboardExperimentData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardExperimentData with error', async () => { @@ -2210,15 +2269,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardExperimentDataRequest() ); - request.tensorboardExperiment = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardExperimentDataRequest', + ['tensorboardExperiment'] + ); + request.tensorboardExperiment = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.writeTensorboardExperimentData = stubSimpleCall( undefined, @@ -2228,11 +2284,14 @@ describe('v1.TensorboardServiceClient', () => { client.writeTensorboardExperimentData(request), expectedError ); - assert( - (client.innerApiCalls.writeTensorboardExperimentData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardExperimentData with closed client', async () => { @@ -2244,7 +2303,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardExperimentDataRequest() ); - request.tensorboardExperiment = ''; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardExperimentDataRequest', + ['tensorboardExperiment'] + ); + request.tensorboardExperiment = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2264,15 +2327,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardRunDataRequest() ); - request.tensorboardRun = ''; - const expectedHeaderRequestParams = 'tensorboard_run='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardRunDataRequest', + ['tensorboardRun'] + ); + request.tensorboardRun = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardRunDataResponse() ); @@ -2280,11 +2340,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.writeTensorboardRunData(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeTensorboardRunData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardRunData without error using callback', async () => { @@ -2296,15 +2359,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardRunDataRequest() ); - request.tensorboardRun = ''; - const expectedHeaderRequestParams = 'tensorboard_run='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardRunDataRequest', + ['tensorboardRun'] + ); + request.tensorboardRun = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardRunDataResponse() ); @@ -2327,11 +2387,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeTensorboardRunData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardRunData with error', async () => { @@ -2343,15 +2406,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardRunDataRequest() ); - request.tensorboardRun = ''; - const expectedHeaderRequestParams = 'tensorboard_run='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardRunDataRequest', + ['tensorboardRun'] + ); + request.tensorboardRun = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.writeTensorboardRunData = stubSimpleCall( undefined, @@ -2361,11 +2421,14 @@ describe('v1.TensorboardServiceClient', () => { client.writeTensorboardRunData(request), expectedError ); - assert( - (client.innerApiCalls.writeTensorboardRunData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardRunData with closed client', async () => { @@ -2377,7 +2440,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.WriteTensorboardRunDataRequest() ); - request.tensorboardRun = ''; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardRunDataRequest', + ['tensorboardRun'] + ); + request.tensorboardRun = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2397,15 +2464,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2414,11 +2477,14 @@ describe('v1.TensorboardServiceClient', () => { const [operation] = await client.createTensorboard(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboard without error using callback', async () => { @@ -2430,15 +2496,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2468,11 +2530,14 @@ describe('v1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboard with call error', async () => { @@ -2484,26 +2549,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboard = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createTensorboard(request), expectedError); - assert( - (client.innerApiCalls.createTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboard with LRO error', async () => { @@ -2515,15 +2579,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTensorboardRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboard = stubLongRunningCall( undefined, @@ -2532,11 +2592,14 @@ describe('v1.TensorboardServiceClient', () => { ); const [operation] = await client.createTensorboard(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateTensorboardProgress without error', async () => { @@ -2591,16 +2654,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardRequest() ); - request.tensorboard = {}; - request.tensorboard.name = ''; - const expectedHeaderRequestParams = 'tensorboard.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboard ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRequest', [ + 'tensorboard', + 'name', + ]); + request.tensorboard.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2609,11 +2669,14 @@ describe('v1.TensorboardServiceClient', () => { const [operation] = await client.updateTensorboard(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboard without error using callback', async () => { @@ -2625,16 +2688,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardRequest() ); - request.tensorboard = {}; - request.tensorboard.name = ''; - const expectedHeaderRequestParams = 'tensorboard.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboard ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRequest', [ + 'tensorboard', + 'name', + ]); + request.tensorboard.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2664,11 +2724,14 @@ describe('v1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboard with call error', async () => { @@ -2680,27 +2743,27 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardRequest() ); - request.tensorboard = {}; - request.tensorboard.name = ''; - const expectedHeaderRequestParams = 'tensorboard.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboard ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRequest', [ + 'tensorboard', + 'name', + ]); + request.tensorboard.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboard = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateTensorboard(request), expectedError); - assert( - (client.innerApiCalls.updateTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboard with LRO error', async () => { @@ -2712,16 +2775,13 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.UpdateTensorboardRequest() ); - request.tensorboard = {}; - request.tensorboard.name = ''; - const expectedHeaderRequestParams = 'tensorboard.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboard ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRequest', [ + 'tensorboard', + 'name', + ]); + request.tensorboard.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboard = stubLongRunningCall( undefined, @@ -2730,11 +2790,14 @@ describe('v1.TensorboardServiceClient', () => { ); const [operation] = await client.updateTensorboard(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateTensorboardProgress without error', async () => { @@ -2789,15 +2852,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2806,11 +2865,14 @@ describe('v1.TensorboardServiceClient', () => { const [operation] = await client.deleteTensorboard(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboard without error using callback', async () => { @@ -2822,15 +2884,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2860,11 +2918,14 @@ describe('v1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboard with call error', async () => { @@ -2876,26 +2937,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboard = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteTensorboard(request), expectedError); - assert( - (client.innerApiCalls.deleteTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboard with LRO error', async () => { @@ -2907,15 +2967,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboard = stubLongRunningCall( undefined, @@ -2924,11 +2980,14 @@ describe('v1.TensorboardServiceClient', () => { ); const [operation] = await client.deleteTensorboard(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTensorboardProgress without error', async () => { @@ -2983,15 +3042,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3000,11 +3056,14 @@ describe('v1.TensorboardServiceClient', () => { const [operation] = await client.deleteTensorboardExperiment(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardExperiment without error using callback', async () => { @@ -3016,15 +3075,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3054,11 +3110,14 @@ describe('v1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardExperiment with call error', async () => { @@ -3070,15 +3129,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardExperiment = stubLongRunningCall( undefined, @@ -3088,11 +3144,14 @@ describe('v1.TensorboardServiceClient', () => { client.deleteTensorboardExperiment(request), expectedError ); - assert( - (client.innerApiCalls.deleteTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardExperiment with LRO error', async () => { @@ -3104,15 +3163,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardExperiment = stubLongRunningCall( undefined, @@ -3121,11 +3177,14 @@ describe('v1.TensorboardServiceClient', () => { ); const [operation] = await client.deleteTensorboardExperiment(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTensorboardExperimentProgress without error', async () => { @@ -3181,15 +3240,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3198,11 +3253,14 @@ describe('v1.TensorboardServiceClient', () => { const [operation] = await client.deleteTensorboardRun(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardRun without error using callback', async () => { @@ -3214,15 +3272,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3252,11 +3306,14 @@ describe('v1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardRun with call error', async () => { @@ -3268,26 +3325,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardRun = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteTensorboardRun(request), expectedError); - assert( - (client.innerApiCalls.deleteTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardRun with LRO error', async () => { @@ -3299,15 +3355,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardRun = stubLongRunningCall( undefined, @@ -3316,11 +3368,14 @@ describe('v1.TensorboardServiceClient', () => { ); const [operation] = await client.deleteTensorboardRun(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTensorboardRunProgress without error', async () => { @@ -3375,15 +3430,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3392,11 +3444,14 @@ describe('v1.TensorboardServiceClient', () => { const [operation] = await client.deleteTensorboardTimeSeries(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardTimeSeries without error using callback', async () => { @@ -3408,15 +3463,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3446,11 +3498,14 @@ describe('v1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardTimeSeries with call error', async () => { @@ -3462,15 +3517,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardTimeSeries = stubLongRunningCall( undefined, @@ -3480,11 +3532,14 @@ describe('v1.TensorboardServiceClient', () => { client.deleteTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardTimeSeries with LRO error', async () => { @@ -3496,15 +3551,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardTimeSeries = stubLongRunningCall( undefined, @@ -3513,11 +3565,14 @@ describe('v1.TensorboardServiceClient', () => { ); const [operation] = await client.deleteTensorboardTimeSeries(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTensorboardTimeSeriesProgress without error', async () => { @@ -3573,15 +3628,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardBlobDataRequest() ); - request.timeSeries = ''; - const expectedHeaderRequestParams = 'time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardBlobDataRequest', + ['timeSeries'] + ); + request.timeSeries = defaultValue1; + const expectedHeaderRequestParams = `time_series=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardBlobDataResponse() ); @@ -3603,11 +3655,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readTensorboardBlobData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardBlobData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardBlobData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardBlobData with error', async () => { @@ -3619,15 +3674,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardBlobDataRequest() ); - request.timeSeries = ''; - const expectedHeaderRequestParams = 'time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardBlobDataRequest', + ['timeSeries'] + ); + request.timeSeries = defaultValue1; + const expectedHeaderRequestParams = `time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.readTensorboardBlobData = stubServerStreamingCall( undefined, @@ -3648,11 +3700,14 @@ describe('v1.TensorboardServiceClient', () => { }); }); await assert.rejects(promise, expectedError); - assert( - (client.innerApiCalls.readTensorboardBlobData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardBlobData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardBlobData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardBlobData with closed client', async () => { @@ -3664,7 +3719,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ReadTensorboardBlobDataRequest() ); - request.timeSeries = ''; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardBlobDataRequest', + ['timeSeries'] + ); + request.timeSeries = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.readTensorboardBlobData(request); @@ -3695,15 +3754,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Tensorboard() @@ -3718,11 +3773,14 @@ describe('v1.TensorboardServiceClient', () => { client.innerApiCalls.listTensorboards = stubSimpleCall(expectedResponse); const [response] = await client.listTensorboards(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboards as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboards without error using callback', async () => { @@ -3734,15 +3792,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Tensorboard() @@ -3773,11 +3827,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboards as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboards with error', async () => { @@ -3789,26 +3846,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTensorboards = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listTensorboards(request), expectedError); - assert( - (client.innerApiCalls.listTensorboards as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardsStream without error', async () => { @@ -3820,8 +3876,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Tensorboard() @@ -3858,11 +3917,12 @@ describe('v1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboards, request) ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboards.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboards.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3875,8 +3935,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboards.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3902,11 +3965,12 @@ describe('v1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboards, request) ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboards.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboards.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3919,8 +3983,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.Tensorboard() @@ -3946,11 +4013,12 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboards.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboards.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3963,8 +4031,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboards.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3981,11 +4052,12 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboards.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboards.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4000,15 +4072,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() @@ -4024,11 +4093,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listTensorboardExperiments(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardExperiments as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardExperiments without error using callback', async () => { @@ -4040,15 +4112,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() @@ -4081,11 +4150,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardExperiments as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardExperiments with error', async () => { @@ -4097,15 +4169,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTensorboardExperiments = stubSimpleCall( undefined, @@ -4115,11 +4184,14 @@ describe('v1.TensorboardServiceClient', () => { client.listTensorboardExperiments(request), expectedError ); - assert( - (client.innerApiCalls.listTensorboardExperiments as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardExperimentsStream without error', async () => { @@ -4131,8 +4203,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() @@ -4175,12 +4251,15 @@ describe('v1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardExperiments, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardExperiments .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4193,8 +4272,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardExperiments.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4226,12 +4309,15 @@ describe('v1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardExperiments, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardExperiments .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4244,8 +4330,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardExperiment() @@ -4273,12 +4363,15 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardExperiments .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4291,8 +4384,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardExperiments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4311,12 +4408,15 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardExperiments .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4331,15 +4431,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() @@ -4355,11 +4451,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listTensorboardRuns(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardRuns without error using callback', async () => { @@ -4371,15 +4470,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() @@ -4410,11 +4505,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardRuns with error', async () => { @@ -4426,26 +4524,25 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTensorboardRuns = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listTensorboardRuns(request), expectedError); - assert( - (client.innerApiCalls.listTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardRunsStream without error', async () => { @@ -4457,8 +4554,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() @@ -4496,11 +4596,12 @@ describe('v1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardRuns, request) ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboardRuns.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboardRuns.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4513,8 +4614,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardRuns.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4541,11 +4645,12 @@ describe('v1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardRuns, request) ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboardRuns.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboardRuns.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4558,8 +4663,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardRun() @@ -4585,11 +4693,12 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboardRuns.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboardRuns.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4602,8 +4711,11 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardRuns.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4621,11 +4733,12 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboardRuns.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboardRuns.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4640,15 +4753,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() @@ -4664,11 +4774,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardTimeSeries without error using callback', async () => { @@ -4680,15 +4793,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() @@ -4721,11 +4831,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardTimeSeries with error', async () => { @@ -4737,15 +4850,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTensorboardTimeSeries = stubSimpleCall( undefined, @@ -4755,11 +4865,14 @@ describe('v1.TensorboardServiceClient', () => { client.listTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.listTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardTimeSeriesStream without error', async () => { @@ -4771,8 +4884,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() @@ -4815,12 +4932,15 @@ describe('v1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardTimeSeries, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardTimeSeries .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4833,8 +4953,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardTimeSeries.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4866,12 +4990,15 @@ describe('v1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardTimeSeries, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardTimeSeries .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4884,8 +5011,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TensorboardTimeSeries() @@ -4913,12 +5044,15 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardTimeSeries .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4931,8 +5065,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardTimeSeries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4951,12 +5089,15 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardTimeSeries .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4971,15 +5112,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TimeSeriesDataPoint() @@ -4995,11 +5133,14 @@ describe('v1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.exportTensorboardTimeSeriesData(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportTensorboardTimeSeriesData without error using callback', async () => { @@ -5011,15 +5152,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TimeSeriesDataPoint() @@ -5052,11 +5190,14 @@ describe('v1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportTensorboardTimeSeriesData with error', async () => { @@ -5068,15 +5209,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportTensorboardTimeSeriesData = stubSimpleCall( undefined, @@ -5086,11 +5224,14 @@ describe('v1.TensorboardServiceClient', () => { client.exportTensorboardTimeSeriesData(request), expectedError ); - assert( - (client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportTensorboardTimeSeriesDataStream without error', async () => { @@ -5102,8 +5243,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TimeSeriesDataPoint() @@ -5147,12 +5292,15 @@ describe('v1.TensorboardServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.exportTensorboardTimeSeriesData .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5165,8 +5313,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.exportTensorboardTimeSeriesData.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5199,12 +5351,15 @@ describe('v1.TensorboardServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.exportTensorboardTimeSeriesData .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5217,8 +5372,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1.TimeSeriesDataPoint() @@ -5246,12 +5405,15 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.exportTensorboardTimeSeriesData .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5264,8 +5426,12 @@ describe('v1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.exportTensorboardTimeSeriesData.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5284,12 +5450,15 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.exportTensorboardTimeSeriesData .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5764,12 +5933,15 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -5800,12 +5972,15 @@ describe('v1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_tensorboard_service_v1beta1.ts b/test/gapic_tensorboard_service_v1beta1.ts index 21453295..33863022 100644 --- a/test/gapic_tensorboard_service_v1beta1.ts +++ b/test/gapic_tensorboard_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -290,26 +305,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Tensorboard() ); client.innerApiCalls.getTensorboard = stubSimpleCall(expectedResponse); const [response] = await client.getTensorboard(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboard without error using callback', async () => { @@ -322,15 +336,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Tensorboard() ); @@ -353,11 +363,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboard with error', async () => { @@ -370,26 +383,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTensorboard = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getTensorboard(request), expectedError); - assert( - (client.innerApiCalls.getTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboard with closed client', async () => { @@ -402,7 +414,10 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTensorboard(request), expectedError); @@ -420,15 +435,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardExperimentRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardExperimentRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() ); @@ -436,11 +448,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createTensorboardExperiment(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardExperiment without error using callback', async () => { @@ -453,15 +468,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardExperimentRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardExperimentRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() ); @@ -484,11 +496,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardExperiment with error', async () => { @@ -501,15 +516,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardExperimentRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardExperimentRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboardExperiment = stubSimpleCall( undefined, @@ -519,11 +531,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.createTensorboardExperiment(request), expectedError ); - assert( - (client.innerApiCalls.createTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardExperiment with closed client', async () => { @@ -536,7 +551,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardExperimentRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardExperimentRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -557,15 +576,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() ); @@ -573,11 +589,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getTensorboardExperiment(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardExperiment without error using callback', async () => { @@ -590,15 +609,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() ); @@ -621,11 +637,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardExperiment with error', async () => { @@ -638,15 +657,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTensorboardExperiment = stubSimpleCall( undefined, @@ -656,11 +672,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.getTensorboardExperiment(request), expectedError ); - assert( - (client.innerApiCalls.getTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardExperiment with closed client', async () => { @@ -673,7 +692,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardExperimentRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -694,16 +717,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardExperimentRequest() ); - request.tensorboardExperiment = {}; - request.tensorboardExperiment.name = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardExperiment ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardExperimentRequest', + ['tensorboardExperiment', 'name'] + ); + request.tensorboardExperiment.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() ); @@ -711,11 +731,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.updateTensorboardExperiment(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardExperiment without error using callback', async () => { @@ -728,16 +751,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardExperimentRequest() ); - request.tensorboardExperiment = {}; - request.tensorboardExperiment.name = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardExperiment ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardExperimentRequest', + ['tensorboardExperiment', 'name'] + ); + request.tensorboardExperiment.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() ); @@ -760,11 +780,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardExperiment with error', async () => { @@ -777,16 +800,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardExperimentRequest() ); - request.tensorboardExperiment = {}; - request.tensorboardExperiment.name = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardExperiment ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardExperimentRequest', + ['tensorboardExperiment', 'name'] + ); + request.tensorboardExperiment.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboardExperiment = stubSimpleCall( undefined, @@ -796,11 +816,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.updateTensorboardExperiment(request), expectedError ); - assert( - (client.innerApiCalls.updateTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardExperiment with closed client', async () => { @@ -813,8 +836,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardExperimentRequest() ); - request.tensorboardExperiment = {}; - request.tensorboardExperiment.name = ''; + request.tensorboardExperiment ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardExperimentRequest', + ['tensorboardExperiment', 'name'] + ); + request.tensorboardExperiment.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -835,15 +862,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardRunRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRunRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() ); @@ -851,11 +874,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createTensorboardRun(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardRun without error using callback', async () => { @@ -868,15 +894,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardRunRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRunRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() ); @@ -899,11 +921,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardRun with error', async () => { @@ -916,26 +941,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardRunRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRunRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboardRun = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createTensorboardRun(request), expectedError); - assert( - (client.innerApiCalls.createTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardRun with closed client', async () => { @@ -948,7 +972,10 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardRunRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRunRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createTensorboardRun(request), expectedError); @@ -966,15 +993,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardRunsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardRunsResponse() ); @@ -982,11 +1006,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchCreateTensorboardRuns(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardRuns without error using callback', async () => { @@ -999,15 +1026,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardRunsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardRunsResponse() ); @@ -1030,11 +1054,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardRuns with error', async () => { @@ -1047,15 +1074,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardRunsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateTensorboardRuns = stubSimpleCall( undefined, @@ -1065,11 +1089,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.batchCreateTensorboardRuns(request), expectedError ); - assert( - (client.innerApiCalls.batchCreateTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardRuns with closed client', async () => { @@ -1082,7 +1109,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardRunsRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardRunsRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1103,26 +1134,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() ); client.innerApiCalls.getTensorboardRun = stubSimpleCall(expectedResponse); const [response] = await client.getTensorboardRun(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardRun without error using callback', async () => { @@ -1135,15 +1165,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() ); @@ -1166,11 +1192,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardRun with error', async () => { @@ -1183,26 +1212,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTensorboardRun = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getTensorboardRun(request), expectedError); - assert( - (client.innerApiCalls.getTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardRun with closed client', async () => { @@ -1215,7 +1243,10 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardRunRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTensorboardRun(request), expectedError); @@ -1233,16 +1264,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardRunRequest() ); - request.tensorboardRun = {}; - request.tensorboardRun.name = ''; - const expectedHeaderRequestParams = 'tensorboard_run.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardRun ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRunRequest', [ + 'tensorboardRun', + 'name', + ]); + request.tensorboardRun.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() ); @@ -1250,11 +1278,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.updateTensorboardRun(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardRun without error using callback', async () => { @@ -1267,16 +1298,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardRunRequest() ); - request.tensorboardRun = {}; - request.tensorboardRun.name = ''; - const expectedHeaderRequestParams = 'tensorboard_run.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardRun ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRunRequest', [ + 'tensorboardRun', + 'name', + ]); + request.tensorboardRun.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() ); @@ -1299,11 +1327,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardRun with error', async () => { @@ -1316,27 +1347,27 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardRunRequest() ); - request.tensorboardRun = {}; - request.tensorboardRun.name = ''; - const expectedHeaderRequestParams = 'tensorboard_run.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardRun ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRunRequest', [ + 'tensorboardRun', + 'name', + ]); + request.tensorboardRun.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboardRun = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateTensorboardRun(request), expectedError); - assert( - (client.innerApiCalls.updateTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardRun with closed client', async () => { @@ -1349,8 +1380,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardRunRequest() ); - request.tensorboardRun = {}; - request.tensorboardRun.name = ''; + request.tensorboardRun ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRunRequest', [ + 'tensorboardRun', + 'name', + ]); + request.tensorboardRun.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateTensorboardRun(request), expectedError); @@ -1368,15 +1403,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardTimeSeriesResponse() ); @@ -1384,11 +1416,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchCreateTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardTimeSeries without error using callback', async () => { @@ -1401,15 +1436,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardTimeSeriesResponse() ); @@ -1432,11 +1464,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardTimeSeries with error', async () => { @@ -1449,15 +1484,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchCreateTensorboardTimeSeries = stubSimpleCall( undefined, @@ -1467,11 +1499,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.batchCreateTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchCreateTensorboardTimeSeries with closed client', async () => { @@ -1484,7 +1519,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchCreateTensorboardTimeSeriesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'BatchCreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1505,15 +1544,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() ); @@ -1521,11 +1557,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardTimeSeries without error using callback', async () => { @@ -1538,15 +1577,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() ); @@ -1569,11 +1605,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardTimeSeries with error', async () => { @@ -1586,15 +1625,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboardTimeSeries = stubSimpleCall( undefined, @@ -1604,11 +1640,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.createTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.createTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboardTimeSeries with closed client', async () => { @@ -1621,7 +1660,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardTimeSeriesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + 'CreateTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1642,15 +1685,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() ); @@ -1658,11 +1698,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.getTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardTimeSeries without error using callback', async () => { @@ -1675,15 +1718,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() ); @@ -1706,11 +1746,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardTimeSeries with error', async () => { @@ -1723,15 +1766,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTensorboardTimeSeries = stubSimpleCall( undefined, @@ -1741,11 +1781,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.getTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.getTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTensorboardTimeSeries with closed client', async () => { @@ -1758,7 +1801,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTensorboardTimeSeriesRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + 'GetTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1779,16 +1826,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardTimeSeriesRequest() ); - request.tensorboardTimeSeries = {}; - request.tensorboardTimeSeries.name = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardTimeSeries ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardTimeSeriesRequest', + ['tensorboardTimeSeries', 'name'] + ); + request.tensorboardTimeSeries.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() ); @@ -1796,11 +1840,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.updateTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardTimeSeries without error using callback', async () => { @@ -1813,16 +1860,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardTimeSeriesRequest() ); - request.tensorboardTimeSeries = {}; - request.tensorboardTimeSeries.name = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardTimeSeries ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardTimeSeriesRequest', + ['tensorboardTimeSeries', 'name'] + ); + request.tensorboardTimeSeries.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() ); @@ -1845,11 +1889,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardTimeSeries with error', async () => { @@ -1862,16 +1909,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardTimeSeriesRequest() ); - request.tensorboardTimeSeries = {}; - request.tensorboardTimeSeries.name = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboardTimeSeries ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardTimeSeriesRequest', + ['tensorboardTimeSeries', 'name'] + ); + request.tensorboardTimeSeries.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboardTimeSeries = stubSimpleCall( undefined, @@ -1881,11 +1925,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.updateTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.updateTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboardTimeSeries with closed client', async () => { @@ -1898,8 +1945,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardTimeSeriesRequest() ); - request.tensorboardTimeSeries = {}; - request.tensorboardTimeSeries.name = ''; + request.tensorboardTimeSeries ??= {}; + const defaultValue1 = getTypeDefaultValue( + 'UpdateTensorboardTimeSeriesRequest', + ['tensorboardTimeSeries', 'name'] + ); + request.tensorboardTimeSeries.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1920,15 +1971,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadTensorboardTimeSeriesDataRequest() ); - request.tensorboard = ''; - const expectedHeaderRequestParams = 'tensorboard='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadTensorboardTimeSeriesDataRequest', + ['tensorboard'] + ); + request.tensorboard = defaultValue1; + const expectedHeaderRequestParams = `tensorboard=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadTensorboardTimeSeriesDataResponse() ); @@ -1938,11 +1986,14 @@ describe('v1beta1.TensorboardServiceClient', () => { request ); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadTensorboardTimeSeriesData without error using callback', async () => { @@ -1955,15 +2006,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadTensorboardTimeSeriesDataRequest() ); - request.tensorboard = ''; - const expectedHeaderRequestParams = 'tensorboard='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadTensorboardTimeSeriesDataRequest', + ['tensorboard'] + ); + request.tensorboard = defaultValue1; + const expectedHeaderRequestParams = `tensorboard=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadTensorboardTimeSeriesDataResponse() ); @@ -1986,11 +2034,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadTensorboardTimeSeriesData with error', async () => { @@ -2003,15 +2054,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadTensorboardTimeSeriesDataRequest() ); - request.tensorboard = ''; - const expectedHeaderRequestParams = 'tensorboard='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadTensorboardTimeSeriesDataRequest', + ['tensorboard'] + ); + request.tensorboard = defaultValue1; + const expectedHeaderRequestParams = `tensorboard=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchReadTensorboardTimeSeriesData = stubSimpleCall( undefined, @@ -2021,11 +2069,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.batchReadTensorboardTimeSeriesData(request), expectedError ); - assert( - (client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchReadTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchReadTensorboardTimeSeriesData with closed client', async () => { @@ -2038,7 +2089,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.BatchReadTensorboardTimeSeriesDataRequest() ); - request.tensorboard = ''; + const defaultValue1 = getTypeDefaultValue( + 'BatchReadTensorboardTimeSeriesDataRequest', + ['tensorboard'] + ); + request.tensorboard = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2059,15 +2114,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardTimeSeriesDataResponse() ); @@ -2075,11 +2127,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.readTensorboardTimeSeriesData(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardTimeSeriesData without error using callback', async () => { @@ -2092,15 +2147,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardTimeSeriesDataResponse() ); @@ -2123,11 +2175,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardTimeSeriesData with error', async () => { @@ -2140,15 +2195,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.readTensorboardTimeSeriesData = stubSimpleCall( undefined, @@ -2158,11 +2210,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.readTensorboardTimeSeriesData(request), expectedError ); - assert( - (client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardTimeSeriesData with closed client', async () => { @@ -2175,7 +2230,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2196,15 +2255,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardExperimentDataRequest() ); - request.tensorboardExperiment = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardExperimentDataRequest', + ['tensorboardExperiment'] + ); + request.tensorboardExperiment = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardExperimentDataResponse() ); @@ -2212,11 +2268,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.writeTensorboardExperimentData(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeTensorboardExperimentData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardExperimentData without error using callback', async () => { @@ -2229,15 +2288,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardExperimentDataRequest() ); - request.tensorboardExperiment = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardExperimentDataRequest', + ['tensorboardExperiment'] + ); + request.tensorboardExperiment = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardExperimentDataResponse() ); @@ -2260,11 +2316,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeTensorboardExperimentData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardExperimentData with error', async () => { @@ -2277,15 +2336,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardExperimentDataRequest() ); - request.tensorboardExperiment = ''; - const expectedHeaderRequestParams = 'tensorboard_experiment='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardExperimentDataRequest', + ['tensorboardExperiment'] + ); + request.tensorboardExperiment = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_experiment=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.writeTensorboardExperimentData = stubSimpleCall( undefined, @@ -2295,11 +2351,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.writeTensorboardExperimentData(request), expectedError ); - assert( - (client.innerApiCalls.writeTensorboardExperimentData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardExperimentData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardExperimentData with closed client', async () => { @@ -2312,7 +2371,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardExperimentDataRequest() ); - request.tensorboardExperiment = ''; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardExperimentDataRequest', + ['tensorboardExperiment'] + ); + request.tensorboardExperiment = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2333,15 +2396,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardRunDataRequest() ); - request.tensorboardRun = ''; - const expectedHeaderRequestParams = 'tensorboard_run='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardRunDataRequest', + ['tensorboardRun'] + ); + request.tensorboardRun = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardRunDataResponse() ); @@ -2349,11 +2409,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.writeTensorboardRunData(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeTensorboardRunData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardRunData without error using callback', async () => { @@ -2366,15 +2429,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardRunDataRequest() ); - request.tensorboardRun = ''; - const expectedHeaderRequestParams = 'tensorboard_run='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardRunDataRequest', + ['tensorboardRun'] + ); + request.tensorboardRun = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardRunDataResponse() ); @@ -2397,11 +2457,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.writeTensorboardRunData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardRunData with error', async () => { @@ -2414,15 +2477,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardRunDataRequest() ); - request.tensorboardRun = ''; - const expectedHeaderRequestParams = 'tensorboard_run='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardRunDataRequest', + ['tensorboardRun'] + ); + request.tensorboardRun = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_run=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.writeTensorboardRunData = stubSimpleCall( undefined, @@ -2432,11 +2492,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.writeTensorboardRunData(request), expectedError ); - assert( - (client.innerApiCalls.writeTensorboardRunData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.writeTensorboardRunData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes writeTensorboardRunData with closed client', async () => { @@ -2449,7 +2512,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.WriteTensorboardRunDataRequest() ); - request.tensorboardRun = ''; + const defaultValue1 = getTypeDefaultValue( + 'WriteTensorboardRunDataRequest', + ['tensorboardRun'] + ); + request.tensorboardRun = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -2470,15 +2537,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2487,11 +2550,14 @@ describe('v1beta1.TensorboardServiceClient', () => { const [operation] = await client.createTensorboard(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboard without error using callback', async () => { @@ -2504,15 +2570,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2542,11 +2604,14 @@ describe('v1beta1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboard with call error', async () => { @@ -2559,26 +2624,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboard = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.createTensorboard(request), expectedError); - assert( - (client.innerApiCalls.createTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTensorboard with LRO error', async () => { @@ -2591,15 +2655,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTensorboardRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTensorboardRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTensorboard = stubLongRunningCall( undefined, @@ -2608,11 +2668,14 @@ describe('v1beta1.TensorboardServiceClient', () => { ); const [operation] = await client.createTensorboard(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.createTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCreateTensorboardProgress without error', async () => { @@ -2670,16 +2733,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardRequest() ); - request.tensorboard = {}; - request.tensorboard.name = ''; - const expectedHeaderRequestParams = 'tensorboard.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboard ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRequest', [ + 'tensorboard', + 'name', + ]); + request.tensorboard.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2688,11 +2748,14 @@ describe('v1beta1.TensorboardServiceClient', () => { const [operation] = await client.updateTensorboard(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboard without error using callback', async () => { @@ -2705,16 +2768,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardRequest() ); - request.tensorboard = {}; - request.tensorboard.name = ''; - const expectedHeaderRequestParams = 'tensorboard.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboard ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRequest', [ + 'tensorboard', + 'name', + ]); + request.tensorboard.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2744,11 +2804,14 @@ describe('v1beta1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboard with call error', async () => { @@ -2761,27 +2824,27 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardRequest() ); - request.tensorboard = {}; - request.tensorboard.name = ''; - const expectedHeaderRequestParams = 'tensorboard.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboard ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRequest', [ + 'tensorboard', + 'name', + ]); + request.tensorboard.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboard = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.updateTensorboard(request), expectedError); - assert( - (client.innerApiCalls.updateTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateTensorboard with LRO error', async () => { @@ -2794,16 +2857,13 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.UpdateTensorboardRequest() ); - request.tensorboard = {}; - request.tensorboard.name = ''; - const expectedHeaderRequestParams = 'tensorboard.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.tensorboard ??= {}; + const defaultValue1 = getTypeDefaultValue('UpdateTensorboardRequest', [ + 'tensorboard', + 'name', + ]); + request.tensorboard.name = defaultValue1; + const expectedHeaderRequestParams = `tensorboard.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateTensorboard = stubLongRunningCall( undefined, @@ -2812,11 +2872,14 @@ describe('v1beta1.TensorboardServiceClient', () => { ); const [operation] = await client.updateTensorboard(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.updateTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkUpdateTensorboardProgress without error', async () => { @@ -2874,15 +2937,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2891,11 +2950,14 @@ describe('v1beta1.TensorboardServiceClient', () => { const [operation] = await client.deleteTensorboard(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboard without error using callback', async () => { @@ -2908,15 +2970,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2946,11 +3004,14 @@ describe('v1beta1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboard with call error', async () => { @@ -2963,26 +3024,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboard = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteTensorboard(request), expectedError); - assert( - (client.innerApiCalls.deleteTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboard with LRO error', async () => { @@ -2995,15 +3055,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboard = stubLongRunningCall( undefined, @@ -3012,11 +3068,14 @@ describe('v1beta1.TensorboardServiceClient', () => { ); const [operation] = await client.deleteTensorboard(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTensorboard as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboard as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTensorboardProgress without error', async () => { @@ -3074,15 +3133,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3091,11 +3147,14 @@ describe('v1beta1.TensorboardServiceClient', () => { const [operation] = await client.deleteTensorboardExperiment(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardExperiment without error using callback', async () => { @@ -3108,15 +3167,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3146,11 +3202,14 @@ describe('v1beta1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardExperiment with call error', async () => { @@ -3163,15 +3222,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardExperiment = stubLongRunningCall( undefined, @@ -3181,11 +3237,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.deleteTensorboardExperiment(request), expectedError ); - assert( - (client.innerApiCalls.deleteTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardExperiment with LRO error', async () => { @@ -3198,15 +3257,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardExperimentRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardExperimentRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardExperiment = stubLongRunningCall( undefined, @@ -3215,11 +3271,14 @@ describe('v1beta1.TensorboardServiceClient', () => { ); const [operation] = await client.deleteTensorboardExperiment(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTensorboardExperiment as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardExperiment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTensorboardExperimentProgress without error', async () => { @@ -3278,15 +3337,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3295,11 +3350,14 @@ describe('v1beta1.TensorboardServiceClient', () => { const [operation] = await client.deleteTensorboardRun(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardRun without error using callback', async () => { @@ -3312,15 +3370,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3350,11 +3404,14 @@ describe('v1beta1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardRun with call error', async () => { @@ -3367,26 +3424,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardRun = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.deleteTensorboardRun(request), expectedError); - assert( - (client.innerApiCalls.deleteTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardRun with LRO error', async () => { @@ -3399,15 +3455,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardRunRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTensorboardRunRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardRun = stubLongRunningCall( undefined, @@ -3416,11 +3468,14 @@ describe('v1beta1.TensorboardServiceClient', () => { ); const [operation] = await client.deleteTensorboardRun(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTensorboardRun as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTensorboardRunProgress without error', async () => { @@ -3478,15 +3533,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3495,11 +3547,14 @@ describe('v1beta1.TensorboardServiceClient', () => { const [operation] = await client.deleteTensorboardTimeSeries(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardTimeSeries without error using callback', async () => { @@ -3512,15 +3567,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -3550,11 +3602,14 @@ describe('v1beta1.TensorboardServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardTimeSeries with call error', async () => { @@ -3567,15 +3622,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardTimeSeries = stubLongRunningCall( undefined, @@ -3585,11 +3637,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.deleteTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTensorboardTimeSeries with LRO error', async () => { @@ -3602,15 +3657,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTensorboardTimeSeriesRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'DeleteTensorboardTimeSeriesRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTensorboardTimeSeries = stubLongRunningCall( undefined, @@ -3619,11 +3671,14 @@ describe('v1beta1.TensorboardServiceClient', () => { ); const [operation] = await client.deleteTensorboardTimeSeries(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkDeleteTensorboardTimeSeriesProgress without error', async () => { @@ -3682,15 +3737,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardBlobDataRequest() ); - request.timeSeries = ''; - const expectedHeaderRequestParams = 'time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardBlobDataRequest', + ['timeSeries'] + ); + request.timeSeries = defaultValue1; + const expectedHeaderRequestParams = `time_series=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardBlobDataResponse() ); @@ -3712,11 +3764,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.readTensorboardBlobData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardBlobData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardBlobData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardBlobData with error', async () => { @@ -3729,15 +3784,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardBlobDataRequest() ); - request.timeSeries = ''; - const expectedHeaderRequestParams = 'time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardBlobDataRequest', + ['timeSeries'] + ); + request.timeSeries = defaultValue1; + const expectedHeaderRequestParams = `time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.readTensorboardBlobData = stubServerStreamingCall( undefined, @@ -3758,11 +3810,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); }); await assert.rejects(promise, expectedError); - assert( - (client.innerApiCalls.readTensorboardBlobData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions) - ); + const actualRequest = ( + client.innerApiCalls.readTensorboardBlobData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.readTensorboardBlobData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes readTensorboardBlobData with closed client', async () => { @@ -3775,7 +3830,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ReadTensorboardBlobDataRequest() ); - request.timeSeries = ''; + const defaultValue1 = getTypeDefaultValue( + 'ReadTensorboardBlobDataRequest', + ['timeSeries'] + ); + request.timeSeries = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); const stream = client.readTensorboardBlobData(request); @@ -3807,15 +3866,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Tensorboard() @@ -3830,11 +3885,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.innerApiCalls.listTensorboards = stubSimpleCall(expectedResponse); const [response] = await client.listTensorboards(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboards as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboards without error using callback', async () => { @@ -3847,15 +3905,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Tensorboard() @@ -3888,11 +3942,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboards as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboards with error', async () => { @@ -3905,26 +3962,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTensorboards = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listTensorboards(request), expectedError); - assert( - (client.innerApiCalls.listTensorboards as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboards as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardsStream without error', async () => { @@ -3937,8 +3993,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Tensorboard() @@ -3976,11 +4035,12 @@ describe('v1beta1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboards, request) ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboards.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboards.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3994,8 +4054,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboards.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4022,11 +4085,12 @@ describe('v1beta1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboards, request) ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboards.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboards.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4040,8 +4104,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Tensorboard() @@ -4068,11 +4135,12 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboards.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboards.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4086,8 +4154,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboards.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4105,11 +4176,12 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboards.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboards.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4125,15 +4197,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() @@ -4149,11 +4218,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listTensorboardExperiments(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardExperiments as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardExperiments without error using callback', async () => { @@ -4166,15 +4238,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() @@ -4207,11 +4276,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardExperiments as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardExperiments with error', async () => { @@ -4224,15 +4296,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTensorboardExperiments = stubSimpleCall( undefined, @@ -4242,11 +4311,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.listTensorboardExperiments(request), expectedError ); - assert( - (client.innerApiCalls.listTensorboardExperiments as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardExperiments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardExperimentsStream without error', async () => { @@ -4259,8 +4331,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() @@ -4303,12 +4379,15 @@ describe('v1beta1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardExperiments, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardExperiments .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4322,8 +4401,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardExperiments.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4355,12 +4438,15 @@ describe('v1beta1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardExperiments, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardExperiments .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4374,8 +4460,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardExperiment() @@ -4403,12 +4493,15 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardExperiments .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4422,8 +4515,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardExperimentsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardExperimentsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardExperiments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4442,12 +4539,15 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardExperiments .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4463,15 +4563,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() @@ -4487,11 +4583,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listTensorboardRuns(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardRuns without error using callback', async () => { @@ -4504,15 +4603,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() @@ -4545,11 +4640,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardRuns with error', async () => { @@ -4562,26 +4660,25 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTensorboardRuns = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listTensorboardRuns(request), expectedError); - assert( - (client.innerApiCalls.listTensorboardRuns as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardRunsStream without error', async () => { @@ -4594,8 +4691,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() @@ -4633,11 +4733,12 @@ describe('v1beta1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardRuns, request) ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboardRuns.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboardRuns.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4651,8 +4752,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardRuns.createStream = stubPageStreamingCall(undefined, expectedError); @@ -4679,11 +4783,12 @@ describe('v1beta1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardRuns, request) ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboardRuns.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboardRuns.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4697,8 +4802,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardRun() @@ -4725,11 +4833,12 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboardRuns.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboardRuns.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4743,8 +4852,11 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardRunsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTensorboardRunsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardRuns.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -4762,11 +4874,12 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listTensorboardRuns.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTensorboardRuns.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -4782,15 +4895,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() @@ -4806,11 +4916,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listTensorboardTimeSeries(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardTimeSeries without error using callback', async () => { @@ -4823,15 +4936,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() @@ -4864,11 +4974,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardTimeSeries with error', async () => { @@ -4881,15 +4994,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTensorboardTimeSeries = stubSimpleCall( undefined, @@ -4899,11 +5009,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.listTensorboardTimeSeries(request), expectedError ); - assert( - (client.innerApiCalls.listTensorboardTimeSeries as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTensorboardTimeSeries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTensorboardTimeSeriesStream without error', async () => { @@ -4916,8 +5029,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() @@ -4960,12 +5077,15 @@ describe('v1beta1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardTimeSeries, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardTimeSeries .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -4979,8 +5099,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardTimeSeries.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5012,12 +5136,15 @@ describe('v1beta1.TensorboardServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTensorboardTimeSeries, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardTimeSeries .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5031,8 +5158,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TensorboardTimeSeries() @@ -5060,12 +5191,15 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardTimeSeries .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5079,8 +5213,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTensorboardTimeSeriesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + 'ListTensorboardTimeSeriesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTensorboardTimeSeries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5099,12 +5237,15 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listTensorboardTimeSeries .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5120,15 +5261,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TimeSeriesDataPoint() @@ -5144,11 +5282,14 @@ describe('v1beta1.TensorboardServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.exportTensorboardTimeSeriesData(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportTensorboardTimeSeriesData without error using callback', async () => { @@ -5161,15 +5302,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TimeSeriesDataPoint() @@ -5202,11 +5340,14 @@ describe('v1beta1.TensorboardServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportTensorboardTimeSeriesData with error', async () => { @@ -5219,15 +5360,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.exportTensorboardTimeSeriesData = stubSimpleCall( undefined, @@ -5237,11 +5375,14 @@ describe('v1beta1.TensorboardServiceClient', () => { client.exportTensorboardTimeSeriesData(request), expectedError ); - assert( - (client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportTensorboardTimeSeriesData as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes exportTensorboardTimeSeriesDataStream without error', async () => { @@ -5254,8 +5395,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TimeSeriesDataPoint() @@ -5301,12 +5446,15 @@ describe('v1beta1.TensorboardServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.exportTensorboardTimeSeriesData .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5320,8 +5468,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.exportTensorboardTimeSeriesData.createStream = stubPageStreamingCall(undefined, expectedError); @@ -5356,12 +5508,15 @@ describe('v1beta1.TensorboardServiceClient', () => { request ) ); - assert.strictEqual( + assert( ( client.descriptors.page.exportTensorboardTimeSeriesData .createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5375,8 +5530,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.TimeSeriesDataPoint() @@ -5404,12 +5563,15 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.exportTensorboardTimeSeriesData .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -5423,8 +5585,12 @@ describe('v1beta1.TensorboardServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ExportTensorboardTimeSeriesDataRequest() ); - request.tensorboardTimeSeries = ''; - const expectedHeaderRequestParams = 'tensorboard_time_series='; + const defaultValue1 = getTypeDefaultValue( + 'ExportTensorboardTimeSeriesDataRequest', + ['tensorboardTimeSeries'] + ); + request.tensorboardTimeSeries = defaultValue1; + const expectedHeaderRequestParams = `tensorboard_time_series=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.exportTensorboardTimeSeriesData.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -5443,12 +5609,15 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.exportTensorboardTimeSeriesData .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -5936,12 +6105,15 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -5973,12 +6145,15 @@ describe('v1beta1.TensorboardServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_vizier_service_v1.ts b/test/gapic_vizier_service_v1.ts index 5381fd6d..4d9f5dfc 100644 --- a/test/gapic_vizier_service_v1.ts +++ b/test/gapic_vizier_service_v1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Study() ); client.innerApiCalls.createStudy = stubSimpleCall(expectedResponse); const [response] = await client.createStudy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createStudy without error using callback', async () => { @@ -291,15 +305,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Study() ); @@ -322,11 +332,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createStudy with error', async () => { @@ -338,26 +351,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createStudy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createStudy(request), expectedError); - assert( - (client.innerApiCalls.createStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createStudy with closed client', async () => { @@ -369,7 +381,10 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateStudyRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createStudy(request), expectedError); @@ -386,26 +401,23 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Study() ); client.innerApiCalls.getStudy = stubSimpleCall(expectedResponse); const [response] = await client.getStudy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getStudy without error using callback', async () => { @@ -417,15 +429,9 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Study() ); @@ -448,11 +454,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getStudy with error', async () => { @@ -464,23 +473,20 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getStudy = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getStudy(request), expectedError); - assert( - (client.innerApiCalls.getStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getStudy with closed client', async () => { @@ -492,7 +498,8 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetStudyRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetStudyRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getStudy(request), expectedError); @@ -509,26 +516,23 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteStudy = stubSimpleCall(expectedResponse); const [response] = await client.deleteStudy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteStudy without error using callback', async () => { @@ -540,15 +544,9 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -571,11 +569,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteStudy with error', async () => { @@ -587,26 +588,23 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteStudy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteStudy(request), expectedError); - assert( - (client.innerApiCalls.deleteStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteStudy with closed client', async () => { @@ -618,7 +616,8 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteStudyRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteStudyRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteStudy(request), expectedError); @@ -635,26 +634,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LookupStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('LookupStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Study() ); client.innerApiCalls.lookupStudy = stubSimpleCall(expectedResponse); const [response] = await client.lookupStudy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.lookupStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes lookupStudy without error using callback', async () => { @@ -666,15 +664,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LookupStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('LookupStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Study() ); @@ -697,11 +691,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.lookupStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes lookupStudy with error', async () => { @@ -713,26 +710,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LookupStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('LookupStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.lookupStudy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.lookupStudy(request), expectedError); - assert( - (client.innerApiCalls.lookupStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes lookupStudy with closed client', async () => { @@ -744,7 +740,10 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.LookupStudyRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('LookupStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.lookupStudy(request), expectedError); @@ -761,26 +760,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTrialRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTrialRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); client.innerApiCalls.createTrial = stubSimpleCall(expectedResponse); const [response] = await client.createTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrial without error using callback', async () => { @@ -792,15 +790,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTrialRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTrialRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); @@ -823,11 +817,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrial with error', async () => { @@ -839,26 +836,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTrialRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTrialRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTrial = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createTrial(request), expectedError); - assert( - (client.innerApiCalls.createTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrial with closed client', async () => { @@ -870,7 +866,10 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CreateTrialRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateTrialRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createTrial(request), expectedError); @@ -887,26 +886,23 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); client.innerApiCalls.getTrial = stubSimpleCall(expectedResponse); const [response] = await client.getTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrial without error using callback', async () => { @@ -918,15 +914,9 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); @@ -949,11 +939,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrial with error', async () => { @@ -965,23 +958,20 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTrial = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getTrial(request), expectedError); - assert( - (client.innerApiCalls.getTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrial with closed client', async () => { @@ -993,7 +983,8 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.GetTrialRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetTrialRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTrial(request), expectedError); @@ -1010,15 +1001,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddTrialMeasurementRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddTrialMeasurementRequest', [ + 'trialName', + ]); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); @@ -1026,11 +1013,14 @@ describe('v1.VizierServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addTrialMeasurement(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addTrialMeasurement as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addTrialMeasurement without error using callback', async () => { @@ -1042,15 +1032,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddTrialMeasurementRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddTrialMeasurementRequest', [ + 'trialName', + ]); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); @@ -1073,11 +1059,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addTrialMeasurement as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addTrialMeasurement with error', async () => { @@ -1089,26 +1078,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddTrialMeasurementRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddTrialMeasurementRequest', [ + 'trialName', + ]); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addTrialMeasurement = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.addTrialMeasurement(request), expectedError); - assert( - (client.innerApiCalls.addTrialMeasurement as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addTrialMeasurement with closed client', async () => { @@ -1120,7 +1108,10 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.AddTrialMeasurementRequest() ); - request.trialName = ''; + const defaultValue1 = getTypeDefaultValue('AddTrialMeasurementRequest', [ + 'trialName', + ]); + request.trialName = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.addTrialMeasurement(request), expectedError); @@ -1137,26 +1128,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CompleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CompleteTrialRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); client.innerApiCalls.completeTrial = stubSimpleCall(expectedResponse); const [response] = await client.completeTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.completeTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes completeTrial without error using callback', async () => { @@ -1168,15 +1158,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CompleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CompleteTrialRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); @@ -1199,11 +1185,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.completeTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes completeTrial with error', async () => { @@ -1215,26 +1204,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CompleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CompleteTrialRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.completeTrial = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.completeTrial(request), expectedError); - assert( - (client.innerApiCalls.completeTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes completeTrial with closed client', async () => { @@ -1246,7 +1234,10 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CompleteTrialRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('CompleteTrialRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.completeTrial(request), expectedError); @@ -1263,26 +1254,23 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteTrial = stubSimpleCall(expectedResponse); const [response] = await client.deleteTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrial without error using callback', async () => { @@ -1294,15 +1282,9 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1325,11 +1307,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrial with error', async () => { @@ -1341,26 +1326,23 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTrial = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteTrial(request), expectedError); - assert( - (client.innerApiCalls.deleteTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrial with closed client', async () => { @@ -1372,7 +1354,8 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.DeleteTrialRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteTrialRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteTrial(request), expectedError); @@ -1389,46 +1372,37 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.StopTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StopTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); client.innerApiCalls.stopTrial = stubSimpleCall(expectedResponse); const [response] = await client.stopTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.stopTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopTrial without error using callback', async () => { const client = new vizierserviceModule.v1.VizierServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.aiplatform.v1.StopTrialRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1.StopTrialRequest() + ); + const defaultValue1 = getTypeDefaultValue('StopTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.Trial() ); @@ -1451,11 +1425,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.stopTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopTrial with error', async () => { @@ -1467,23 +1444,20 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.StopTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StopTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.stopTrial = stubSimpleCall(undefined, expectedError); await assert.rejects(client.stopTrial(request), expectedError); - assert( - (client.innerApiCalls.stopTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopTrial with closed client', async () => { @@ -1495,7 +1469,8 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.StopTrialRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('StopTrialRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.stopTrial(request), expectedError); @@ -1512,26 +1487,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListOptimalTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListOptimalTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListOptimalTrialsResponse() ); client.innerApiCalls.listOptimalTrials = stubSimpleCall(expectedResponse); const [response] = await client.listOptimalTrials(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listOptimalTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listOptimalTrials without error using callback', async () => { @@ -1543,15 +1517,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListOptimalTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListOptimalTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListOptimalTrialsResponse() ); @@ -1574,11 +1544,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listOptimalTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listOptimalTrials with error', async () => { @@ -1590,26 +1563,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListOptimalTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListOptimalTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listOptimalTrials = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listOptimalTrials(request), expectedError); - assert( - (client.innerApiCalls.listOptimalTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listOptimalTrials with closed client', async () => { @@ -1621,7 +1593,10 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListOptimalTrialsRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('ListOptimalTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.listOptimalTrials(request), expectedError); @@ -1638,15 +1613,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SuggestTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SuggestTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1655,11 +1626,14 @@ describe('v1.VizierServiceClient', () => { const [operation] = await client.suggestTrials(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.suggestTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes suggestTrials without error using callback', async () => { @@ -1671,15 +1645,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SuggestTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SuggestTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1709,11 +1679,14 @@ describe('v1.VizierServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.suggestTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes suggestTrials with call error', async () => { @@ -1725,26 +1698,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SuggestTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SuggestTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.suggestTrials = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.suggestTrials(request), expectedError); - assert( - (client.innerApiCalls.suggestTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes suggestTrials with LRO error', async () => { @@ -1756,15 +1728,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.SuggestTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SuggestTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.suggestTrials = stubLongRunningCall( undefined, @@ -1773,11 +1741,14 @@ describe('v1.VizierServiceClient', () => { ); const [operation] = await client.suggestTrials(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.suggestTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkSuggestTrialsProgress without error', async () => { @@ -1832,15 +1803,12 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CheckTrialEarlyStoppingStateRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CheckTrialEarlyStoppingStateRequest', + ['trialName'] + ); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1849,11 +1817,14 @@ describe('v1.VizierServiceClient', () => { const [operation] = await client.checkTrialEarlyStoppingState(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkTrialEarlyStoppingState without error using callback', async () => { @@ -1865,15 +1836,12 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CheckTrialEarlyStoppingStateRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CheckTrialEarlyStoppingStateRequest', + ['trialName'] + ); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1903,11 +1871,14 @@ describe('v1.VizierServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkTrialEarlyStoppingState with call error', async () => { @@ -1919,15 +1890,12 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CheckTrialEarlyStoppingStateRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CheckTrialEarlyStoppingStateRequest', + ['trialName'] + ); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.checkTrialEarlyStoppingState = stubLongRunningCall( undefined, @@ -1937,11 +1905,14 @@ describe('v1.VizierServiceClient', () => { client.checkTrialEarlyStoppingState(request), expectedError ); - assert( - (client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkTrialEarlyStoppingState with LRO error', async () => { @@ -1953,15 +1924,12 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.CheckTrialEarlyStoppingStateRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CheckTrialEarlyStoppingStateRequest', + ['trialName'] + ); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.checkTrialEarlyStoppingState = stubLongRunningCall( undefined, @@ -1970,11 +1938,14 @@ describe('v1.VizierServiceClient', () => { ); const [operation] = await client.checkTrialEarlyStoppingState(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCheckTrialEarlyStoppingStateProgress without error', async () => { @@ -2030,15 +2001,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Study()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Study()), @@ -2047,11 +2014,14 @@ describe('v1.VizierServiceClient', () => { client.innerApiCalls.listStudies = stubSimpleCall(expectedResponse); const [response] = await client.listStudies(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listStudies as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listStudies without error using callback', async () => { @@ -2063,15 +2033,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Study()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Study()), @@ -2096,11 +2062,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listStudies as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listStudies with error', async () => { @@ -2112,26 +2081,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listStudies = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listStudies(request), expectedError); - assert( - (client.innerApiCalls.listStudies as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listStudiesStream without error', async () => { @@ -2143,8 +2111,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Study()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Study()), @@ -2175,11 +2146,12 @@ describe('v1.VizierServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listStudies, request) ); - assert.strictEqual( - (client.descriptors.page.listStudies.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listStudies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2192,8 +2164,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listStudies.createStream = stubPageStreamingCall( undefined, @@ -2221,11 +2196,12 @@ describe('v1.VizierServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listStudies, request) ); - assert.strictEqual( - (client.descriptors.page.listStudies.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listStudies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2238,8 +2214,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Study()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Study()), @@ -2259,11 +2238,12 @@ describe('v1.VizierServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listStudies.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listStudies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2276,8 +2256,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listStudies.asyncIterate = stubAsyncIterationCall( undefined, @@ -2296,11 +2279,12 @@ describe('v1.VizierServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listStudies.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listStudies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2315,15 +2299,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Trial()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Trial()), @@ -2332,11 +2312,14 @@ describe('v1.VizierServiceClient', () => { client.innerApiCalls.listTrials = stubSimpleCall(expectedResponse); const [response] = await client.listTrials(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrials without error using callback', async () => { @@ -2348,15 +2331,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Trial()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Trial()), @@ -2381,11 +2360,14 @@ describe('v1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrials with error', async () => { @@ -2397,26 +2379,25 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTrials = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listTrials(request), expectedError); - assert( - (client.innerApiCalls.listTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrialsStream without error', async () => { @@ -2428,8 +2409,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Trial()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Trial()), @@ -2460,11 +2444,12 @@ describe('v1.VizierServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTrials, request) ); - assert.strictEqual( - (client.descriptors.page.listTrials.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTrials.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2477,8 +2462,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTrials.createStream = stubPageStreamingCall( undefined, @@ -2506,11 +2494,12 @@ describe('v1.VizierServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTrials, request) ); - assert.strictEqual( - (client.descriptors.page.listTrials.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTrials.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2523,8 +2512,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.aiplatform.v1.Trial()), generateSampleMessage(new protos.google.cloud.aiplatform.v1.Trial()), @@ -2544,11 +2536,12 @@ describe('v1.VizierServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listTrials.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTrials.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2561,8 +2554,11 @@ describe('v1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTrials.asyncIterate = stubAsyncIterationCall( undefined, @@ -2581,11 +2577,12 @@ describe('v1.VizierServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listTrials.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTrials.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3060,12 +3057,15 @@ describe('v1.VizierServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -3096,12 +3096,15 @@ describe('v1.VizierServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); diff --git a/test/gapic_vizier_service_v1beta1.ts b/test/gapic_vizier_service_v1beta1.ts index b8fd4a73..2a7ca064 100644 --- a/test/gapic_vizier_service_v1beta1.ts +++ b/test/gapic_vizier_service_v1beta1.ts @@ -33,6 +33,21 @@ import { LocationProtos, } from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -260,26 +275,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() ); client.innerApiCalls.createStudy = stubSimpleCall(expectedResponse); const [response] = await client.createStudy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createStudy without error using callback', async () => { @@ -291,15 +305,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() ); @@ -322,11 +332,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createStudy with error', async () => { @@ -338,26 +351,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createStudy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createStudy(request), expectedError); - assert( - (client.innerApiCalls.createStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createStudy with closed client', async () => { @@ -369,7 +381,10 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateStudyRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createStudy(request), expectedError); @@ -386,26 +401,23 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() ); client.innerApiCalls.getStudy = stubSimpleCall(expectedResponse); const [response] = await client.getStudy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getStudy without error using callback', async () => { @@ -417,15 +429,9 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() ); @@ -448,11 +454,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getStudy with error', async () => { @@ -464,23 +473,20 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getStudy = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getStudy(request), expectedError); - assert( - (client.innerApiCalls.getStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getStudy with closed client', async () => { @@ -492,7 +498,8 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetStudyRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetStudyRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getStudy(request), expectedError); @@ -509,26 +516,23 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteStudy = stubSimpleCall(expectedResponse); const [response] = await client.deleteStudy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteStudy without error using callback', async () => { @@ -540,15 +544,9 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -571,11 +569,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteStudy with error', async () => { @@ -587,26 +588,23 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteStudyRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteStudyRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteStudy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteStudy(request), expectedError); - assert( - (client.innerApiCalls.deleteStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteStudy with closed client', async () => { @@ -618,7 +616,8 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteStudyRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteStudyRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteStudy(request), expectedError); @@ -635,26 +634,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LookupStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('LookupStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() ); client.innerApiCalls.lookupStudy = stubSimpleCall(expectedResponse); const [response] = await client.lookupStudy(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.lookupStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes lookupStudy without error using callback', async () => { @@ -666,15 +664,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LookupStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('LookupStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() ); @@ -697,11 +691,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.lookupStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes lookupStudy with error', async () => { @@ -713,26 +710,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LookupStudyRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('LookupStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.lookupStudy = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.lookupStudy(request), expectedError); - assert( - (client.innerApiCalls.lookupStudy as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookupStudy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes lookupStudy with closed client', async () => { @@ -744,7 +740,10 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.LookupStudyRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('LookupStudyRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.lookupStudy(request), expectedError); @@ -761,26 +760,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTrialRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTrialRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); client.innerApiCalls.createTrial = stubSimpleCall(expectedResponse); const [response] = await client.createTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrial without error using callback', async () => { @@ -792,15 +790,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTrialRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTrialRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); @@ -823,11 +817,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrial with error', async () => { @@ -839,26 +836,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTrialRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CreateTrialRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createTrial = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createTrial(request), expectedError); - assert( - (client.innerApiCalls.createTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createTrial with closed client', async () => { @@ -870,7 +866,10 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CreateTrialRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('CreateTrialRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createTrial(request), expectedError); @@ -887,26 +886,23 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); client.innerApiCalls.getTrial = stubSimpleCall(expectedResponse); const [response] = await client.getTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrial without error using callback', async () => { @@ -918,15 +914,9 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); @@ -949,11 +939,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrial with error', async () => { @@ -965,23 +958,20 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('GetTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getTrial = stubSimpleCall(undefined, expectedError); await assert.rejects(client.getTrial(request), expectedError); - assert( - (client.innerApiCalls.getTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getTrial with closed client', async () => { @@ -993,7 +983,8 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.GetTrialRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('GetTrialRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getTrial(request), expectedError); @@ -1010,15 +1001,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddTrialMeasurementRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddTrialMeasurementRequest', [ + 'trialName', + ]); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); @@ -1026,11 +1013,14 @@ describe('v1beta1.VizierServiceClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addTrialMeasurement(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addTrialMeasurement as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addTrialMeasurement without error using callback', async () => { @@ -1042,15 +1032,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddTrialMeasurementRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddTrialMeasurementRequest', [ + 'trialName', + ]); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); @@ -1073,11 +1059,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addTrialMeasurement as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addTrialMeasurement with error', async () => { @@ -1089,26 +1078,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddTrialMeasurementRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('AddTrialMeasurementRequest', [ + 'trialName', + ]); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addTrialMeasurement = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.addTrialMeasurement(request), expectedError); - assert( - (client.innerApiCalls.addTrialMeasurement as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addTrialMeasurement as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addTrialMeasurement with closed client', async () => { @@ -1120,7 +1108,10 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.AddTrialMeasurementRequest() ); - request.trialName = ''; + const defaultValue1 = getTypeDefaultValue('AddTrialMeasurementRequest', [ + 'trialName', + ]); + request.trialName = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.addTrialMeasurement(request), expectedError); @@ -1137,26 +1128,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CompleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CompleteTrialRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); client.innerApiCalls.completeTrial = stubSimpleCall(expectedResponse); const [response] = await client.completeTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.completeTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes completeTrial without error using callback', async () => { @@ -1168,15 +1158,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CompleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CompleteTrialRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); @@ -1199,11 +1185,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.completeTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes completeTrial with error', async () => { @@ -1215,26 +1204,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CompleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('CompleteTrialRequest', [ + 'name', + ]); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.completeTrial = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.completeTrial(request), expectedError); - assert( - (client.innerApiCalls.completeTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes completeTrial with closed client', async () => { @@ -1246,7 +1234,10 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CompleteTrialRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('CompleteTrialRequest', [ + 'name', + ]); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.completeTrial(request), expectedError); @@ -1263,26 +1254,23 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteTrial = stubSimpleCall(expectedResponse); const [response] = await client.deleteTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrial without error using callback', async () => { @@ -1294,15 +1282,9 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1325,11 +1307,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrial with error', async () => { @@ -1341,26 +1326,23 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('DeleteTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteTrial = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteTrial(request), expectedError); - assert( - (client.innerApiCalls.deleteTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteTrial with closed client', async () => { @@ -1372,7 +1354,8 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.DeleteTrialRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('DeleteTrialRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteTrial(request), expectedError); @@ -1389,46 +1372,37 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.StopTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StopTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); client.innerApiCalls.stopTrial = stubSimpleCall(expectedResponse); const [response] = await client.stopTrial(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.stopTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopTrial without error using callback', async () => { const client = new vizierserviceModule.v1beta1.VizierServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.aiplatform.v1beta1.StopTrialRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.aiplatform.v1beta1.StopTrialRequest() + ); + const defaultValue1 = getTypeDefaultValue('StopTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() ); @@ -1451,11 +1425,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.stopTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopTrial with error', async () => { @@ -1467,23 +1444,20 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.StopTrialRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('StopTrialRequest', ['name']); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.stopTrial = stubSimpleCall(undefined, expectedError); await assert.rejects(client.stopTrial(request), expectedError); - assert( - (client.innerApiCalls.stopTrial as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopTrial as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes stopTrial with closed client', async () => { @@ -1495,7 +1469,8 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.StopTrialRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue('StopTrialRequest', ['name']); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.stopTrial(request), expectedError); @@ -1512,26 +1487,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListOptimalTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListOptimalTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListOptimalTrialsResponse() ); client.innerApiCalls.listOptimalTrials = stubSimpleCall(expectedResponse); const [response] = await client.listOptimalTrials(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listOptimalTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listOptimalTrials without error using callback', async () => { @@ -1543,15 +1517,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListOptimalTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListOptimalTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListOptimalTrialsResponse() ); @@ -1574,11 +1544,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listOptimalTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listOptimalTrials with error', async () => { @@ -1590,26 +1563,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListOptimalTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListOptimalTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listOptimalTrials = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listOptimalTrials(request), expectedError); - assert( - (client.innerApiCalls.listOptimalTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOptimalTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listOptimalTrials with closed client', async () => { @@ -1621,7 +1593,10 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListOptimalTrialsRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue('ListOptimalTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.listOptimalTrials(request), expectedError); @@ -1638,15 +1613,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SuggestTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SuggestTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1655,11 +1626,14 @@ describe('v1beta1.VizierServiceClient', () => { const [operation] = await client.suggestTrials(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.suggestTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes suggestTrials without error using callback', async () => { @@ -1671,15 +1645,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SuggestTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SuggestTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1709,11 +1679,14 @@ describe('v1beta1.VizierServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.suggestTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes suggestTrials with call error', async () => { @@ -1725,26 +1698,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SuggestTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SuggestTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.suggestTrials = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.suggestTrials(request), expectedError); - assert( - (client.innerApiCalls.suggestTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes suggestTrials with LRO error', async () => { @@ -1756,15 +1728,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.SuggestTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('SuggestTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.suggestTrials = stubLongRunningCall( undefined, @@ -1773,11 +1741,14 @@ describe('v1beta1.VizierServiceClient', () => { ); const [operation] = await client.suggestTrials(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.suggestTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.suggestTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkSuggestTrialsProgress without error', async () => { @@ -1832,15 +1803,12 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CheckTrialEarlyStoppingStateRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CheckTrialEarlyStoppingStateRequest', + ['trialName'] + ); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1849,11 +1817,14 @@ describe('v1beta1.VizierServiceClient', () => { const [operation] = await client.checkTrialEarlyStoppingState(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkTrialEarlyStoppingState without error using callback', async () => { @@ -1865,15 +1836,12 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CheckTrialEarlyStoppingStateRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CheckTrialEarlyStoppingStateRequest', + ['trialName'] + ); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1903,11 +1871,14 @@ describe('v1beta1.VizierServiceClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkTrialEarlyStoppingState with call error', async () => { @@ -1919,15 +1890,12 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CheckTrialEarlyStoppingStateRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CheckTrialEarlyStoppingStateRequest', + ['trialName'] + ); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.checkTrialEarlyStoppingState = stubLongRunningCall( undefined, @@ -1937,11 +1905,14 @@ describe('v1beta1.VizierServiceClient', () => { client.checkTrialEarlyStoppingState(request), expectedError ); - assert( - (client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkTrialEarlyStoppingState with LRO error', async () => { @@ -1953,15 +1924,12 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.CheckTrialEarlyStoppingStateRequest() ); - request.trialName = ''; - const expectedHeaderRequestParams = 'trial_name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + 'CheckTrialEarlyStoppingStateRequest', + ['trialName'] + ); + request.trialName = defaultValue1; + const expectedHeaderRequestParams = `trial_name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.checkTrialEarlyStoppingState = stubLongRunningCall( undefined, @@ -1970,11 +1938,14 @@ describe('v1beta1.VizierServiceClient', () => { ); const [operation] = await client.checkTrialEarlyStoppingState(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.checkTrialEarlyStoppingState as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkCheckTrialEarlyStoppingStateProgress without error', async () => { @@ -2030,15 +2001,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() @@ -2053,11 +2020,14 @@ describe('v1beta1.VizierServiceClient', () => { client.innerApiCalls.listStudies = stubSimpleCall(expectedResponse); const [response] = await client.listStudies(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listStudies as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listStudies without error using callback', async () => { @@ -2069,15 +2039,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() @@ -2108,11 +2074,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listStudies as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listStudies with error', async () => { @@ -2124,26 +2093,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listStudies = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listStudies(request), expectedError); - assert( - (client.innerApiCalls.listStudies as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listStudies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listStudiesStream without error', async () => { @@ -2155,8 +2123,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() @@ -2193,11 +2164,12 @@ describe('v1beta1.VizierServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listStudies, request) ); - assert.strictEqual( - (client.descriptors.page.listStudies.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listStudies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2210,8 +2182,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listStudies.createStream = stubPageStreamingCall( undefined, @@ -2239,11 +2214,12 @@ describe('v1beta1.VizierServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listStudies, request) ); - assert.strictEqual( - (client.descriptors.page.listStudies.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listStudies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2256,8 +2232,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Study() @@ -2283,11 +2262,12 @@ describe('v1beta1.VizierServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listStudies.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listStudies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2300,8 +2280,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListStudiesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListStudiesRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listStudies.asyncIterate = stubAsyncIterationCall( undefined, @@ -2320,11 +2303,12 @@ describe('v1beta1.VizierServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listStudies.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listStudies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2339,15 +2323,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() @@ -2362,11 +2342,14 @@ describe('v1beta1.VizierServiceClient', () => { client.innerApiCalls.listTrials = stubSimpleCall(expectedResponse); const [response] = await client.listTrials(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrials without error using callback', async () => { @@ -2378,15 +2361,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() @@ -2417,11 +2396,14 @@ describe('v1beta1.VizierServiceClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrials with error', async () => { @@ -2433,26 +2415,25 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listTrials = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listTrials(request), expectedError); - assert( - (client.innerApiCalls.listTrials as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTrials as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listTrialsStream without error', async () => { @@ -2464,8 +2445,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() @@ -2502,11 +2486,12 @@ describe('v1beta1.VizierServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTrials, request) ); - assert.strictEqual( - (client.descriptors.page.listTrials.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTrials.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2519,8 +2504,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTrials.createStream = stubPageStreamingCall( undefined, @@ -2548,11 +2536,12 @@ describe('v1beta1.VizierServiceClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listTrials, request) ); - assert.strictEqual( - (client.descriptors.page.listTrials.createStream as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTrials.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2565,8 +2554,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.Trial() @@ -2592,11 +2584,12 @@ describe('v1beta1.VizierServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listTrials.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTrials.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2609,8 +2602,11 @@ describe('v1beta1.VizierServiceClient', () => { const request = generateSampleMessage( new protos.google.cloud.aiplatform.v1beta1.ListTrialsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue('ListTrialsRequest', [ + 'parent', + ]); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listTrials.asyncIterate = stubAsyncIterationCall( undefined, @@ -2629,11 +2625,12 @@ describe('v1beta1.VizierServiceClient', () => { ).args[1], request ); - assert.strictEqual( - (client.descriptors.page.listTrials.asyncIterate as SinonStub).getCall( - 0 - ).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listTrials.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3108,12 +3105,15 @@ describe('v1beta1.VizierServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); it('uses async iteration with listLocations with error', async () => { @@ -3144,12 +3144,15 @@ describe('v1beta1.VizierServiceClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.locationsClient.descriptors.page.listLocations .asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); });