Skip to content

Commit

Permalink
Fix test counting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Oct 30, 2016
1 parent f259c11 commit 1f369a7
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions lib/tapex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ defmodule Tapex do
increment_test_count(config)
|> increment_type_counter(test)
|> increment_state_counter(test)
|> increment_tag_counter(test)
end

defp increment_type_counter(%{type_counter: counter}=config, %{tags: %{type: type}}) do
Expand All @@ -69,20 +70,27 @@ defmodule Tapex do
config
end

defp increment_state_counter(%{state_counter: counter}=config, %{state: state, tags: tags}) do
counter = Map.update(counter, state || :passed, 1, &(&1 + 1))
counter =
case Map.get(tags, :todo) do
nil -> counter
_ -> Map.update(counter, :todo, 1, &(&1 + 1))
end
%{config | type_counter: counter}
defp increment_state_counter(%{state_counter: counter}=config, %{state: {state, _}}) do
%{config | state_counter: Map.update(counter, state, 1, &(&1 + 1))}
end
defp increment_state_counter(%{state_counter: counter}=config, %{state: nil}) do
%{config | state_counter: Map.update(counter, :passed, 1, &(&1 + 1))}
end

defp increment_state_counter(%{}=config, %{}) do
config
end

defp increment_tag_counter(%{tag_counter: counter}=config, %{tags: %{todo: todo}}) do
case todo do
false -> config
nil -> config
_ -> %{config | tag_counter: Map.update(counter, :todo, 1, &(&1 + 1))}
end
end
defp increment_tag_counter(%{}=config, %{}) do
config
end

defp increment_test_count(%{test_count: count}=config) do
%{config | test_count: count + 1}
end
Expand Down

0 comments on commit 1f369a7

Please sign in to comment.