From 1d4990ce373bd145344c4f5749229c06104cb4bb Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Mon, 2 Jan 2023 14:52:59 +0900 Subject: [PATCH] test_console_adapter: Add more tests Signed-off-by: Takuro Ashie --- test/log/test_console_adapter.rb | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/test/log/test_console_adapter.rb b/test/log/test_console_adapter.rb index c689821b50..7199fea57c 100644 --- a/test/log/test_console_adapter.rb +++ b/test/log/test_console_adapter.rb @@ -30,12 +30,42 @@ def test_expected_log_levels warn: :warn, error: :error, fatal: :fatal) - def test_one_message(level) + def test_string_subject(level) @console_logger.send(level, "subject") assert_equal(["#{@timestamp_str} [#{level}]: 0.0s: subject\n"], @logdev.logs) end + data(debug: :debug, + info: :info, + warn: :warn, + error: :error, + fatal: :fatal) + def test_args(level) + @console_logger.send(level, "subject", 1, 2, 3) + assert_equal([ + "#{@timestamp_str} [#{level}]: 0.0s: subject\n" + + " | 1\n" + + " | 2\n" + + " | 3\n" + ], + @logdev.logs) + end + + data(debug: :debug, + info: :info, + warn: :warn, + error: :error, + fatal: :fatal) + def test_options(level) + @console_logger.send(level, "subject", kwarg1: "opt1", kwarg2: "opt2") + assert_equal([ + "#{@timestamp_str} [#{level}]: 0.0s: subject\n" + + " | {\"kwarg1\":\"opt1\",\"kwarg2\":\"opt2\"}\n" + ], + @logdev.logs) + end + data(debug: :debug, info: :info, warn: :warn,