From ed837fbf227e9b2bdce2d2dbced02e24c0c59254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Thu, 10 May 2018 17:25:02 +0200 Subject: [PATCH] improving tests raising the pg_typeof error --- test/acceptance/dataviews/error-cases.js | 42 +++++++++++++++++------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/test/acceptance/dataviews/error-cases.js b/test/acceptance/dataviews/error-cases.js index 933211b4..eb85dab8 100644 --- a/test/acceptance/dataviews/error-cases.js +++ b/test/acceptance/dataviews/error-cases.js @@ -146,10 +146,7 @@ describe('dataview error cases', function() { it('should work without filters', function(done) { this.testClient = new TestClient(createMapConfig()); this.testClient.getDataview('aggregation_count_dataview', { own_filter: 0 }, function(err, result) { - if (err) { - return done(err); - } - + assert.ifError(err); done(); }); }); @@ -163,22 +160,43 @@ describe('dataview error cases', function() { this.testClient = new TestClient(createMapConfig()); this.testClient.getDataview('aggregation_count_dataview', params, function(err, result) { - if (err) { - return done(err); - } - + assert.ifError(err); done(); }); }); + it('should return an error if the column used by dataview does not exist', function(done) { + const query = 'select cartodb_id, the_geom, the_geom_webmercator from populated_places_simple_reduced'; + + const expectedResponse = { + status: 404, + headers: { + 'Content-Type': 'application/json; charset=utf-8' + } + }; + + const expectedResponseBody = { + errors:['column "adm0name" does not exist'], + errors_with_context:[{ + type:'unknown', + message:'column "adm0name" does not exist' + }] + }; + + this.testClient = new TestClient(createMapConfig(query)); + this.testClient.getDataview('aggregation_count_dataview', { response: expectedResponse }, function(err, result) { + assert.ifError(err); + assert.deepEqual(result, expectedResponseBody); + done(); + }); + }); + it('should return an error if query row equals to 0', function(done) { const query = 'select * from populated_places_simple_reduced limit 0'; + this.testClient = new TestClient(createMapConfig(query)); this.testClient.getDataview('aggregation_count_dataview', { own_filter: 0 }, function(err, result) { - if (err) { - return done(err); - } - + assert.ifError(err); done(); }); });