Browse Source

added warning if boundary.circle.radius is defined

pull/904/head
Stephen Hess 8 years ago
parent
commit
2ba23cbb62
  1. 5
      controller/coarse_reverse.js
  2. 74
      test/unit/controller/coarse_reverse.js

5
controller/coarse_reverse.js

@ -103,6 +103,11 @@ function setup(service, should_execute) {
return next(); return next();
} }
// return a warning to the caller that boundary.circle.radius will be ignored
if (!_.isUndefined(req.clean['boundary.circle.radius'])) {
req.warnings.push('boundary.circle.radius is not applicable for coarse reverse');
}
// because coarse reverse is called when non-coarse reverse didn't return // because coarse reverse is called when non-coarse reverse didn't return
// anything, treat requested layers as if it didn't contain non-coarse layers // anything, treat requested layers as if it didn't contain non-coarse layers
const effective_layers = getEffectiveLayers(req.clean.layers); const effective_layers = getEffectiveLayers(req.clean.layers);

74
test/unit/controller/coarse_reverse.js

@ -80,6 +80,80 @@ module.exports.tests.error_conditions = (test, common) => {
}; };
module.exports.tests.boundary_circle_radius_warnings = (test, common) => {
test('defined clean[boundary.circle.radius] should add a warning', (t) => {
const service = (req, callback) => {
callback(undefined, {});
};
const logger = require('pelias-mock-logger')();
const controller = proxyquire('../../../controller/coarse_reverse', {
'pelias-logger': logger
})(service, _.constant(true));
const req = {
warnings: [],
clean: {
'boundary.circle.radius': 17
}
};
const res = { };
const next = () => {};
controller(req, res, next);
const expected = {
meta: {},
data: []
};
t.deepEquals(req.warnings, ['boundary.circle.radius is not applicable for coarse reverse']);
t.deepEquals(res, expected);
t.notOk(logger.hasErrorMessages());
t.end();
});
test('defined clean[boundary.circle.radius] should add a warning', (t) => {
const service = (req, callback) => {
callback(undefined, {});
};
const logger = require('pelias-mock-logger')();
const controller = proxyquire('../../../controller/coarse_reverse', {
'pelias-logger': logger
})(service, _.constant(true));
const req = {
warnings: [],
clean: {}
};
const res = { };
// verify that next was called
const next = () => { };
controller(req, res, next);
const expected = {
meta: {},
data: []
};
t.deepEquals(req.warnings, []);
t.deepEquals(res, expected);
t.notOk(logger.hasErrorMessages());
t.end();
});
};
module.exports.tests.success_conditions = (test, common) => { module.exports.tests.success_conditions = (test, common) => {
test('service returning results should use first entry for each layer', (t) => { test('service returning results should use first entry for each layer', (t) => {
t.plan(4); t.plan(4);

Loading…
Cancel
Save