diff --git a/lib/bigquery/table.js b/lib/bigquery/table.js index 3e92bd5ca8c..e8a902244a8 100644 --- a/lib/bigquery/table.js +++ b/lib/bigquery/table.js @@ -632,7 +632,9 @@ Table.prototype.import = function(source, metadata, callback) { return fs.createReadStream(source) .pipe(this.createWriteStream(metadata)) .on('error', callback) - .on('complete', callback); + .on('complete', function(job) { + callback(null, job); + }); } var body = { diff --git a/test/bigquery/table.js b/test/bigquery/table.js index 30535c86979..ab074b8f257 100644 --- a/test/bigquery/table.js +++ b/test/bigquery/table.js @@ -698,16 +698,22 @@ describe('BigQuery/Table', function() { }, 'file.json'); it('should accept just a File and a callback', function(done) { + var mockJob = { id: 'foo' }; + table.createWriteStream = function() { var ws = new stream.Writable(); setImmediate(function() { - ws.emit('complete'); + ws.emit('complete', mockJob); ws.end(); }); return ws; }; - table.import(FILEPATH, done); + table.import(FILEPATH, function(error, job) { + assert.strictEqual(error, null); + assert.deepEqual(job, mockJob); + done(); + }); }); it('should return a stream when a string is given', function() {