Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
So coveralls can shut up already and green light this PR.
  • Loading branch information
lrascao committed Dec 2, 2020
1 parent 411402a commit d225b66
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
7 changes: 7 additions & 0 deletions src/conf_parse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ included_dir_test() ->
?assertEqual([
{include,<<"conf.d/*.conf">>}

escaped_dots_are_removed_test() ->
Conf = conf_parse:parse("#comment\nsetting\\.0 = thing0\n"),
?assertEqual([
{["setting.0"],"thing0"}
], Conf),
ok.

shell_value_test() ->
Conf = conf_parse:file("test/shell_value.conf"),
?assertEqual([
Expand Down
7 changes: 7 additions & 0 deletions src/conf_parse.peg
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ included_dir_test() ->
], Conf),
ok.

escaped_dots_are_removed_test() ->
Conf = conf_parse:parse("#comment\nsetting\\.0 = thing0\n"),
?assertEqual([
{["setting.0"],"thing0"}
], Conf),
ok.

shell_value_test() ->
Conf = conf_parse:file("test/shell_value.conf"),
?assertEqual([
Expand Down
22 changes: 0 additions & 22 deletions src/cuttlefish_unit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,6 @@ assert_not_configured(Config, Path) ->
assert_error(Config) ->
?assertMatch({error, _, {errorlist, _}}, Config).

%% @doc Asserts that the generated configuration is in error, with the
%% error occurring in a specific phase.
assert_error_in_phase(Config, Phase) when is_atom(Phase) ->
?assertMatch({error, Phase, {errorlist, _}}, Config).

%% @doc Asserts that the generated configuration is in error, and the
%% given error message was emitted by the given phase.
assert_error(Config, Phase, Message) ->
assert_error_in_phase(Config, Phase),
assert_error_message(Config, Message).

%% @doc Asserts that the generated configuration is in error and has
%% the given error messages.
assert_errors(Config, [H|_]=Messages) when is_list(H) ->
[ assert_error_message(Config, Message) || Message <- Messages ].

%% @doc Asserts that the generated configuration is in error, with
%% errors occuring in the given phase and containing the given
%% messages.
assert_errors(Config, Phase, [H|_]=Messages) when is_list(H) ->
assert_error_in_phase(Config, Phase),
[ assert_error_message(Config, Message) || Message <- Messages ].

%% @doc Asserts that the generated configuration is in error and
%% contains an error tuple that translates to the given error message
Expand Down
6 changes: 6 additions & 0 deletions src/cuttlefish_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,10 @@ ceiling_test() ->
?assertEqual(-2, ceiling(-2.9999999)),
ok.

numerify_test() ->
?assertEqual(42, numerify("42")),
?assertEqual(42.0, numerify("42.0")),
?assertEqual(0.5, numerify(".5")),
ok.

-endif.

0 comments on commit d225b66

Please sign in to comment.