Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated cluster links and option handling #1420

Merged
merged 2 commits into from
Jul 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ job.getQueryResults().on('data', function(row) {});
- [API Documentation][gcloud-bigtable-docs]
- [Official Documentation][cloud-bigtable-docs]

*You may need to [create a cluster][gcloud-bigtable-cluster] to use the Google Cloud Bigtable API with your project.*
*You may need to [create a cluster][cloud-bigtable-cluster] to use the Google Cloud Bigtable API with your project.*

#### Preview

Expand Down Expand Up @@ -740,7 +740,7 @@ Apache 2.0 - See [COPYING](COPYING) for more information.
[cloud-bigquery-docs]: https://cloud.google.com/bigquery/what-is-bigquery

[cloud-bigtable-docs]: https://cloud.google.com/bigtable/docs/
[cloud-bigtable-cluster]: https://cloud.google.com/bigtable/docs/creating-cluster
[cloud-bigtable-cluster]: https://cloud.google.com/bigtable/docs/creating-compute-instance

[cloud-compute-docs]: https://cloud.google.com/compute/docs

Expand Down
13 changes: 6 additions & 7 deletions lib/bigtable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var googleProtoFiles = require('google-proto-files');
var is = require('is');
var nodeutil = require('util');
var format = require('string-format-obj');
var extend = require('extend');

/**
* @type {module:bigtable/table}
Expand Down Expand Up @@ -56,7 +57,7 @@ var util = require('../common/util.js');
* To learn more about Bigtable, read the
* [Google Cloud Bigtable Concepts Overview](https://cloud.google.com/bigtable/docs/concepts)
*
* @resource [Creating a Cloud Bigtable Cluster]{@link https://cloud.google.com/bigtable/docs/creating-cluster}
* @resource [Creating a Cloud Bigtable Cluster]{@link https://cloud.google.com/bigtable/docs/creating-compute-instance}
*
* @param {object=} options - [Configuration object](#/docs).
* @param {string} options.cluster - The cluster name that hosts your tables.
Expand All @@ -80,7 +81,7 @@ var util = require('../common/util.js');
* // Before you create your table, you first need to create a Bigtable Cluster
* // for the table to be served from. This can be done from either the
* // Google Cloud Platform Console or the `gcloud` cli tool. Please refer to
* // the <a href="https://cloud.google.com/bigtable/docs/creating-cluster">
* // the <a href="https://cloud.google.com/bigtable/docs/creating-compute-instance">
* // official Bigtable documentation</a> for more information.
* //-
*
Expand Down Expand Up @@ -280,11 +281,9 @@ function Bigtable(options) {
return new Bigtable(options);
}

options = {
projectId: options.projectId,
zone: options.zone.name || options.zone,
cluster: options.cluster
};
options = extend({}, options, {
zone: options.zone.name || options.zone
});

this.clusterName = format(
'projects/{projectId}/zones/{zone}/clusters/{cluster}',
Expand Down
18 changes: 18 additions & 0 deletions test/bigtable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ describe('Bigtable', function() {
fakeUtil.normalizeArguments = normalizeArguments;
});

it('should leave the original options unaltered', function() {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

var fakeOptions = {
a: 'a',
b: 'b',
c: 'c',
zone: 'zone'
};

var bigtable = new Bigtable(fakeOptions);
var options = bigtable.calledWith_[1];

for (var option in fakeOptions) {
assert.strictEqual(fakeOptions[option], options[option]);
}

assert.notStrictEqual(fakeOptions, options);
});

it('should localize the cluster name', function() {
assert.strictEqual(bigtable.clusterName, CLUSTER_NAME);
});
Expand Down