Skip to content

Commit

Permalink
Minor stylistic tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ace Nassri committed Aug 22, 2016
1 parent 3d35fac commit bbd5ee8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
16 changes: 9 additions & 7 deletions bigquery/system-test/export_data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ describe('bigquery:export_data', function () {
it('should export data to GCS', function (done) {
example.exportTableToGCS(options, function (err, job) {
assert.ifError(err);
assert.notEqual(job, null);
assert.notEqual(job.id, null);
assert(job.id.length > 5);
assert(job, 'job is not null');
assert(job.id, 'job has an id');
assert(job.id.length > 5, 'job id is 5 characters or more');
jobId = job.id;
setTimeout(done, 100); // Wait for export job to be submitted
});
Expand All @@ -38,15 +38,17 @@ describe('bigquery:export_data', function () {

describe('export_poll', function () {
it('should fetch job status', function (done) {
assert.notEqual(jobId, null);
assert(jobId);
var poller = function (tries) {
example.pollExportJob(jobId, function (err, metadata) {
if (!err || tries === 0) {
assert.ifError(err);
assert.equal(metadata.status.state, 'DONE');
assert.ifError(err, 'no error occurred');
assert.equal(metadata.status.state, 'DONE', 'export job is finished');
done();
} else {
setTimeout(function () { poller(tries - 1); }, 1000);
setTimeout(function () {
poller(tries - 1);
}, 1000);
}
});
};
Expand Down
22 changes: 10 additions & 12 deletions bigquery/test/export_data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ describe('bigquery:export', function () {
example.mocks.bigquery.job = sinon.stub().returns(example.mocks.job);
example.program.pollExportJob(example.jobId, callback);

assert(example.mocks.bigquery.job.calledOnce);
assert(example.mocks.job.getMetadata.calledOnce);
assert(callback.calledOnce);
assert.equal(callback.firstCall.args.length, 2);
assert.equal(callback.firstCall.args[0], null);
assert.deepEqual(callback.firstCall.args[1], example.mocks.metadata);
assert(example.mocks.bigquery.job.calledOnce, 'job called once');
assert(example.mocks.job.getMetadata.calledOnce, 'getMetadata called once');
assert(callback.calledOnce, 'callback called once');
assert.equal(callback.firstCall.args.length, 2, 'callback received 2 arguments');
assert.equal(callback.firstCall.args[0], null, 'callback did not receive error');
assert.deepEqual(callback.firstCall.args[1], example.mocks.metadata,
'callback received metadata'
);

assert(
console.log.calledWith('PollExportJob: job status: %s', example.mocks.metadata.status.state),
Expand All @@ -148,9 +150,7 @@ describe('bigquery:export', function () {
assert(example.mocks.job.getMetadata.calledOnce, 'getMetadata called once');
assert(callback.calledOnce, 'callback called once');
assert.equal(callback.firstCall.args.length, 1, 'callback received 1 argument');
assert.deepEqual(
callback.firstCall.args[0],
new Error('Job %s is not done'),
assert.deepEqual(callback.firstCall.args[0], new Error('Job %s is not done'),
'callback received error'
);

Expand All @@ -168,9 +168,7 @@ describe('bigquery:export', function () {

assert.equal(callback.secondCall.args.length, 2, 'callback received 2 arguments');
assert.ifError(callback.secondCall.args[0], 'callback did not receive error');
assert.deepEqual(
callback.secondCall.args[1],
example.mocks.metadata,
assert.deepEqual(callback.secondCall.args[1], example.mocks.metadata,
'callback received metadata'
);

Expand Down

0 comments on commit bbd5ee8

Please sign in to comment.