diff --git a/src/v1beta1/asset_service_client.js b/src/v1beta1/asset_service_client.js index a6ae2716..cffe3aeb 100644 --- a/src/v1beta1/asset_service_client.js +++ b/src/v1beta1/asset_service_client.js @@ -101,17 +101,20 @@ class AssetServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - projectPathTemplate: new gax.PathTemplate( - 'projects/{project}' - ), + projectPathTemplate: new gax.PathTemplate('projects/{project}'), }; var protoFilesRoot = new gax.GoogleProtoFilesRoot(); protoFilesRoot = protobuf.loadSync( - path.join(__dirname, '..', '..', 'protos', 'google/cloud/asset/v1beta1/asset_service.proto'), + path.join( + __dirname, + '..', + '..', + 'protos', + 'google/cloud/asset/v1beta1/asset_service.proto' + ), protoFilesRoot ); - // This API contains "long-running operations", which return a // an Operation object that allows for tracking of the operation, // rather than holding a request open. @@ -157,10 +160,7 @@ class AssetServiceClient { // Iterate over each of the methods that the service provides // and create an API call method for each. - var assetServiceStubMethods = [ - 'exportAssets', - 'batchGetAssetsHistory', - ]; + var assetServiceStubMethods = ['exportAssets', 'batchGetAssetsHistory']; for (let methodName of assetServiceStubMethods) { this._innerApiCalls[methodName] = gax.createApiCall( assetServiceStub.then( @@ -195,9 +195,7 @@ class AssetServiceClient { * in this service. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } /** @@ -417,7 +415,11 @@ class AssetServiceClient { } options = options || {}; - return this._innerApiCalls.batchGetAssetsHistory(request, options, callback); + return this._innerApiCalls.batchGetAssetsHistory( + request, + options, + callback + ); } // -------------------- @@ -444,11 +446,8 @@ class AssetServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromProjectName(projectName) { - return this._pathTemplates.projectPathTemplate - .match(projectName) - .project; + return this._pathTemplates.projectPathTemplate.match(projectName).project; } } - module.exports = AssetServiceClient; diff --git a/test/gapic-v1beta1.js b/test/gapic-v1beta1.js index 5adeca94..5fdcecf0 100644 --- a/test/gapic-v1beta1.js +++ b/test/gapic-v1beta1.js @@ -44,17 +44,24 @@ describe('AssetServiceClient', () => { var expectedResponse = {}; // Mock Grpc layer - client._innerApiCalls.exportAssets = mockLongRunningGrpcMethod(request, expectedResponse); + client._innerApiCalls.exportAssets = mockLongRunningGrpcMethod( + request, + expectedResponse + ); - client.exportAssets(request).then(responses => { - var operation = responses[0]; - return operation.promise(); - }).then(responses => { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }).catch(err => { - done(err); - }); + client + .exportAssets(request) + .then(responses => { + var operation = responses[0]; + return operation.promise(); + }) + .then(responses => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch(err => { + done(err); + }); }); it('invokes exportAssets with error', done => { @@ -74,18 +81,26 @@ describe('AssetServiceClient', () => { }; // Mock Grpc layer - client._innerApiCalls.exportAssets = mockLongRunningGrpcMethod(request, null, error); - - client.exportAssets(request).then(responses => { - var operation = responses[0]; - return operation.promise(); - }).then(() => { - assert.fail(); - }).catch(err => { - assert(err instanceof Error); - assert.strictEqual(err.code, FAKE_STATUS_CODE); - done(); - }); + client._innerApiCalls.exportAssets = mockLongRunningGrpcMethod( + request, + null, + error + ); + + client + .exportAssets(request) + .then(responses => { + var operation = responses[0]; + return operation.promise(); + }) + .then(() => { + assert.fail(); + }) + .catch(err => { + assert(err instanceof Error); + assert.strictEqual(err.code, FAKE_STATUS_CODE); + done(); + }); }); it('has longrunning decoder functions', () => { @@ -93,8 +108,14 @@ describe('AssetServiceClient', () => { credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); - assert(client._descriptors.longrunning.exportAssets.responseDecoder instanceof Function); - assert(client._descriptors.longrunning.exportAssets.metadataDecoder instanceof Function); + assert( + client._descriptors.longrunning.exportAssets.responseDecoder instanceof + Function + ); + assert( + client._descriptors.longrunning.exportAssets.metadataDecoder instanceof + Function + ); }); }); @@ -166,7 +187,6 @@ describe('AssetServiceClient', () => { }); }); }); - }); function mockSimpleGrpcMethod(expectedRequest, response, error) { @@ -190,12 +210,11 @@ function mockLongRunningGrpcMethod(expectedRequest, response, error) { return new Promise((resolve, reject) => { if (error) { reject(error); - } - else { + } else { resolve([response]); } }); - } + }, }; return Promise.resolve([mockOperation]); };