From 3913c836e2bbc0144910513b6a2aee9e0a505a57 Mon Sep 17 00:00:00 2001 From: missinglink Date: Mon, 25 Sep 2017 18:05:25 +0200 Subject: [PATCH] feat(coarse_reverse): improve logger assertions --- controller/coarse_reverse.js | 2 +- test/unit/controller/coarse_reverse.js | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/controller/coarse_reverse.js b/controller/coarse_reverse.js index 1ed47c58..cae79a78 100644 --- a/controller/coarse_reverse.js +++ b/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; } diff --git a/test/unit/controller/coarse_reverse.js b/test/unit/controller/coarse_reverse.js index cc7c5443..d4e357cb 100644 --- a/test/unit/controller/coarse_reverse.js +++ b/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(); });