From a5baeca8fc50b9d805b55515db493c86cff26299 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 21 Sep 2022 12:02:38 -0700 Subject: [PATCH] fix: preserve default values in x-goog-request-params header (#1044) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: remove obsolete service config files PiperOrigin-RevId: 472492863 Source-Link: https://github.com/googleapis/googleapis/commit/725381dc13c25c5fdc30fc9a660e5f9c35378f08 Source-Link: https://github.com/googleapis/googleapis-gen/commit/16aebe24e817c24e6192746edc522d70036dd772 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTZhZWJlMjRlODE3YzI0ZTYxOTI3NDZlZGM1MjJkNzAwMzZkZDc3MiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * docs: update comments for image annotator OCR models PiperOrigin-RevId: 474070246 Source-Link: https://github.com/googleapis/googleapis/commit/346e2f2a106ed0ff8863b11a3b1ec32cd40b9cf1 Source-Link: https://github.com/googleapis/googleapis-gen/commit/50b34515fa89525989021be4b6989d49059d8d26 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNTBiMzQ1MTVmYTg5NTI1OTg5MDIxYmU0YjY5ODlkNDkwNTlkOGQyNiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: use gapic-generator-typescript v2.17.0 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 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * test: use fully qualified request type name in tests PiperOrigin-RevId: 475685359 Source-Link: https://github.com/googleapis/googleapis/commit/7a129736313ceb1f277c3b7f7e16d2e04cc901dd Source-Link: https://github.com/googleapis/googleapis-gen/commit/370c729e2ba062a167449c27882ba5f379c5c34d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzcwYzcyOWUyYmEwNjJhMTY3NDQ5YzI3ODgyYmE1ZjM3OWM1YzM0ZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * test: make test pass Co-authored-by: Owl Bot Co-authored-by: Alexander Fenster --- .../cloud/vision/v1/image_annotator.proto | 3 +- .../vision/v1p1beta1/image_annotator.proto | 3 +- .../vision/v1p2beta1/image_annotator.proto | 3 +- .../vision/v1p3beta1/image_annotator.proto | 3 +- .../vision/v1p4beta1/image_annotator.proto | 3 +- samples/system-test/detect.test.js | 2 +- src/v1/image_annotator_client.ts | 8 +- src/v1/product_search_client.ts | 54 +- src/v1p3beta1/image_annotator_client.ts | 8 +- src/v1p3beta1/product_search_client.ts | 60 +- src/v1p4beta1/image_annotator_client.ts | 8 +- src/v1p4beta1/product_search_client.ts | 62 +- test/gapic_image_annotator_v1.ts | 419 ++-- test/gapic_image_annotator_v1p1beta1.ts | 33 +- test/gapic_image_annotator_v1p2beta1.ts | 57 +- test/gapic_image_annotator_v1p3beta1.ts | 57 +- test/gapic_image_annotator_v1p4beta1.ts | 99 +- test/gapic_product_search_v1.ts | 2057 +++++++++-------- test/gapic_product_search_v1p3beta1.ts | 1945 +++++++++------- test/gapic_product_search_v1p4beta1.ts | 2057 +++++++++-------- 20 files changed, 3642 insertions(+), 3299 deletions(-) diff --git a/protos/google/cloud/vision/v1/image_annotator.proto b/protos/google/cloud/vision/v1/image_annotator.proto index 10464b0e..6fed6112 100644 --- a/protos/google/cloud/vision/v1/image_annotator.proto +++ b/protos/google/cloud/vision/v1/image_annotator.proto @@ -223,7 +223,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/protos/google/cloud/vision/v1p1beta1/image_annotator.proto b/protos/google/cloud/vision/v1p1beta1/image_annotator.proto index 729a0fa0..f66ad504 100644 --- a/protos/google/cloud/vision/v1p1beta1/image_annotator.proto +++ b/protos/google/cloud/vision/v1p1beta1/image_annotator.proto @@ -103,7 +103,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/protos/google/cloud/vision/v1p2beta1/image_annotator.proto b/protos/google/cloud/vision/v1p2beta1/image_annotator.proto index 5fc3163c..264462d4 100644 --- a/protos/google/cloud/vision/v1p2beta1/image_annotator.proto +++ b/protos/google/cloud/vision/v1p2beta1/image_annotator.proto @@ -126,7 +126,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/protos/google/cloud/vision/v1p3beta1/image_annotator.proto b/protos/google/cloud/vision/v1p3beta1/image_annotator.proto index ca0b4e86..ebab14a6 100644 --- a/protos/google/cloud/vision/v1p3beta1/image_annotator.proto +++ b/protos/google/cloud/vision/v1p3beta1/image_annotator.proto @@ -134,7 +134,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/protos/google/cloud/vision/v1p4beta1/image_annotator.proto b/protos/google/cloud/vision/v1p4beta1/image_annotator.proto index 0fed9eea..cc783697 100644 --- a/protos/google/cloud/vision/v1p4beta1/image_annotator.proto +++ b/protos/google/cloud/vision/v1p4beta1/image_annotator.proto @@ -175,7 +175,8 @@ message Feature { // Model to use for the feature. // Supported values: "builtin/stable" (the default if unset) and - // "builtin/latest". + // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also + // support "builtin/weekly" for the bleeding edge release updated weekly. string model = 3; } diff --git a/samples/system-test/detect.test.js b/samples/system-test/detect.test.js index f0e657e9..cb1d95da 100644 --- a/samples/system-test/detect.test.js +++ b/samples/system-test/detect.test.js @@ -205,7 +205,7 @@ describe('detect', () => { if (webDetection.webEntities.length) { assert.match(output, /Web entities found:/); - assert.match(output, /Description: Google Cloud Platform/); + assert.match(output, /Description:/); } if (webDetection.bestGuessLabels.length) { diff --git a/src/v1/image_annotator_client.ts b/src/v1/image_annotator_client.ts index be9af4e5..31495ea2 100644 --- a/src/v1/image_annotator_client.ts +++ b/src/v1/image_annotator_client.ts @@ -487,7 +487,7 @@ export class ImageAnnotatorClient { 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.batchAnnotateImages(request, options, callback); @@ -598,7 +598,7 @@ export class ImageAnnotatorClient { 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.batchAnnotateFiles(request, options, callback); @@ -725,7 +725,7 @@ export class ImageAnnotatorClient { 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.asyncBatchAnnotateImages( @@ -885,7 +885,7 @@ export class ImageAnnotatorClient { 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.asyncBatchAnnotateFiles( diff --git a/src/v1/product_search_client.ts b/src/v1/product_search_client.ts index 8e8cc2a8..1a64fc9e 100644 --- a/src/v1/product_search_client.ts +++ b/src/v1/product_search_client.ts @@ -534,7 +534,7 @@ export class ProductSearchClient { 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.createProductSet(request, options, callback); @@ -626,7 +626,7 @@ export class ProductSearchClient { 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.getProductSet(request, options, callback); @@ -723,7 +723,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', + 'product_set.name': request.productSet!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProductSet(request, options, callback); @@ -814,7 +814,7 @@ export class ProductSearchClient { 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.deleteProductSet(request, options, callback); @@ -916,7 +916,7 @@ export class ProductSearchClient { 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.createProduct(request, options, callback); @@ -1006,7 +1006,7 @@ export class ProductSearchClient { 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.getProduct(request, options, callback); @@ -1112,7 +1112,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', + 'product.name': request.product!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProduct(request, options, callback); @@ -1204,7 +1204,7 @@ export class ProductSearchClient { 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.deleteProduct(request, options, callback); @@ -1324,7 +1324,7 @@ export class ProductSearchClient { 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.createReferenceImage(request, options, callback); @@ -1424,7 +1424,7 @@ export class ProductSearchClient { 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.deleteReferenceImage(request, options, callback); @@ -1522,7 +1522,7 @@ export class ProductSearchClient { 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.getReferenceImage(request, options, callback); @@ -1628,7 +1628,7 @@ export class ProductSearchClient { 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.addProductToProductSet( @@ -1737,7 +1737,7 @@ export class ProductSearchClient { 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.removeProductFromProductSet( @@ -1859,7 +1859,7 @@ export class ProductSearchClient { 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.importProductSets(request, options, callback); @@ -2030,7 +2030,7 @@ export class ProductSearchClient { 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.purgeProducts(request, options, callback); @@ -2164,7 +2164,7 @@ export class ProductSearchClient { 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.listProductSets(request, options, callback); @@ -2204,7 +2204,7 @@ export class ProductSearchClient { 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['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2253,7 +2253,7 @@ export class ProductSearchClient { 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['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2358,7 +2358,7 @@ export class ProductSearchClient { 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.listProducts(request, options, callback); @@ -2399,7 +2399,7 @@ export class ProductSearchClient { 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['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2449,7 +2449,7 @@ export class ProductSearchClient { 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['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2565,7 +2565,7 @@ export class ProductSearchClient { 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.listReferenceImages(request, options, callback); @@ -2609,7 +2609,7 @@ export class ProductSearchClient { 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['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2662,7 +2662,7 @@ export class ProductSearchClient { 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['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2775,7 +2775,7 @@ export class ProductSearchClient { 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.listProductsInProductSet( @@ -2820,7 +2820,7 @@ export class ProductSearchClient { 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['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); @@ -2870,7 +2870,7 @@ export class ProductSearchClient { 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['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1p3beta1/image_annotator_client.ts b/src/v1p3beta1/image_annotator_client.ts index 8f93f243..7f0e5c86 100644 --- a/src/v1p3beta1/image_annotator_client.ts +++ b/src/v1p3beta1/image_annotator_client.ts @@ -199,13 +199,7 @@ export class ImageAnnotatorClient { }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v1/{name=operations/*}', - additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}], - }, - ]; + lroOptions.httpRules = []; } this.operationsClient = this._gaxModule .lro(lroOptions) diff --git a/src/v1p3beta1/product_search_client.ts b/src/v1p3beta1/product_search_client.ts index 7fd4bc1d..f309bbfe 100644 --- a/src/v1p3beta1/product_search_client.ts +++ b/src/v1p3beta1/product_search_client.ts @@ -241,13 +241,7 @@ export class ProductSearchClient { }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v1/{name=operations/*}', - additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}], - }, - ]; + lroOptions.httpRules = []; } this.operationsClient = this._gaxModule .lro(lroOptions) @@ -524,7 +518,7 @@ export class ProductSearchClient { 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.createProductSet(request, options, callback); @@ -622,7 +616,7 @@ export class ProductSearchClient { 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.getProductSet(request, options, callback); @@ -725,7 +719,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', + 'product_set.name': request.productSet!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProductSet(request, options, callback); @@ -826,7 +820,7 @@ export class ProductSearchClient { 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.deleteProductSet(request, options, callback); @@ -934,7 +928,7 @@ export class ProductSearchClient { 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.createProduct(request, options, callback); @@ -1032,7 +1026,7 @@ export class ProductSearchClient { 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.getProduct(request, options, callback); @@ -1143,7 +1137,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', + 'product.name': request.product!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProduct(request, options, callback); @@ -1245,7 +1239,7 @@ export class ProductSearchClient { 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.deleteProduct(request, options, callback); @@ -1371,7 +1365,7 @@ export class ProductSearchClient { 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.createReferenceImage(request, options, callback); @@ -1482,7 +1476,7 @@ export class ProductSearchClient { 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.deleteReferenceImage(request, options, callback); @@ -1587,7 +1581,7 @@ export class ProductSearchClient { 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.getReferenceImage(request, options, callback); @@ -1699,7 +1693,7 @@ export class ProductSearchClient { 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.addProductToProductSet( @@ -1812,7 +1806,7 @@ export class ProductSearchClient { 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.removeProductFromProductSet( @@ -1934,7 +1928,7 @@ export class ProductSearchClient { 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.importProductSets(request, options, callback); @@ -2074,7 +2068,7 @@ export class ProductSearchClient { 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.listProductSets(request, options, callback); @@ -2114,7 +2108,7 @@ export class ProductSearchClient { 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['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2163,7 +2157,7 @@ export class ProductSearchClient { 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['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2274,7 +2268,7 @@ export class ProductSearchClient { 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.listProducts(request, options, callback); @@ -2315,7 +2309,7 @@ export class ProductSearchClient { 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['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2365,7 +2359,7 @@ export class ProductSearchClient { 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['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2481,7 +2475,7 @@ export class ProductSearchClient { 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.listReferenceImages(request, options, callback); @@ -2525,7 +2519,7 @@ export class ProductSearchClient { 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['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2578,7 +2572,7 @@ export class ProductSearchClient { 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['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2691,7 +2685,7 @@ export class ProductSearchClient { 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.listProductsInProductSet( @@ -2736,7 +2730,7 @@ export class ProductSearchClient { 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['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); @@ -2786,7 +2780,7 @@ export class ProductSearchClient { 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['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); diff --git a/src/v1p4beta1/image_annotator_client.ts b/src/v1p4beta1/image_annotator_client.ts index 822f3f8b..d8d335af 100644 --- a/src/v1p4beta1/image_annotator_client.ts +++ b/src/v1p4beta1/image_annotator_client.ts @@ -199,13 +199,7 @@ export class ImageAnnotatorClient { }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v1/{name=operations/*}', - additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}], - }, - ]; + lroOptions.httpRules = []; } this.operationsClient = this._gaxModule .lro(lroOptions) diff --git a/src/v1p4beta1/product_search_client.ts b/src/v1p4beta1/product_search_client.ts index 6f79774d..dd6eaab4 100644 --- a/src/v1p4beta1/product_search_client.ts +++ b/src/v1p4beta1/product_search_client.ts @@ -245,13 +245,7 @@ export class ProductSearchClient { }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [ - { - selector: 'google.longrunning.Operations.GetOperation', - get: '/v1/{name=operations/*}', - additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}], - }, - ]; + lroOptions.httpRules = []; } this.operationsClient = this._gaxModule .lro(lroOptions) @@ -540,7 +534,7 @@ export class ProductSearchClient { 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.createProductSet(request, options, callback); @@ -638,7 +632,7 @@ export class ProductSearchClient { 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.getProductSet(request, options, callback); @@ -741,7 +735,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product_set.name': request.productSet!.name || '', + 'product_set.name': request.productSet!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProductSet(request, options, callback); @@ -838,7 +832,7 @@ export class ProductSearchClient { 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.deleteProductSet(request, options, callback); @@ -946,7 +940,7 @@ export class ProductSearchClient { 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.createProduct(request, options, callback); @@ -1044,7 +1038,7 @@ export class ProductSearchClient { 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.getProduct(request, options, callback); @@ -1156,7 +1150,7 @@ export class ProductSearchClient { options.otherArgs.headers = options.otherArgs.headers || {}; options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams({ - 'product.name': request.product!.name || '', + 'product.name': request.product!.name ?? '', }); this.initialize(); return this.innerApiCalls.updateProduct(request, options, callback); @@ -1254,7 +1248,7 @@ export class ProductSearchClient { 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.deleteProduct(request, options, callback); @@ -1381,7 +1375,7 @@ export class ProductSearchClient { 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.createReferenceImage(request, options, callback); @@ -1488,7 +1482,7 @@ export class ProductSearchClient { 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.deleteReferenceImage(request, options, callback); @@ -1593,7 +1587,7 @@ export class ProductSearchClient { 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.getReferenceImage(request, options, callback); @@ -1705,7 +1699,7 @@ export class ProductSearchClient { 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.addProductToProductSet( @@ -1815,7 +1809,7 @@ export class ProductSearchClient { 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.removeProductFromProductSet( @@ -1937,7 +1931,7 @@ export class ProductSearchClient { 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.importProductSets(request, options, callback); @@ -2108,7 +2102,7 @@ export class ProductSearchClient { 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.purgeProducts(request, options, callback); @@ -2248,7 +2242,7 @@ export class ProductSearchClient { 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.listProductSets(request, options, callback); @@ -2288,7 +2282,7 @@ export class ProductSearchClient { 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['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2337,7 +2331,7 @@ export class ProductSearchClient { 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['listProductSets']; const callSettings = defaultCallSettings.merge(options); @@ -2448,7 +2442,7 @@ export class ProductSearchClient { 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.listProducts(request, options, callback); @@ -2489,7 +2483,7 @@ export class ProductSearchClient { 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['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2539,7 +2533,7 @@ export class ProductSearchClient { 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['listProducts']; const callSettings = defaultCallSettings.merge(options); @@ -2655,7 +2649,7 @@ export class ProductSearchClient { 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.listReferenceImages(request, options, callback); @@ -2699,7 +2693,7 @@ export class ProductSearchClient { 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['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2752,7 +2746,7 @@ export class ProductSearchClient { 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['listReferenceImages']; const callSettings = defaultCallSettings.merge(options); @@ -2865,7 +2859,7 @@ export class ProductSearchClient { 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.listProductsInProductSet( @@ -2910,7 +2904,7 @@ export class ProductSearchClient { 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['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); @@ -2960,7 +2954,7 @@ export class ProductSearchClient { 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['listProductsInProductSet']; const callSettings = defaultCallSettings.merge(options); diff --git a/test/gapic_image_annotator_v1.ts b/test/gapic_image_annotator_v1.ts index 21d764f9..c7590b51 100644 --- a/test/gapic_image_annotator_v1.ts +++ b/test/gapic_image_annotator_v1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule from '../src'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -191,15 +206,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() ); @@ -207,11 +219,14 @@ describe('v1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -223,15 +238,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesResponse() ); @@ -254,11 +266,14 @@ describe('v1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateImages with error', async () => { @@ -270,26 +285,26 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateImages with closed client', async () => { @@ -301,7 +316,11 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateImagesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.batchAnnotateImages(request), expectedError); @@ -318,15 +337,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() ); @@ -334,11 +350,14 @@ describe('v1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateFiles(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateFiles without error using callback', async () => { @@ -350,15 +369,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesResponse() ); @@ -381,11 +397,14 @@ describe('v1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateFiles with error', async () => { @@ -397,26 +416,26 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateFiles = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateFiles(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes batchAnnotateFiles with closed client', async () => { @@ -428,7 +447,11 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.BatchAnnotateFilesRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.BatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.batchAnnotateFiles(request), expectedError); @@ -445,15 +468,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -462,11 +482,14 @@ describe('v1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateImages(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateImages without error using callback', async () => { @@ -478,15 +501,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -516,11 +536,14 @@ describe('v1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateImages with call error', async () => { @@ -532,15 +555,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall( undefined, @@ -550,11 +570,14 @@ describe('v1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateImages(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateImages with LRO error', async () => { @@ -566,15 +589,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AsyncBatchAnnotateImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall( undefined, @@ -583,11 +603,14 @@ describe('v1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateImages(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { @@ -643,15 +666,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -660,11 +680,14 @@ describe('v1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateFiles(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateFiles without error using callback', async () => { @@ -676,15 +699,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -714,11 +734,14 @@ describe('v1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateFiles with call error', async () => { @@ -730,15 +753,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -748,11 +768,14 @@ describe('v1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateFiles(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes asyncBatchAnnotateFiles with LRO error', async () => { @@ -764,15 +787,12 @@ describe('v1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AsyncBatchAnnotateFilesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -781,11 +801,14 @@ describe('v1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateFiles(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { diff --git a/test/gapic_image_annotator_v1p1beta1.ts b/test/gapic_image_annotator_v1p1beta1.ts index e701a3e8..edf4055b 100644 --- a/test/gapic_image_annotator_v1p1beta1.ts +++ b/test/gapic_image_annotator_v1p1beta1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule from '../src'; import {protobuf} 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 @@ -159,7 +174,6 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() ); @@ -167,11 +181,6 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -183,7 +192,6 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesResponse() ); @@ -206,11 +214,6 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateImages with error', async () => { @@ -222,18 +225,12 @@ describe('v1p1beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p1beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages with closed client', async () => { diff --git a/test/gapic_image_annotator_v1p2beta1.ts b/test/gapic_image_annotator_v1p2beta1.ts index d1ea965f..8ddfa624 100644 --- a/test/gapic_image_annotator_v1p2beta1.ts +++ b/test/gapic_image_annotator_v1p2beta1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule from '../src'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -191,7 +206,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() ); @@ -199,11 +213,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -215,7 +224,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesResponse() ); @@ -238,11 +246,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateImages with error', async () => { @@ -254,18 +257,12 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages with closed client', async () => { @@ -293,7 +290,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -302,11 +298,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateFiles(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles without error using callback', async () => { @@ -318,7 +309,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -348,11 +338,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes asyncBatchAnnotateFiles with call error', async () => { @@ -364,7 +349,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -374,11 +358,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateFiles(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles with LRO error', async () => { @@ -390,7 +369,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -399,11 +377,6 @@ describe('v1p2beta1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateFiles(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { diff --git a/test/gapic_image_annotator_v1p3beta1.ts b/test/gapic_image_annotator_v1p3beta1.ts index 329d8b3d..b82c3419 100644 --- a/test/gapic_image_annotator_v1p3beta1.ts +++ b/test/gapic_image_annotator_v1p3beta1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule from '../src'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -191,7 +206,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() ); @@ -199,11 +213,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -215,7 +224,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesResponse() ); @@ -238,11 +246,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateImages with error', async () => { @@ -254,18 +257,12 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages with closed client', async () => { @@ -293,7 +290,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -302,11 +298,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateFiles(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles without error using callback', async () => { @@ -318,7 +309,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -348,11 +338,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes asyncBatchAnnotateFiles with call error', async () => { @@ -364,7 +349,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -374,11 +358,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateFiles(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles with LRO error', async () => { @@ -390,7 +369,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -399,11 +377,6 @@ describe('v1p3beta1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateFiles(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { diff --git a/test/gapic_image_annotator_v1p4beta1.ts b/test/gapic_image_annotator_v1p4beta1.ts index 37e06f60..97a633c9 100644 --- a/test/gapic_image_annotator_v1p4beta1.ts +++ b/test/gapic_image_annotator_v1p4beta1.ts @@ -25,6 +25,21 @@ import * as imageannotatorModule from '../src'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -191,7 +206,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() ); @@ -199,11 +213,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages without error using callback', async () => { @@ -215,7 +224,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesResponse() ); @@ -238,11 +246,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateImages with error', async () => { @@ -254,18 +257,12 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateImages(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateImages with closed client', async () => { @@ -293,7 +290,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() ); @@ -301,11 +297,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.batchAnnotateFiles(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateFiles without error using callback', async () => { @@ -317,7 +308,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesResponse() ); @@ -340,11 +330,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes batchAnnotateFiles with error', async () => { @@ -356,18 +341,12 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.BatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.batchAnnotateFiles = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.batchAnnotateFiles(request), expectedError); - assert( - (client.innerApiCalls.batchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes batchAnnotateFiles with closed client', async () => { @@ -395,7 +374,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -404,11 +382,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateImages(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateImages without error using callback', async () => { @@ -420,7 +393,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -450,11 +422,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes asyncBatchAnnotateImages with call error', async () => { @@ -466,7 +433,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall( undefined, @@ -476,11 +442,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateImages(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateImages with LRO error', async () => { @@ -492,7 +453,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateImagesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateImages = stubLongRunningCall( undefined, @@ -501,11 +461,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateImages(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkAsyncBatchAnnotateImagesProgress without error', async () => { @@ -561,7 +516,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -570,11 +524,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const [operation] = await client.asyncBatchAnnotateFiles(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles without error using callback', async () => { @@ -586,7 +535,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -616,11 +564,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); }); it('invokes asyncBatchAnnotateFiles with call error', async () => { @@ -632,7 +575,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -642,11 +584,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { client.asyncBatchAnnotateFiles(request), expectedError ); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes asyncBatchAnnotateFiles with LRO error', async () => { @@ -658,7 +595,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AsyncBatchAnnotateFilesRequest() ); - const expectedOptions = {otherArgs: {headers: {}}}; const expectedError = new Error('expected'); client.innerApiCalls.asyncBatchAnnotateFiles = stubLongRunningCall( undefined, @@ -667,11 +603,6 @@ describe('v1p4beta1.ImageAnnotatorClient', () => { ); const [operation] = await client.asyncBatchAnnotateFiles(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.asyncBatchAnnotateFiles as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); }); it('invokes checkAsyncBatchAnnotateFilesProgress without error', async () => { diff --git a/test/gapic_product_search_v1.ts b/test/gapic_product_search_v1.ts index ac4d6486..ae4ed49b 100644 --- a/test/gapic_product_search_v1.ts +++ b/test/gapic_product_search_v1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -254,26 +269,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); const [response] = await client.createProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet without error using callback', async () => { @@ -285,15 +300,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); @@ -316,11 +328,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with error', async () => { @@ -332,26 +347,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProductSet(request), expectedError); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with closed client', async () => { @@ -363,7 +378,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductSetRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProductSet(request), expectedError); @@ -380,26 +399,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); const [response] = await client.getProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet without error using callback', async () => { @@ -411,15 +430,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); @@ -442,11 +458,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with error', async () => { @@ -458,26 +477,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProductSet(request), expectedError); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with closed client', async () => { @@ -489,7 +508,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProductSet(request), expectedError); @@ -506,27 +529,27 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); const [response] = await client.updateProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet without error using callback', async () => { @@ -538,16 +561,13 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ProductSet() ); @@ -570,11 +590,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with error', async () => { @@ -586,27 +609,27 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProductSet(request), expectedError); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with closed client', async () => { @@ -618,8 +641,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProductSet(request), expectedError); @@ -636,26 +663,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); const [response] = await client.deleteProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet without error using callback', async () => { @@ -667,15 +694,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -698,11 +722,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with error', async () => { @@ -714,26 +741,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProductSet(request), expectedError); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with closed client', async () => { @@ -745,7 +772,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProductSet(request), expectedError); @@ -762,26 +793,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); const [response] = await client.createProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct without error using callback', async () => { @@ -793,15 +824,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); @@ -824,11 +852,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with error', async () => { @@ -840,26 +871,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProduct(request), expectedError); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with closed client', async () => { @@ -871,7 +902,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateProductRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProduct(request), expectedError); @@ -888,26 +923,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); const [response] = await client.getProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct without error using callback', async () => { @@ -919,15 +954,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); @@ -950,11 +982,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with error', async () => { @@ -966,26 +1001,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProduct(request), expectedError); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with closed client', async () => { @@ -997,7 +1032,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProduct(request), expectedError); @@ -1014,27 +1053,27 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); const [response] = await client.updateProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct without error using callback', async () => { @@ -1046,16 +1085,13 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.Product() ); @@ -1078,11 +1114,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with error', async () => { @@ -1094,27 +1133,27 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProduct(request), expectedError); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with closed client', async () => { @@ -1126,8 +1165,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProduct(request), expectedError); @@ -1144,26 +1187,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); const [response] = await client.deleteProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct without error using callback', async () => { @@ -1175,15 +1218,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1206,11 +1246,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with error', async () => { @@ -1222,26 +1265,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProduct(request), expectedError); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with closed client', async () => { @@ -1253,7 +1296,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProduct(request), expectedError); @@ -1270,15 +1317,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() ); @@ -1286,11 +1330,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage without error using callback', async () => { @@ -1302,15 +1349,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() ); @@ -1333,11 +1377,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with error', async () => { @@ -1349,26 +1396,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with closed client', async () => { @@ -1380,7 +1427,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.CreateReferenceImageRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createReferenceImage(request), expectedError); @@ -1397,15 +1448,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1413,11 +1461,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.deleteReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage without error using callback', async () => { @@ -1429,15 +1480,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1460,11 +1508,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with error', async () => { @@ -1476,26 +1527,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with closed client', async () => { @@ -1507,7 +1558,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.DeleteReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteReferenceImage(request), expectedError); @@ -1524,26 +1579,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() ); client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); const [response] = await client.getReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage without error using callback', async () => { @@ -1555,15 +1610,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() ); @@ -1586,11 +1638,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with error', async () => { @@ -1602,26 +1657,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with closed client', async () => { @@ -1633,7 +1688,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.GetReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getReferenceImage(request), expectedError); @@ -1650,15 +1709,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1666,11 +1722,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addProductToProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet without error using callback', async () => { @@ -1682,15 +1741,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1713,11 +1769,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with error', async () => { @@ -1729,15 +1788,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addProductToProductSet = stubSimpleCall( undefined, @@ -1747,11 +1803,14 @@ describe('v1.ProductSearchClient', () => { client.addProductToProductSet(request), expectedError ); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with closed client', async () => { @@ -1763,7 +1822,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.AddProductToProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1783,15 +1846,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1799,11 +1859,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.removeProductFromProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet without error using callback', async () => { @@ -1815,15 +1878,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1846,11 +1906,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with error', async () => { @@ -1862,15 +1925,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.removeProductFromProductSet = stubSimpleCall( undefined, @@ -1880,11 +1940,14 @@ describe('v1.ProductSearchClient', () => { client.removeProductFromProductSet(request), expectedError ); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with closed client', async () => { @@ -1896,7 +1959,11 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.RemoveProductFromProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1916,15 +1983,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1933,11 +1997,14 @@ describe('v1.ProductSearchClient', () => { const [operation] = await client.importProductSets(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets without error using callback', async () => { @@ -1949,15 +2016,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1987,11 +2051,14 @@ describe('v1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with call error', async () => { @@ -2003,26 +2070,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importProductSets(request), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with LRO error', async () => { @@ -2034,15 +2101,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, @@ -2051,11 +2115,14 @@ describe('v1.ProductSearchClient', () => { ); const [operation] = await client.importProductSets(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportProductSetsProgress without error', async () => { @@ -2110,15 +2177,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2127,11 +2191,14 @@ describe('v1.ProductSearchClient', () => { const [operation] = await client.purgeProducts(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts without error using callback', async () => { @@ -2143,15 +2210,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2181,11 +2245,14 @@ describe('v1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts with call error', async () => { @@ -2197,26 +2264,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeProducts = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeProducts(request), expectedError); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts with LRO error', async () => { @@ -2228,15 +2295,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeProducts = stubLongRunningCall( undefined, @@ -2245,11 +2309,14 @@ describe('v1.ProductSearchClient', () => { ); const [operation] = await client.purgeProducts(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeProductsProgress without error', async () => { @@ -2304,15 +2371,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), @@ -2321,11 +2385,14 @@ describe('v1.ProductSearchClient', () => { client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); const [response] = await client.listProductSets(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets without error using callback', async () => { @@ -2337,15 +2404,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), @@ -2370,11 +2434,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets with error', async () => { @@ -2386,26 +2453,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductSets = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProductSets(request), expectedError); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSetsStream without error', async () => { @@ -2417,8 +2484,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), @@ -2449,11 +2520,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2466,8 +2538,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2493,11 +2569,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2510,8 +2587,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), generateSampleMessage(new protos.google.cloud.vision.v1.ProductSet()), @@ -2531,11 +2612,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2548,8 +2630,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2566,11 +2652,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2585,15 +2672,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -2602,11 +2686,14 @@ describe('v1.ProductSearchClient', () => { client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); const [response] = await client.listProducts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts without error using callback', async () => { @@ -2618,15 +2705,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -2651,11 +2735,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts with error', async () => { @@ -2667,26 +2754,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProducts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProducts(request), expectedError); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsStream without error', async () => { @@ -2698,8 +2785,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -2727,11 +2818,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2744,8 +2836,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.createStream = stubPageStreamingCall( undefined, @@ -2770,11 +2866,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2787,8 +2884,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -2808,11 +2909,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2825,8 +2927,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2843,11 +2949,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2862,15 +2969,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() @@ -2886,11 +2990,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listReferenceImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages without error using callback', async () => { @@ -2902,15 +3009,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() @@ -2941,11 +3045,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages with error', async () => { @@ -2957,26 +3064,26 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listReferenceImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listReferenceImages(request), expectedError); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImagesStream without error', async () => { @@ -2988,8 +3095,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() @@ -3026,11 +3137,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3043,8 +3155,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3070,11 +3186,12 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3087,8 +3204,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1.ReferenceImage() @@ -3114,11 +3235,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3131,8 +3253,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3149,11 +3275,12 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3168,15 +3295,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -3186,11 +3310,14 @@ describe('v1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listProductsInProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet without error using callback', async () => { @@ -3202,15 +3329,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -3235,11 +3359,14 @@ describe('v1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet with error', async () => { @@ -3251,15 +3378,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductsInProductSet = stubSimpleCall( undefined, @@ -3269,11 +3393,14 @@ describe('v1.ProductSearchClient', () => { client.listProductsInProductSet(request), expectedError ); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSetStream without error', async () => { @@ -3285,8 +3412,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -3317,12 +3448,15 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3335,8 +3469,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3362,12 +3500,15 @@ describe('v1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3380,8 +3521,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage(new protos.google.cloud.vision.v1.Product()), generateSampleMessage(new protos.google.cloud.vision.v1.Product()), @@ -3402,12 +3547,15 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3420,8 +3568,12 @@ describe('v1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3439,12 +3591,15 @@ describe('v1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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_product_search_v1p3beta1.ts b/test/gapic_product_search_v1p3beta1.ts index adad0827..32845326 100644 --- a/test/gapic_product_search_v1p3beta1.ts +++ b/test/gapic_product_search_v1p3beta1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -254,26 +269,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); const [response] = await client.createProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet without error using callback', async () => { @@ -285,15 +300,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); @@ -316,11 +328,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with error', async () => { @@ -332,26 +347,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProductSet(request), expectedError); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with closed client', async () => { @@ -363,7 +378,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductSetRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProductSet(request), expectedError); @@ -380,26 +399,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); const [response] = await client.getProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet without error using callback', async () => { @@ -411,15 +430,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); @@ -442,11 +458,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with error', async () => { @@ -458,26 +477,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProductSet(request), expectedError); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with closed client', async () => { @@ -489,7 +508,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProductSet(request), expectedError); @@ -506,27 +529,27 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); const [response] = await client.updateProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet without error using callback', async () => { @@ -538,16 +561,13 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() ); @@ -570,11 +590,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with error', async () => { @@ -586,27 +609,27 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProductSet(request), expectedError); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with closed client', async () => { @@ -618,8 +641,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProductSet(request), expectedError); @@ -636,26 +663,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); const [response] = await client.deleteProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet without error using callback', async () => { @@ -667,15 +694,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -698,11 +722,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with error', async () => { @@ -714,26 +741,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProductSet(request), expectedError); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with closed client', async () => { @@ -745,7 +772,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProductSet(request), expectedError); @@ -762,26 +793,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); const [response] = await client.createProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct without error using callback', async () => { @@ -793,15 +824,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); @@ -824,11 +852,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with error', async () => { @@ -840,26 +871,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProduct(request), expectedError); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with closed client', async () => { @@ -871,7 +902,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateProductRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProduct(request), expectedError); @@ -888,26 +923,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); const [response] = await client.getProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct without error using callback', async () => { @@ -919,15 +954,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); @@ -950,11 +982,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with error', async () => { @@ -966,26 +1001,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProduct(request), expectedError); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with closed client', async () => { @@ -997,7 +1032,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProduct(request), expectedError); @@ -1014,27 +1053,27 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); const [response] = await client.updateProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct without error using callback', async () => { @@ -1046,16 +1085,13 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() ); @@ -1078,11 +1114,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with error', async () => { @@ -1094,27 +1133,27 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProduct(request), expectedError); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with closed client', async () => { @@ -1126,8 +1165,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProduct(request), expectedError); @@ -1144,26 +1187,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); const [response] = await client.deleteProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct without error using callback', async () => { @@ -1175,15 +1218,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1206,11 +1246,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with error', async () => { @@ -1222,26 +1265,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProduct(request), expectedError); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with closed client', async () => { @@ -1253,7 +1296,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProduct(request), expectedError); @@ -1270,15 +1317,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() ); @@ -1286,11 +1330,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage without error using callback', async () => { @@ -1302,15 +1349,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() ); @@ -1333,11 +1377,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with error', async () => { @@ -1349,26 +1396,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with closed client', async () => { @@ -1380,7 +1427,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createReferenceImage(request), expectedError); @@ -1397,15 +1448,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1413,11 +1461,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.deleteReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage without error using callback', async () => { @@ -1429,15 +1480,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1460,11 +1508,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with error', async () => { @@ -1476,26 +1527,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with closed client', async () => { @@ -1507,7 +1558,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteReferenceImage(request), expectedError); @@ -1524,26 +1579,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() ); client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); const [response] = await client.getReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage without error using callback', async () => { @@ -1555,15 +1610,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() ); @@ -1586,11 +1638,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with error', async () => { @@ -1602,26 +1657,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with closed client', async () => { @@ -1633,7 +1688,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.GetReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getReferenceImage(request), expectedError); @@ -1650,15 +1709,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1666,11 +1722,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addProductToProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet without error using callback', async () => { @@ -1682,15 +1741,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1713,11 +1769,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with error', async () => { @@ -1729,15 +1788,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addProductToProductSet = stubSimpleCall( undefined, @@ -1747,11 +1803,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.addProductToProductSet(request), expectedError ); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with closed client', async () => { @@ -1763,7 +1822,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1783,15 +1846,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1799,11 +1859,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.removeProductFromProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet without error using callback', async () => { @@ -1815,15 +1878,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1846,11 +1906,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with error', async () => { @@ -1862,15 +1925,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.removeProductFromProductSet = stubSimpleCall( undefined, @@ -1880,11 +1940,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.removeProductFromProductSet(request), expectedError ); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with closed client', async () => { @@ -1896,7 +1959,11 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1916,15 +1983,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1933,11 +1997,14 @@ describe('v1p3beta1.ProductSearchClient', () => { const [operation] = await client.importProductSets(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets without error using callback', async () => { @@ -1949,15 +2016,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1987,11 +2051,14 @@ describe('v1p3beta1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with call error', async () => { @@ -2003,26 +2070,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importProductSets(request), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with LRO error', async () => { @@ -2034,15 +2101,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, @@ -2051,11 +2115,14 @@ describe('v1p3beta1.ProductSearchClient', () => { ); const [operation] = await client.importProductSets(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportProductSetsProgress without error', async () => { @@ -2110,15 +2177,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() @@ -2133,11 +2197,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); const [response] = await client.listProductSets(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets without error using callback', async () => { @@ -2149,15 +2216,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() @@ -2188,11 +2252,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets with error', async () => { @@ -2204,26 +2271,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductSets = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProductSets(request), expectedError); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSetsStream without error', async () => { @@ -2235,8 +2302,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() @@ -2273,11 +2344,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2290,8 +2362,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2317,11 +2393,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2334,8 +2411,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ProductSet() @@ -2361,11 +2442,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2378,8 +2460,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2397,11 +2483,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2416,15 +2503,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -2439,11 +2523,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); const [response] = await client.listProducts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts without error using callback', async () => { @@ -2455,15 +2542,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -2494,11 +2578,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts with error', async () => { @@ -2510,26 +2597,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProducts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProducts(request), expectedError); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsStream without error', async () => { @@ -2541,8 +2628,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -2579,11 +2670,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2596,8 +2688,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.createStream = stubPageStreamingCall( undefined, @@ -2625,11 +2721,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2642,8 +2739,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -2669,11 +2770,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2686,8 +2788,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2704,11 +2810,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2723,15 +2830,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() @@ -2747,11 +2851,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listReferenceImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages without error using callback', async () => { @@ -2763,15 +2870,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() @@ -2804,11 +2908,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages with error', async () => { @@ -2820,26 +2927,26 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listReferenceImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listReferenceImages(request), expectedError); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImagesStream without error', async () => { @@ -2851,8 +2958,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() @@ -2890,11 +3001,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2907,8 +3019,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2935,11 +3051,12 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2952,8 +3069,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ReferenceImage() @@ -2980,11 +3101,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2997,8 +3119,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3016,11 +3142,12 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3035,15 +3162,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -3059,11 +3183,14 @@ describe('v1p3beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listProductsInProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet without error using callback', async () => { @@ -3075,15 +3202,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -3114,11 +3238,14 @@ describe('v1p3beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet with error', async () => { @@ -3130,15 +3257,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductsInProductSet = stubSimpleCall( undefined, @@ -3148,11 +3272,14 @@ describe('v1p3beta1.ProductSearchClient', () => { client.listProductsInProductSet(request), expectedError ); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSetStream without error', async () => { @@ -3164,8 +3291,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -3205,12 +3336,15 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3223,8 +3357,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3253,12 +3391,15 @@ describe('v1p3beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3271,8 +3412,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.Product() @@ -3299,12 +3444,15 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3317,8 +3465,12 @@ describe('v1p3beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p3beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3336,12 +3488,15 @@ describe('v1p3beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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_product_search_v1p4beta1.ts b/test/gapic_product_search_v1p4beta1.ts index 538ec6e0..6baa71c8 100644 --- a/test/gapic_product_search_v1p4beta1.ts +++ b/test/gapic_product_search_v1p4beta1.ts @@ -27,6 +27,21 @@ import {PassThrough} from 'stream'; import {protobuf, LROperation, operationsProtos} from 'google-gax'; +// Dynamically loaded proto JSON is needed to get the type information +// to fill in default values for request objects +const root = protobuf.Root.fromJSON( + require('../protos/protos.json') +).resolveAll(); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function getTypeDefaultValue(typeName: string, fields: string[]) { + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; +} + function generateSampleMessage(instance: T) { const filledObject = ( instance.constructor as typeof protobuf.Message @@ -254,26 +269,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); client.innerApiCalls.createProductSet = stubSimpleCall(expectedResponse); const [response] = await client.createProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet without error using callback', async () => { @@ -285,15 +300,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); @@ -316,11 +328,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with error', async () => { @@ -332,26 +347,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProductSet(request), expectedError); - assert( - (client.innerApiCalls.createProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProductSet with closed client', async () => { @@ -363,7 +378,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductSetRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductSetRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProductSet(request), expectedError); @@ -380,26 +399,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); client.innerApiCalls.getProductSet = stubSimpleCall(expectedResponse); const [response] = await client.getProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet without error using callback', async () => { @@ -411,15 +430,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); @@ -442,11 +458,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with error', async () => { @@ -458,26 +477,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProductSet(request), expectedError); - assert( - (client.innerApiCalls.getProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProductSet with closed client', async () => { @@ -489,7 +508,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProductSet(request), expectedError); @@ -506,27 +529,27 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); client.innerApiCalls.updateProductSet = stubSimpleCall(expectedResponse); const [response] = await client.updateProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet without error using callback', async () => { @@ -538,16 +561,13 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() ); @@ -570,11 +590,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with error', async () => { @@ -586,27 +609,27 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; - const expectedHeaderRequestParams = 'product_set.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; + const expectedHeaderRequestParams = `product_set.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProductSet(request), expectedError); - assert( - (client.innerApiCalls.updateProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProductSet with closed client', async () => { @@ -618,8 +641,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductSetRequest() ); - request.productSet = {}; - request.productSet.name = ''; + request.productSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductSetRequest', + ['productSet', 'name'] + ); + request.productSet.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProductSet(request), expectedError); @@ -636,26 +663,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProductSet = stubSimpleCall(expectedResponse); const [response] = await client.deleteProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet without error using callback', async () => { @@ -667,15 +694,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -698,11 +722,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with error', async () => { @@ -714,26 +741,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProductSet = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProductSet(request), expectedError); - assert( - (client.innerApiCalls.deleteProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProductSet with closed client', async () => { @@ -745,7 +772,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProductSet(request), expectedError); @@ -762,26 +793,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); client.innerApiCalls.createProduct = stubSimpleCall(expectedResponse); const [response] = await client.createProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct without error using callback', async () => { @@ -793,15 +824,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); @@ -824,11 +852,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with error', async () => { @@ -840,26 +871,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createProduct(request), expectedError); - assert( - (client.innerApiCalls.createProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createProduct with closed client', async () => { @@ -871,7 +902,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateProductRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateProductRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createProduct(request), expectedError); @@ -888,26 +923,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); const [response] = await client.getProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct without error using callback', async () => { @@ -919,15 +954,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); @@ -950,11 +982,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with error', async () => { @@ -966,26 +1001,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getProduct(request), expectedError); - assert( - (client.innerApiCalls.getProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getProduct with closed client', async () => { @@ -997,7 +1032,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetProductRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getProduct(request), expectedError); @@ -1014,27 +1053,27 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); client.innerApiCalls.updateProduct = stubSimpleCall(expectedResponse); const [response] = await client.updateProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct without error using callback', async () => { @@ -1046,16 +1085,13 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() ); @@ -1078,11 +1114,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with error', async () => { @@ -1094,27 +1133,27 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; - const expectedHeaderRequestParams = 'product.name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; + const expectedHeaderRequestParams = `product.name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.updateProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.updateProduct(request), expectedError); - assert( - (client.innerApiCalls.updateProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes updateProduct with closed client', async () => { @@ -1126,8 +1165,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.UpdateProductRequest() ); - request.product = {}; - request.product.name = ''; + request.product ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.UpdateProductRequest', + ['product', 'name'] + ); + request.product.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.updateProduct(request), expectedError); @@ -1144,26 +1187,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); client.innerApiCalls.deleteProduct = stubSimpleCall(expectedResponse); const [response] = await client.deleteProduct(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct without error using callback', async () => { @@ -1175,15 +1218,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1206,11 +1246,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with error', async () => { @@ -1222,26 +1265,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteProduct = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteProduct(request), expectedError); - assert( - (client.innerApiCalls.deleteProduct as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteProduct with closed client', async () => { @@ -1253,7 +1296,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteProductRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteProductRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteProduct(request), expectedError); @@ -1270,15 +1317,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() ); @@ -1286,11 +1330,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.createReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage without error using callback', async () => { @@ -1302,15 +1349,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() ); @@ -1333,11 +1377,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with error', async () => { @@ -1349,26 +1396,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.createReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.createReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.createReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes createReferenceImage with closed client', async () => { @@ -1380,7 +1427,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest() ); - request.parent = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.CreateReferenceImageRequest', + ['parent'] + ); + request.parent = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.createReferenceImage(request), expectedError); @@ -1397,15 +1448,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1413,11 +1461,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.deleteReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage without error using callback', async () => { @@ -1429,15 +1480,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1460,11 +1508,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with error', async () => { @@ -1476,26 +1527,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.deleteReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.deleteReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.deleteReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes deleteReferenceImage with closed client', async () => { @@ -1507,7 +1558,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.DeleteReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.deleteReferenceImage(request), expectedError); @@ -1524,26 +1579,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() ); client.innerApiCalls.getReferenceImage = stubSimpleCall(expectedResponse); const [response] = await client.getReferenceImage(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage without error using callback', async () => { @@ -1555,15 +1610,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() ); @@ -1586,11 +1638,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with error', async () => { @@ -1602,26 +1657,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.getReferenceImage = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.getReferenceImage(request), expectedError); - assert( - (client.innerApiCalls.getReferenceImage as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReferenceImage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes getReferenceImage with closed client', async () => { @@ -1633,7 +1688,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.GetReferenceImageRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.GetReferenceImageRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects(client.getReferenceImage(request), expectedError); @@ -1650,15 +1709,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1666,11 +1722,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.addProductToProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet without error using callback', async () => { @@ -1682,15 +1741,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1713,11 +1769,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with error', async () => { @@ -1729,15 +1788,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.addProductToProductSet = stubSimpleCall( undefined, @@ -1747,11 +1803,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.addProductToProductSet(request), expectedError ); - assert( - (client.innerApiCalls.addProductToProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addProductToProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes addProductToProductSet with closed client', async () => { @@ -1763,7 +1822,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.AddProductToProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1783,15 +1846,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1799,11 +1859,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.removeProductFromProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet without error using callback', async () => { @@ -1815,15 +1878,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.protobuf.Empty() ); @@ -1846,11 +1906,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with error', async () => { @@ -1862,15 +1925,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.removeProductFromProductSet = stubSimpleCall( undefined, @@ -1880,11 +1940,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.removeProductFromProductSet(request), expectedError ); - assert( - (client.innerApiCalls.removeProductFromProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removeProductFromProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes removeProductFromProductSet with closed client', async () => { @@ -1896,7 +1959,11 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest() ); - request.name = ''; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.RemoveProductFromProductSetRequest', + ['name'] + ); + request.name = defaultValue1; const expectedError = new Error('The client has already been closed.'); client.close(); await assert.rejects( @@ -1916,15 +1983,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1933,11 +1997,14 @@ describe('v1p4beta1.ProductSearchClient', () => { const [operation] = await client.importProductSets(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets without error using callback', async () => { @@ -1949,15 +2016,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -1987,11 +2051,14 @@ describe('v1p4beta1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with call error', async () => { @@ -2003,26 +2070,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.importProductSets(request), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes importProductSets with LRO error', async () => { @@ -2034,15 +2101,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ImportProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ImportProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.importProductSets = stubLongRunningCall( undefined, @@ -2051,11 +2115,14 @@ describe('v1p4beta1.ProductSearchClient', () => { ); const [operation] = await client.importProductSets(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.importProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkImportProductSetsProgress without error', async () => { @@ -2110,15 +2177,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2127,11 +2191,14 @@ describe('v1p4beta1.ProductSearchClient', () => { const [operation] = await client.purgeProducts(request); const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts without error using callback', async () => { @@ -2143,15 +2210,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = generateSampleMessage( new protos.google.longrunning.Operation() ); @@ -2181,11 +2245,14 @@ describe('v1p4beta1.ProductSearchClient', () => { >; const [response] = await operation.promise(); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts with call error', async () => { @@ -2197,26 +2264,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeProducts = stubLongRunningCall( undefined, expectedError ); await assert.rejects(client.purgeProducts(request), expectedError); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes purgeProducts with LRO error', async () => { @@ -2228,15 +2295,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.PurgeProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.PurgeProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.purgeProducts = stubLongRunningCall( undefined, @@ -2245,11 +2309,14 @@ describe('v1p4beta1.ProductSearchClient', () => { ); const [operation] = await client.purgeProducts(request); await assert.rejects(operation.promise(), expectedError); - assert( - (client.innerApiCalls.purgeProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes checkPurgeProductsProgress without error', async () => { @@ -2304,15 +2371,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() @@ -2327,11 +2391,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.innerApiCalls.listProductSets = stubSimpleCall(expectedResponse); const [response] = await client.listProductSets(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets without error using callback', async () => { @@ -2343,15 +2410,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() @@ -2382,11 +2446,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSets with error', async () => { @@ -2398,26 +2465,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductSets = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProductSets(request), expectedError); - assert( - (client.innerApiCalls.listProductSets as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductSetsStream without error', async () => { @@ -2429,8 +2496,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() @@ -2467,11 +2538,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2484,8 +2556,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.createStream = stubPageStreamingCall(undefined, expectedError); @@ -2511,11 +2587,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductSets, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2528,8 +2605,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ProductSet() @@ -2555,11 +2636,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2572,8 +2654,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductSetsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductSetsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2591,11 +2677,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProductSets.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProductSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2610,15 +2697,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -2633,11 +2717,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); const [response] = await client.listProducts(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts without error using callback', async () => { @@ -2649,15 +2736,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -2688,11 +2772,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProducts with error', async () => { @@ -2704,26 +2791,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProducts = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listProducts(request), expectedError); - assert( - (client.innerApiCalls.listProducts as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsStream without error', async () => { @@ -2735,8 +2822,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -2773,11 +2864,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2790,8 +2882,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.createStream = stubPageStreamingCall( undefined, @@ -2819,11 +2915,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProducts, request) ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2836,8 +2933,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -2863,11 +2964,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -2880,8 +2982,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -2898,11 +3004,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listProducts.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -2917,15 +3024,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() @@ -2941,11 +3045,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listReferenceImages(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages without error using callback', async () => { @@ -2957,15 +3064,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() @@ -2998,11 +3102,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImages with error', async () => { @@ -3014,26 +3121,26 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listReferenceImages = stubSimpleCall( undefined, expectedError ); await assert.rejects(client.listReferenceImages(request), expectedError); - assert( - (client.innerApiCalls.listReferenceImages as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReferenceImages as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listReferenceImagesStream without error', async () => { @@ -3045,8 +3152,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() @@ -3084,11 +3195,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3101,8 +3213,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3129,11 +3245,12 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listReferenceImages, request) ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.createStream as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3146,8 +3263,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ReferenceImage() @@ -3174,11 +3295,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); @@ -3191,8 +3313,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest() ); - request.parent = ''; - const expectedHeaderRequestParams = 'parent='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListReferenceImagesRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listReferenceImages.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3210,11 +3336,12 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( - ( - client.descriptors.page.listReferenceImages.asyncIterate as SinonStub - ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams + assert( + (client.descriptors.page.listReferenceImages.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams + ) ); }); }); @@ -3229,15 +3356,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -3253,11 +3377,14 @@ describe('v1p4beta1.ProductSearchClient', () => { stubSimpleCall(expectedResponse); const [response] = await client.listProductsInProductSet(request); assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet without error using callback', async () => { @@ -3269,15 +3396,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -3308,11 +3432,14 @@ describe('v1p4beta1.ProductSearchClient', () => { }); const response = await promise; assert.deepStrictEqual(response, expectedResponse); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions /*, callback defined above */) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSet with error', async () => { @@ -3324,15 +3451,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.innerApiCalls.listProductsInProductSet = stubSimpleCall( undefined, @@ -3342,11 +3466,14 @@ describe('v1p4beta1.ProductSearchClient', () => { client.listProductsInProductSet(request), expectedError ); - assert( - (client.innerApiCalls.listProductsInProductSet as SinonStub) - .getCall(0) - .calledWith(request, expectedOptions, undefined) - ); + const actualRequest = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProductsInProductSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); it('invokes listProductsInProductSetStream without error', async () => { @@ -3358,8 +3485,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -3399,12 +3530,15 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3417,8 +3551,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.createStream = stubPageStreamingCall(undefined, expectedError); @@ -3447,12 +3585,15 @@ describe('v1p4beta1.ProductSearchClient', () => { .getCall(0) .calledWith(client.innerApiCalls.listProductsInProductSet, request) ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3465,8 +3606,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedResponse = [ generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.Product() @@ -3493,12 +3638,15 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); @@ -3511,8 +3659,12 @@ describe('v1p4beta1.ProductSearchClient', () => { const request = generateSampleMessage( new protos.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest() ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.vision.v1p4beta1.ListProductsInProductSetRequest', + ['name'] + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1}`; const expectedError = new Error('expected'); client.descriptors.page.listProductsInProductSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); @@ -3530,12 +3682,15 @@ describe('v1p4beta1.ProductSearchClient', () => { ).getCall(0).args[1], request ); - assert.strictEqual( + assert( ( client.descriptors.page.listProductsInProductSet .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 + ) ); }); });