Fail on turbo-carto invalid quantification methods
This commit is contained in:
parent
caec04f63b
commit
424cc6d93b
6
NEWS.md
6
NEWS.md
@ -4,7 +4,11 @@
|
||||
|
||||
Released 2016-mm-dd
|
||||
|
||||
Adds support for sql wrap in all layers
|
||||
New features:
|
||||
- Adds support for sql wrap in all layers
|
||||
|
||||
Bug fixes:
|
||||
- Fail on turbo-carto invalid quantification methods
|
||||
|
||||
|
||||
## 2.43.1
|
||||
|
@ -38,7 +38,12 @@ PostgresDatasource.prototype.getName = function () {
|
||||
};
|
||||
|
||||
PostgresDatasource.prototype.getRamp = function (column, buckets, method, callback) {
|
||||
var methodName = methods.hasOwnProperty(method) ? method : 'quantiles';
|
||||
if (method && !methodTemplates.hasOwnProperty(method)) {
|
||||
return callback(new Error(
|
||||
'Invalid method "' + method + '", valid methods: [' + Object.keys(methodTemplates).join(',') + ']'
|
||||
));
|
||||
}
|
||||
var methodName = method || 'quantiles';
|
||||
var template = methodTemplates[methodName];
|
||||
|
||||
var query = template({ _column: column, _sql: this.query, _buckets: buckets });
|
||||
|
@ -53,6 +53,20 @@ describe('turbo-carto for anonymous maps', function() {
|
||||
var fixturePath = 'test_turbo_carto_greens_13_4011_3088.png';
|
||||
this.testClient.getTile(13, 4011, 3088, imageCompareFn(fixturePath, done));
|
||||
});
|
||||
|
||||
it('should work for different char case in quantification names', function(done) {
|
||||
this.testClient = new TestClient(
|
||||
makeMapconfig('#layer { marker-fill: ramp([price], colorbrewer(Greens, 3), jeNkS); }')
|
||||
);
|
||||
this.testClient.getLayergroup(function(err, layergroup) {
|
||||
assert.ok(!err, err);
|
||||
|
||||
assert.ok(layergroup.hasOwnProperty('layergroupid'));
|
||||
assert.ok(!layergroup.hasOwnProperty('errors'));
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('parsing ramp function with colorbrewer for reds and mapnik renderer', function () {
|
||||
|
@ -78,6 +78,21 @@ describe('turbo-carto error cases', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return invalid method from datasource', function(done) {
|
||||
this.testClient = new TestClient(makeMapconfig(null, 'ramp([wadus_column], (red, green, blue), wadusmethod)'));
|
||||
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
|
||||
assert.ok(!err, err);
|
||||
|
||||
assert.ok(layergroup.hasOwnProperty('errors'));
|
||||
assert.equal(layergroup.errors.length, 1);
|
||||
assert.ok(layergroup.errors[0].match(/^turbo-carto/));
|
||||
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
|
||||
assert.ok(layergroup.errors[0].match(/invalid\smethod\s\"wadusmethod\"/i));
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should fail by falling back to normal carto parser', function(done) {
|
||||
this.testClient = new TestClient(makeMapconfig('ramp([price], (8,24,96), (8,24,96));//(red, green, blue))'));
|
||||
this.testClient.getLayergroup(ERROR_RESPONSE, function(err, layergroup) {
|
||||
|
Loading…
Reference in New Issue
Block a user