Skip to content

Commit

Permalink
More tests for meta list values
Browse files Browse the repository at this point in the history
  • Loading branch information
seriyps committed Nov 21, 2023
1 parent 2dbb6d1 commit 09a95be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/logger_journald_h.erl
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ ensure_bytes(V) when is_atom(V) ->

non_io_list_to_bytes(V) ->
try
unicode:characters_to_binary(V)
Res = unicode:characters_to_binary(V),
is_binary(Res) orelse error(badarg),
Res
catch
error:badarg ->
iolist_to_binary(io_lib:format("~w", [V]))
Expand Down
10 changes: 8 additions & 2 deletions test/logger_journald_h_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ just_log_case(Cfg) when is_list(Cfg) ->
"my_key2" => "my_value2",
<<"my_key3">> => <<"my_value3">>,
<<"my_key4">> => {192, 168, 0, 1},
["my", $_, <<"key">>, ["5"]] => 42
["my", $_, <<"key">>, ["5"]] => 42,
<<"my_key6">> => [1087,1088,1080,1074,1077,1090],
<<"my_key7">> => [123456, 123456, 12345678901234567890],
<<"my_key8">> => [ok]
}),
?assertMatch(
#{
Expand All @@ -138,7 +141,10 @@ just_log_case(Cfg) when is_list(Cfg) ->
<<"MY_KEY2">> := <<"my_value2">>,
<<"MY_KEY3">> := <<"my_value3">>,
<<"MY_KEY4">> := <<"{192,168,0,1}">>,
<<"MY_KEY5">> := <<"42">>
<<"MY_KEY5">> := <<"42">>,
<<"MY_KEY6">> := <<208,191,209,128,208,184,208,178,208,181,209,130>>,
<<"MY_KEY7">> := <<"[123456,123456,12345678901234567890]">>,
<<"MY_KEY8">> := <<"[ok]">>
},
p_recv(Srv)
),
Expand Down

0 comments on commit 09a95be

Please sign in to comment.