Skip to content

Commit f741be2

Browse files
committed
updated admin base url with custom endpoint for emulator use
1 parent 1cc8dba commit f741be2

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

packages/bigtable/src/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,22 @@ function Bigtable(options) {
292292
return new Bigtable(options);
293293
}
294294

295+
var baseUrl = 'bigtable.googleapis.com';
295296
var adminBaseUrl = 'bigtableadmin.googleapis.com';
296297

297-
var customEndpoint = is.defined(options.apiEndpoint) ||
298-
is.defined(process.env.BIGTABLE_EMULATOR_HOST);
299-
300-
var baseUrl = 'bigtable.googleapis.com';
298+
var customEndpoint = options.apiEndpoint ||
299+
process.env.BIGTABLE_EMULATOR_HOST;
301300

302301
if (customEndpoint) {
303-
baseUrl = options.apiEndpoint || process.env.BIGTABLE_EMULATOR_HOST;
302+
baseUrl = customEndpoint;
303+
adminBaseUrl = baseUrl;
304304
}
305305

306306
var config = {
307307
baseUrl: baseUrl,
308308
service: 'bigtable',
309309
apiVersion: 'v2',
310-
customEndpoint: customEndpoint,
310+
customEndpoint: !!customEndpoint,
311311
protoServices: {
312312
Bigtable: googleProtoFiles.bigtable.v2,
313313
BigtableTableAdmin: {

packages/bigtable/test/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
var assert = require('assert');
2020
var extend = require('extend');
2121
var googleProtoFiles = require('google-proto-files');
22+
var is = require('is');
2223
var nodeutil = require('util');
2324
var proxyquire = require('proxyquire');
2425
var sinon = require('sinon').sandbox.create();
@@ -157,6 +158,16 @@ describe('Bigtable', function() {
157158
var calledWith = bigtable.calledWith_[0];
158159
assert.strictEqual(calledWith.baseUrl, endpoint);
159160
assert.strictEqual(calledWith.customEndpoint, true);
161+
162+
Object.keys(calledWith.protoServices).forEach(function(service) {
163+
service = calledWith.protoServices[service];
164+
165+
if (is.object(service)) {
166+
assert.strictEqual(service.baseUrl, endpoint);
167+
}
168+
});
169+
170+
delete process.env.BIGTABLE_EMULATOR_HOST;
160171
});
161172

162173
it('should work with a custom apiEndpoint', function() {
@@ -170,6 +181,14 @@ describe('Bigtable', function() {
170181
var calledWith = bigtable.calledWith_[0];
171182
assert.strictEqual(calledWith.baseUrl, options.apiEndpoint);
172183
assert.strictEqual(calledWith.customEndpoint, true);
184+
185+
Object.keys(calledWith.protoServices).forEach(function(service) {
186+
service = calledWith.protoServices[service];
187+
188+
if (is.object(service)) {
189+
assert.strictEqual(service.baseUrl, options.apiEndpoint);
190+
}
191+
});
173192
});
174193

175194
it('should set the projectName', function() {

0 commit comments

Comments
 (0)