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 // an error occurred when generating a new Document
logger.info(`[controller:coarse_reverse][error]`); logger.info(`[controller:coarse_reverse][error]`);
logger.error(e); logger.error(e);
logger.error(results); logger.info(results);
return null; 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) => { test('service returns 0 length name', (t) => {
t.plan(5); t.plan(6);
const service = (req, callback) => { const service = (req, callback) => {
t.deepEquals(req, { clean: { layers: ['neighbourhood'] } } ); t.deepEquals(req, { clean: { layers: ['neighbourhood'] } } );
@ -902,15 +902,12 @@ module.exports.tests.failure_conditions = (test, common) => {
}; };
t.deepEquals(res, expected); t.deepEquals(res, expected);
t.deepEquals(logger.getMessages('info'), [
'[controller:coarse_reverse][queryType:pip][result_count:1]', // logger messages
'[controller:coarse_reverse][error]' t.true(logger.hasMessages('info'), '[controller:coarse_reverse][error]');
]); t.true(logger.hasMessages('error'), 'invalid document type, expecting: truthy, got: ');
t.deepEquals(logger.getMessages('error'), [ t.true(logger.hasMessages('info'), '{ neighbourhood: [ { id: 20, name: \'\' } ] }');
'{ [PeliasModelError: invalid document type, expecting: truthy, ' +
'got: ]\n name: \'PeliasModelError\',\n message: \'invalid document type, expecting: truthy, got: \' }',
'{ neighbourhood: [ { id: 20, name: \'\' } ] }'
]);
t.end(); t.end();
}); });

Loading…
Cancel
Save