diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:26:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 15:26:00 +0000 |
commit | 830407e88f9d40d954356c3754f2647f91d5c06a (patch) | |
tree | d6a0ece6feea91f3c656166dbaa884ef8a29740e /daemon/lua/log.test.lua | |
parent | Initial commit. (diff) | |
download | knot-resolver-830407e88f9d40d954356c3754f2647f91d5c06a.tar.xz knot-resolver-830407e88f9d40d954356c3754f2647f91d5c06a.zip |
Adding upstream version 5.6.0.upstream/5.6.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | daemon/lua/log.test.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/daemon/lua/log.test.lua b/daemon/lua/log.test.lua new file mode 100644 index 0000000..197aa74 --- /dev/null +++ b/daemon/lua/log.test.lua @@ -0,0 +1,42 @@ +local function test_log_level() + same(log_level(), 'notice', 'default level is notice') + same(verbose(), false, 'verbose is not set by default') + same(log_level('crit'), 'crit', '"crit" level can be set') + same(log_level('err'), 'err', '"err" level can be set') + same(log_level('warning'), 'warning', '"warning" level can be set') + same(log_level('notice'), 'notice', '"notice" level can be set') + same(log_level('info'), 'info', '"info" level can be set') + same(log_level('debug'), 'debug', '"debug" level can be set') + same(verbose(), true, 'verbose is active when debug level is set') + same(verbose(false), false, 'verbose can be used to turn off debug level') + same(log_level(), 'notice', 'verbose returns log level to notice') + boom(log_level, { 'xxx' }, "unknown level can't be used") + boom(log_level, { 7 }, "numbered levels aren't supported") + boom(log_level, { 1, 2 }, "level doesn't take multiple arguments") +end + +local function test_log_target() + same(log_target(), 'stderr', 'default target is stderr') + same(log_target('stdout'), 'stdout', 'stdout target can be set') + same(log_target('syslog'), 'syslog', 'syslog target can be set') + same(log_target('stderr'), 'stderr', 'stderr target can be set') + boom(log_level, { 'xxx' }, "unknown target can't be used") + boom(log_level, { 'stderr', 'syslog' }, "target doesn't take multiple arguments") +end + +local function test_log_groups() + same(log_groups(), {}, 'no groups are logged by default') + same(log_groups({'system'}), {'system'}, 'configure "system" group') + same(log_groups({'devel'}), {'devel'}, 'another call overrides previously set groups') + same(log_groups({'devel', 'system'}), {'system', 'devel'}, 'configure multiple groups') + same(log_groups({}), {}, 'clear groups with empty table') + boom(log_groups, { 'string' }, "group argument can't be string") + boom(log_groups, { {'nonexistent'} }, "nonexistent group can't be added") + boom(log_groups, { 1, 2 }, "group doesn't take multiple arguments") +end + +return { + test_log_level, + test_log_target, + test_log_groups, +} |