From 9cf68f2f163a5b7812ccbbc79858718efb21b972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Thu, 28 Feb 2019 16:02:34 +0100 Subject: [PATCH] Batch API Queries with fallbacks tests --- test/acceptance/log.js | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/test/acceptance/log.js b/test/acceptance/log.js index 3681d771..a5c016b2 100644 --- a/test/acceptance/log.js +++ b/test/acceptance/log.js @@ -97,7 +97,7 @@ describe('Log middleware', function() { }); it('one query', function (done) { - var payload = { query: QUERY }; + const payload = { query: QUERY }; this.batchTestClient.createJob(payload, function(err, jobResult, res) { assert.ok(!err); @@ -117,7 +117,7 @@ describe('Log middleware', function() { }); it('multiquery job with two queries', function (done) { - var payload = { query: [QUERY, QUERY] }; + const payload = { query: [QUERY, QUERY] }; this.batchTestClient.createJob(payload, function(err, jobResult, res) { assert.ok(!err); @@ -135,6 +135,36 @@ describe('Log middleware', function() { return done(); }); }); + + it('queries with fallbacks', function (done) { + const FALLBACK_QUERY = { + query: [{ + query: QUERY, + onsuccess: QUERY, + onerror: QUERY + }], + onsuccess: QUERY, + onerror: QUERY + }; + const payload = { query: FALLBACK_QUERY }; + + this.batchTestClient.createJob(payload, function(err, jobResult, res) { + assert.ok(!err); + + assert.ok(res.headers['x-sqlapi-log']); + const log = JSON.parse(res.headers['x-sqlapi-log']); + assert.deepEqual(log, { + request: { + sql: { + type: TYPES.JOB, + sql: FALLBACK_QUERY + } + } + }); + + return done(); + }); + }); }); describe('disable queries log', function() { @@ -206,7 +236,7 @@ describe('Log middleware', function() { assert.deepEqual(log, { request: { sql: { - type: TYPES.QUERY.substring(0, global.settings.maxQueriesLogLength), + type: TYPES.QUERY, sql: QUERY.substring(0, global.settings.maxQueriesLogLength) } }