Browse Source

feat(coarse_reverse): improve logger assertions

pull/1003/head
missinglink 7 years ago
parent
commit
45f313d8d9
  1. 2
      controller/coarse_reverse.js
  2. 17
      test/unit/controller/coarse_reverse.js

2
controller/coarse_reverse.js

@ -102,7 +102,7 @@ function synthesizeDoc(results) {
// an error occurred when generating a new Document
logger.info(`[controller:coarse_reverse][error]`);
logger.error(e);
logger.error(results);
logger.info(results);
return null;
}

17
test/unit/controller/coarse_reverse.js

@ -861,7 +861,7 @@ module.exports.tests.failure_conditions = (test, common) => {
});
test('service returns 0 length name', (t) => {
t.plan(5);
t.plan(6);
const service = (req, callback) => {
t.deepEquals(req, { clean: { layers: ['neighbourhood'] } } );
@ -902,15 +902,12 @@ module.exports.tests.failure_conditions = (test, common) => {
};
t.deepEquals(res, expected);
t.deepEquals(logger.getMessages('info'), [
'[controller:coarse_reverse][queryType:pip][result_count:1]',
'[controller:coarse_reverse][error]'
]);
t.deepEquals(logger.getMessages('error'), [
'{ [PeliasModelError: invalid document type, expecting: truthy, ' +
'got: ]\n name: \'PeliasModelError\',\n message: \'invalid document type, expecting: truthy, got: \' }',
'{ neighbourhood: [ { id: 20, name: \'\' } ] }'
]);
// logger messages
t.true(logger.hasMessages('info'), '[controller:coarse_reverse][error]');
t.true(logger.hasMessages('error'), 'invalid document type, expecting: truthy, got: ');
t.true(logger.hasMessages('info'), '{ neighbourhood: [ { id: 20, name: \'\' } ] }');
t.end();
});

Loading…
Cancel
Save