Skip to content

Commit 8da0173

Browse files
committed
test_console_adapter: fix test failures caused by console gem update
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent f36b379 commit 8da0173

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

test/log/test_console_adapter.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ def setup
1313
@logger = ServerEngine::DaemonLogger.new(@logdev)
1414
@fluent_log = Fluent::Log.new(@logger)
1515
@console_logger = Fluent::Log::ConsoleAdapter.wrap(@fluent_log)
16+
17+
# The log format was modified in https://github.com/socketry/console/commit/14cf37da3f5d3a95ba2766a6dbd4dbce87a4588c
18+
@duration_str = if Gem::Version.new(Console::VERSION) >= Gem::Version.new("1.35.0")
19+
" 0.00s"
20+
else
21+
" 0.0s"
22+
end
1623
end
1724

1825
def teardown
@@ -45,7 +52,7 @@ def test_reflect_log_level(data)
4552
fatal: :fatal)
4653
def test_string_subject(level)
4754
@console_logger.send(level, "subject")
48-
assert_equal(["#{@timestamp_str} [#{level}]: 0.0s: subject\n"],
55+
assert_equal(["#{@timestamp_str} [#{level}]: #{@duration_str}: subject\n"],
4956
@logdev.logs)
5057
end
5158

@@ -57,7 +64,7 @@ def test_string_subject(level)
5764
def test_args(level)
5865
@console_logger.send(level, "subject", 1, 2, 3)
5966
assert_equal([
60-
"#{@timestamp_str} [#{level}]: 0.0s: subject\n" +
67+
"#{@timestamp_str} [#{level}]: #{@duration_str}: subject\n" +
6168
" | 1\n" +
6269
" | 2\n" +
6370
" | 3\n"
@@ -76,7 +83,7 @@ def test_options(level)
7683
args = JSON.parse(lines[1..].collect { |str| str.sub(/\s+\|/, "") }.join("\n"))
7784
assert_equal([
7885
1,
79-
"#{@timestamp_str} [#{level}]: 0.0s: subject",
86+
"#{@timestamp_str} [#{level}]: #{@duration_str}: subject",
8087
{ "kwarg1" => "opt1", "kwarg2" => "opt2" }
8188
],
8289
[
@@ -94,7 +101,7 @@ def test_options(level)
94101
def test_block(level)
95102
@console_logger.send(level, "subject") { "block message" }
96103
assert_equal([
97-
"#{@timestamp_str} [#{level}]: 0.0s: subject\n" +
104+
"#{@timestamp_str} [#{level}]: #{@duration_str}: subject\n" +
98105
" | block message\n"
99106
],
100107
@logdev.logs)
@@ -109,8 +116,8 @@ def test_multiple_entries(level)
109116
@console_logger.send(level, "subject1")
110117
@console_logger.send(level, "line2")
111118
assert_equal([
112-
"#{@timestamp_str} [#{level}]: 0.0s: subject1\n",
113-
"#{@timestamp_str} [#{level}]: 0.0s: line2\n"
119+
"#{@timestamp_str} [#{level}]: #{@duration_str}: subject1\n",
120+
"#{@timestamp_str} [#{level}]: #{@duration_str}: line2\n"
114121
],
115122
@logdev.logs)
116123
end

0 commit comments

Comments
 (0)