Skip to content

Commit

Permalink
npm run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
jkwlui committed Aug 25, 2018
1 parent 84d7ec2 commit 4a00c05
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 45 deletions.
33 changes: 16 additions & 17 deletions src/v1beta1/asset_service_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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'];
}

/**
Expand Down Expand Up @@ -417,7 +415,11 @@ class AssetServiceClient {
}
options = options || {};

return this._innerApiCalls.batchGetAssetsHistory(request, options, callback);
return this._innerApiCalls.batchGetAssetsHistory(
request,
options,
callback
);
}

// --------------------
Expand All @@ -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;
75 changes: 47 additions & 28 deletions test/gapic-v1beta1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -74,27 +81,41 @@ 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', () => {
var client = new assetModule.v1beta1.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
);
});
});

Expand Down Expand Up @@ -166,7 +187,6 @@ describe('AssetServiceClient', () => {
});
});
});

});

function mockSimpleGrpcMethod(expectedRequest, response, error) {
Expand All @@ -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]);
};
Expand Down

0 comments on commit 4a00c05

Please sign in to comment.