Skip to content

Commit

Permalink
fix: set instanceId to the given id (#1094)
Browse files Browse the repository at this point in the history
Previously if a display name was given, we were setting the instanceId
to the display name. This is a bug.

Fixes #1093
  • Loading branch information
skuruppu committed Jun 11, 2020
1 parent 58f773b commit 8973cbc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class Spanner extends GrpcService {
const displayName = config.displayName || formattedName.split('/').pop();
const reqOpts = {
parent: 'projects/' + this.projectId,
instanceId: displayName,
instanceId: formattedName.split('/').pop(),
instance: extend(
{
name: formattedName,
Expand Down
24 changes: 24 additions & 0 deletions test/spanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2283,6 +2283,30 @@ describe('Spanner with mock server', () => {
assert.strictEqual(createdInstance.nodeCount, 10);
});

it('should create an instance with a display name', async () => {
const [createdInstance] = await spanner
.createInstance('new-instance', {
config: 'test-instance-config',
nodes: 10,
displayName: 'some new instance',
})
.then(data => {
const operation = data[1];
return operation.promise() as Promise<
[Instance, CreateInstanceMetadata, object]
>;
})
.then(response => {
return response;
});
assert.strictEqual(
createdInstance.name,
`projects/${spanner.projectId}/instances/new-instance`
);
assert.strictEqual(createdInstance.nodeCount, 10);
assert.strictEqual(createdInstance.displayName, 'some new instance');
});

it('should create an instance using a callback', done => {
spanner.createInstance(
'new-instance',
Expand Down

0 comments on commit 8973cbc

Please sign in to comment.