Skip to content

Commit

Permalink
fix: create special file when running test
Browse files Browse the repository at this point in the history
a\b.conf is not a valid filename for windows
  • Loading branch information
zmstone committed Apr 22, 2022
1 parent 13eedf6 commit b65a17e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
1 change: 0 additions & 1 deletion test/data/a\b.conf

This file was deleted.

27 changes: 17 additions & 10 deletions test/hocon_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -741,16 +741,23 @@ files_test() ->
?assertEqual("b_2.conf", Filename(deep_get("b", Conf, ?METADATA))).

files_esc_test() ->
Filename = fun(Metadata) -> filename:basename(maps:get(filename, Metadata)) end,
{ok, Conf} = hocon:files(
['sample-configs/a_1.conf', <<"sample-configs/b_2.conf">>, "test/data/a\\b.conf"],
#{format => richmap}
),
?assertEqual(1, deep_get("a", Conf, ?HOCON_V)),
?assertEqual("a_1.conf", Filename(deep_get("a", Conf, ?METADATA))),
?assertEqual(2, deep_get("b", Conf, ?HOCON_V)),
?assertEqual("b_2.conf", Filename(deep_get("b", Conf, ?METADATA))),
?assertEqual(<<"gotcha">>, deep_get("backslash", Conf, ?HOCON_V)).
Content = "backslash = gotcha\n",
SpecialFile = "test/data/a\\b.conf",
ok = file:write_file(SpecialFile, Content),
try
Filename = fun(Metadata) -> filename:basename(maps:get(filename, Metadata)) end,
{ok, Conf} = hocon:files(
['sample-configs/a_1.conf', <<"sample-configs/b_2.conf">>, SpecialFile],
#{format => richmap}
),
?assertEqual(1, deep_get("a", Conf, ?HOCON_V)),
?assertEqual("a_1.conf", Filename(deep_get("a", Conf, ?METADATA))),
?assertEqual(2, deep_get("b", Conf, ?HOCON_V)),
?assertEqual("b_2.conf", Filename(deep_get("b", Conf, ?METADATA))),
?assertEqual(<<"gotcha">>, deep_get("backslash", Conf, ?HOCON_V))
after
file:delete(SpecialFile)
end.

files_unicode_path_test() ->
Content =
Expand Down

0 comments on commit b65a17e

Please sign in to comment.