Skip to content

Commit

Permalink
Bug fix - stop promisifying Job#promise and Operation#promise (#1732)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry authored and stephenplusplus committed Oct 21, 2016
1 parent d8cbf38 commit 8000535
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/bigquery/system-test/bigquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,17 @@ describe('BigQuery', function() {
});
});

it('should import data from a file via promises', function() {
return table.import(file)
.then(function(results) {
return results[0].promise();
})
.then(function(results) {
var metadata = results[0];
assert.strictEqual(metadata.status.state, 'DONE');
});
});

it('should convert values to their schema types', function(done) {
var data = {
name: 'dave',
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ function promisifyAll(Class, options) {
.keys(Class.prototype)
.filter(function(methodName) {
return is.fn(Class.prototype[methodName]) && // is it a function?
!/(^\_|(Stream|\_)$)/.test(methodName) && // is it public/non-stream?
!/(^\_|(Stream|\_)|promise$)/.test(methodName) && // is it promisable?
exclude.indexOf(methodName) === -1; // is it blacklisted?
});

Expand Down
2 changes: 2 additions & 0 deletions packages/common/test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ describe('common/util', function() {
FakeClass.prototype.method_ = util.noop;
FakeClass.prototype._method = util.noop;
FakeClass.prototype.methodStream = util.noop;
FakeClass.prototype.promise = util.noop;

util.promisifyAll(FakeClass);
instance = new FakeClass();
Expand All @@ -1420,6 +1421,7 @@ describe('common/util', function() {
assert.strictEqual(FakeClass.prototype.method_, util.noop);
assert.strictEqual(FakeClass.prototype._method, util.noop);
assert.strictEqual(FakeClass.prototype.methodStream, util.noop);
assert.strictEqual(FakeClass.prototype.promise, util.noop);
});

it('should optionally except an exclude list', function() {
Expand Down

0 comments on commit 8000535

Please sign in to comment.