Skip to content

Commit 84317cb

Browse files
add tests
1 parent f72b8ce commit 84317cb

6 files changed

Lines changed: 330 additions & 134 deletions

File tree

packages/bigtable/system-test/bigtable.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,7 @@ describe('Bigtable', function() {
274274

275275
it('should get the tables metadata', function(done) {
276276
TABLE.getMetadata(function(err, metadata) {
277-
assert.strictEqual(
278-
metadata.name,
279-
TABLE.id.replace('{{projectId}}', bigtable.projectId)
280-
);
277+
assert.strictEqual(metadata.name, TABLE.id);
281278
done();
282279
});
283280
});

packages/common/src/grpc-service.js

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,6 @@ GrpcService.prototype.request = function(protoOpts, reqOpts, callback) {
241241
return;
242242
}
243243

244-
// Clean up gcloud-specific options.
245-
delete reqOpts.autoPaginate;
246-
delete reqOpts.autoPaginateVal;
247-
248244
var service = this.getService_(protoOpts);
249245

250246
var metadata = this.grpcMetadata;
@@ -254,6 +250,13 @@ GrpcService.prototype.request = function(protoOpts, reqOpts, callback) {
254250
grpcOpts.deadline = GrpcService.createDeadline_(protoOpts.timeout);
255251
}
256252

253+
try {
254+
reqOpts = util.decorateRequest(reqOpts, { projectId: self.projectId });
255+
} catch(e) {
256+
callback(e);
257+
return;
258+
}
259+
257260
// Retains a reference to an error from the response. If the final callback is
258261
// executed with this as the "response", we return it to the user as an error.
259262
var respError;
@@ -269,13 +272,6 @@ GrpcService.prototype.request = function(protoOpts, reqOpts, callback) {
269272
request: function(_, onResponse) {
270273
respError = null;
271274

272-
try {
273-
reqOpts = util.decorateRequest(reqOpts, { projectId: self.projectId });
274-
} catch (e) {
275-
onResponse(e);
276-
return;
277-
}
278-
279275
service[protoOpts.method](reqOpts, metadata, grpcOpts, function(e, resp) {
280276
if (e) {
281277
respError = GrpcService.decorateError_(e);
@@ -342,17 +338,7 @@ GrpcService.prototype.requestStream = function(protoOpts, reqOpts) {
342338
return stream;
343339
}
344340

345-
try {
346-
reqOpts = util.decorateRequest(reqOpts, { projectId: this.projectId });
347-
} catch (e) {
348-
setImmediate(function() {
349-
stream.destroy(e);
350-
});
351-
return stream;
352-
}
353-
354341
var objectMode = !!reqOpts.objectMode;
355-
delete reqOpts.objectMode;
356342

357343
var service = this.getService_(protoOpts);
358344
var grpcOpts = {};
@@ -361,6 +347,15 @@ GrpcService.prototype.requestStream = function(protoOpts, reqOpts) {
361347
grpcOpts.deadline = GrpcService.createDeadline_(protoOpts.timeout);
362348
}
363349

350+
try {
351+
reqOpts = util.decorateRequest(reqOpts, { projectId: this.projectId });
352+
} catch(e) {
353+
setImmediate(function() {
354+
stream.destroy(e);
355+
});
356+
return stream;
357+
}
358+
364359
var retryOpts = {
365360
retries: this.maxRetries,
366361
objectMode: objectMode,

packages/common/src/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ util.makeRequest = makeRequest;
479479
function decorateRequest(reqOpts, config) {
480480
config = config || {};
481481

482+
delete reqOpts.autoPaginate;
483+
delete reqOpts.autoPaginateVal;
484+
delete reqOpts.objectMode;
485+
482486
if (is.object(reqOpts.qs)) {
483487
delete reqOpts.qs.autoPaginate;
484488
delete reqOpts.qs.autoPaginateVal;

0 commit comments

Comments
 (0)