diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 20:37:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 20:37:50 +0000 |
commit | c1f743ab2e4a7046d5500875a47d1f62c8624603 (patch) | |
tree | 709946d52f5f3bbaeb38be9e3f1d56d11f058237 /daemon/lua/log.test.lua | |
parent | Initial commit. (diff) | |
download | knot-resolver-c1f743ab2e4a7046d5500875a47d1f62c8624603.tar.xz knot-resolver-c1f743ab2e4a7046d5500875a47d1f62c8624603.zip |
Adding upstream version 5.7.1.upstream/5.7.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemon/lua/log.test.lua')
-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..ec5abd2 --- /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') + same(log_groups({'nonexistent'}), {}, "nonexistent group is ignored") + boom(log_groups, { 'string' }, "group argument can't be string") + boom(log_groups, { 1, 2 }, "group doesn't take multiple arguments") +end + +return { + test_log_level, + test_log_target, + test_log_groups, +} |