diff --git a/test/acceptance/batch/job.query.order.test.js b/test/acceptance/batch/job.query.order.test.js new file mode 100644 index 00000000..a56d6e50 --- /dev/null +++ b/test/acceptance/batch/job.query.order.test.js @@ -0,0 +1,57 @@ +require('../../helper'); +var assert = require('../../support/assert'); + +var BatchTestClient = require('./batch-test-client'); +var JobStatus = require('../../../batch/job_status'); + +describe('job query order', function() { + + before(function() { + this.batchTestClient = new BatchTestClient(); + }); + + after(function (done) { + return this.batchTestClient.drain(done); + }); + + function createJob(queries) { + return { + query: queries + }; + } + + it('should run query with higher user timeout', function (done) { + var jobRequest1 = createJob(["select 1", "select 2"]); + var jobRequest2 = createJob(["select 3"]); + + this.batchTestClient.createJob(jobRequest1, function(err, jobResult1) { + if (err) { + return done(err); + } + this.batchTestClient.createJob(jobRequest2, function(err, jobResult2) { + if (err) { + return done(err); + } + + jobResult1.getStatus(function (err, job1) { + if (err) { + return done(err); + } + jobResult2.getStatus(function(err, job2) { + if (err) { + return done(err); + } + assert.equal(job1.status, JobStatus.DONE); + assert.equal(job2.status, JobStatus.DONE); + assert.ok( + new Date(job1.updated_at).getTime() < new Date(job2.updated_at).getTime(), + 'job1 (' + job1.updated_at + ') should finish before job2 (' + job2.updated_at + ')' + ); + done(); + }); + }); + }); + }.bind(this)); + }); + +});