From 2b31d15ecc028030a56065f4ff30c8f4d487e330 Mon Sep 17 00:00:00 2001 From: Dave Gramlich Date: Mon, 11 Jul 2016 22:44:06 -0400 Subject: [PATCH 1/2] updated cluster links and option handling --- README.md | 4 ++-- lib/bigtable/index.js | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6e58cf9ea26..a2a43c79b1e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/lib/bigtable/index.js b/lib/bigtable/index.js index 32a80c5c41e..0b79dfc5e46 100644 --- a/lib/bigtable/index.js +++ b/lib/bigtable/index.js @@ -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} @@ -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. @@ -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 + * // the * // official Bigtable documentation for more information. * //- * @@ -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}', From ba265a8bc7d5d092380956426ead8c24469d6f3f Mon Sep 17 00:00:00 2001 From: Dave Gramlich Date: Tue, 12 Jul 2016 00:43:26 -0400 Subject: [PATCH 2/2] added test for options --- test/bigtable/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/bigtable/index.js b/test/bigtable/index.js index 6d6698263a6..eab807c68f5 100644 --- a/test/bigtable/index.js +++ b/test/bigtable/index.js @@ -110,6 +110,24 @@ describe('Bigtable', function() { fakeUtil.normalizeArguments = normalizeArguments; }); + it('should leave the original options unaltered', function() { + 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); });