From 3e261fb3539c59c70b7fc79b2bdc9e96ed0f0863 Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Tue, 23 Oct 2018 15:49:34 +0200 Subject: [PATCH] Going red: fails with 400 due to "Cannot read property 'geom_type' of undefined" --- .../stats/mapnik_stats_layergroup.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/acceptance/stats/mapnik_stats_layergroup.js b/test/acceptance/stats/mapnik_stats_layergroup.js index dd58fd85..2f4e0289 100644 --- a/test/acceptance/stats/mapnik_stats_layergroup.js +++ b/test/acceptance/stats/mapnik_stats_layergroup.js @@ -519,6 +519,31 @@ describe('Create mapnik layergroup', function() { }); }); + it(`should not fail "TypeError: ... 'geom_type' of undefined" for empty results`, function(done) { + var testClient = new TestClient({ + version: '1.8.0', + layers: [ + { + type: 'mapnik', + options: { + sql: 'select * from test_table where false', + metadata: { + geometryType: true + } + } + } + ] + }); + + testClient.getLayergroup(function(err, layergroup) { + assert.ifError(err); + assert.equal(layergroup.metadata.layers[0].id, mapnikBasicLayerId(0)); + assert.equal(layergroup.metadata.layers[0].meta.stats.estimatedFeatureCount, 0); + assert.equal(layergroup.metadata.layers[0].meta.stats.geometryType, undefined); + testClient.drain(done); + }); + }); + it('should provide a sample as optional metadata', function(done) { var testClient = new TestClient({ version: '1.4.0',