zblueslip: Log output for all function calls.

Also adds asserts on blueslip.log() call in node_tests/people_errors.js.
This commit is contained in:
Rohitt Vashishtha
2018-04-24 03:59:46 +05:30
committed by Tim Abbott
parent 47d53107a1
commit bddb6a1a14
2 changed files with 6 additions and 4 deletions

View File

@@ -26,7 +26,8 @@ people.initialize_current_user(me.user_id);
reload.is_in_progress = true; reload.is_in_progress = true;
people.report_late_add(55, 'foo@example.com'); people.report_late_add(55, 'foo@example.com');
// TODO: Make zblueslip support logging things written to .log and assert result assert.equal(blueslip.get_test_logs('log').length, 1);
assert.equal(blueslip.get_test_logs('log')[0], 'Added user late: user_id=55 email=foo@example.com');
assert.equal(blueslip.get_test_logs('error').length, 0); assert.equal(blueslip.get_test_logs('error').length, 0);
blueslip.clear_test_data(); blueslip.clear_test_data();
}()); }());

View File

@@ -1,5 +1,3 @@
var noop = function () {};
var exports = {}; var exports = {};
exports.make_zblueslip = function (opts) { exports.make_zblueslip = function (opts) {
@@ -61,7 +59,10 @@ exports.make_zblueslip = function (opts) {
// Create logging functions // Create logging functions
Object.keys(opts).forEach(name => { Object.keys(opts).forEach(name => {
if (!opts[name]) { if (!opts[name]) {
lib[name] = noop; // should just log the message.
lib[name] = function (message) {
lib.test_logs[name].push(message);
};
return; return;
} }
lib[name] = function (message) { lib[name] = function (message) {