Skip to content

Commit

Permalink
fix: cluster id store as undefined in createInstance request (#654)
Browse files Browse the repository at this point in the history
* fix: cluster id store as undefined
  • Loading branch information
laljikanjareeya committed Mar 23, 2020
1 parent 69839cd commit 809c719
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Expand Up @@ -641,6 +641,12 @@ export class Bigtable {
}

reqOpts.clusters = arrify(options.clusters!).reduce((clusters, cluster) => {
if (!cluster.id) {
throw new Error(
'A cluster was provided without an `id` property defined.'
);
}

clusters[cluster.id!] = {
location: Cluster.getLocation_(this.projectId, cluster.location!),
serveNodes: cluster.nodes,
Expand Down
17 changes: 17 additions & 0 deletions test/index.ts
Expand Up @@ -489,6 +489,23 @@ describe('Bigtable', () => {
done();
});
});

it('should throw an error if cluster id not provided.', () => {
const options = {
displayName: 'my-sweet-instance',
labels: {env: 'prod'},
clusters: [
{
nodes: 3,
location: 'us-central1-b',
storage: 'ssd',
},
],
};
assert.throws(() => {
bigtable.createInstance(INSTANCE_ID, options);
}, /A cluster was provided without an `id` property defined\./);
});
});

describe('getInstances', () => {
Expand Down

0 comments on commit 809c719

Please sign in to comment.