Browse Source

Merge pull request #909 from pelias/placeholder_settings

allow timeout and retries settings for placeholder microservice
pull/914/head
Diana Shkolnikov 8 years ago committed by GitHub
parent
commit
3271979d60
  1. 4
      schema.js
  2. 23
      test/unit/schema.js

4
schema.js

@ -35,7 +35,9 @@ module.exports = Joi.object().keys({
retries: Joi.number().integer().optional().default(3).min(0), retries: Joi.number().integer().optional().default(3).min(0),
}).unknown(false).requiredKeys('url'), }).unknown(false).requiredKeys('url'),
placeholder: Joi.object().keys({ placeholder: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }) url: Joi.string().uri({ scheme: /https?/ }),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
}).unknown(false).requiredKeys('url') }).unknown(false).requiredKeys('url')
}).unknown(false).default({}) // default api.services to an empty object }).unknown(false).default({}) // default api.services to an empty object

23
test/unit/schema.js

@ -484,6 +484,29 @@ module.exports.tests.api_services_validation = (test, common) => {
}; };
module.exports.tests.placeholder_service_validation = (test, common) => { module.exports.tests.placeholder_service_validation = (test, common) => {
test('timeout and retries not specified should default to 250 and 3', (t) => {
const config = {
api: {
version: 'version value',
indexName: 'index name value',
host: 'host value',
services: {
placeholder: {
url: 'http://localhost'
}
}
},
esclient: {}
};
const result = Joi.validate(config, schema);
t.equals(result.value.api.services.placeholder.timeout, 250);
t.equals(result.value.api.services.placeholder.retries, 3);
t.end();
});
test('when api.services.placeholder is defined, url is required', (t) => { test('when api.services.placeholder is defined, url is required', (t) => {
var config = { var config = {
api: { api: {

Loading…
Cancel
Save