Skip to content

Commit

Permalink
Pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vereis committed Mar 16, 2023
1 parent 4ed4bcc commit a132609
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 65 deletions.
1 change: 1 addition & 0 deletions test/excoveralls_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ defmodule ExCoverallsTest do
ExCoveralls.analyze(@stats, "Undefined Type", [])
end
end

end
33 changes: 0 additions & 33 deletions test/html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,4 @@ defmodule ExCoveralls.HtmlTest do
assert(size == @file_size)
end

test_with_mock "Exit status code is 1 when actual coverage does not reach the minimum",
ExCoveralls.Settings, [
get_coverage_options: fn -> coverage_options(100) end,
get_file_col_width: fn -> 40 end,
get_print_summary: fn -> true end,
get_print_files: fn -> true end
] do
output = capture_io(fn ->
assert catch_exit(Html.execute(@source_info)) == {:shutdown, 1}
end)
assert String.contains?(output, "FAILED: Expected minimum coverage of 100%, got 50%.")
end

test_with_mock "Exit status code is 0 when actual coverage reaches the minimum",
ExCoveralls.Settings, [
get_coverage_options: fn -> coverage_options(49.9) end,
get_file_col_width: fn -> 40 end,
get_print_summary: fn -> true end,
get_print_files: fn -> true end
] do
assert capture_io(fn ->
Html.execute(@source_info)
end) =~ @stats_result
end

defp coverage_options(minimum_coverage) do
%{
"minimum_coverage" => minimum_coverage,
"output_dir" => @test_output_dir,
"template_path" => @test_template_path
}
end

end
26 changes: 0 additions & 26 deletions test/local_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -96,32 +96,6 @@ defmodule ExCoveralls.LocalTest do
assert String.contains?(Local.coverage(@empty_source_info), "[TOTAL] 0.0%")
end

test_with_mock "Exit status code is 1 when actual coverage does not reach the minimum",

ExCoveralls.Settings, [
get_coverage_options: fn -> %{"minimum_coverage" => 100} end,
get_file_col_width: fn -> 40 end,
get_print_summary: fn -> true end,
get_print_files: fn -> true end
] do
output = capture_io(fn ->
assert catch_exit(Local.execute(@source_info)) == {:shutdown, 1}
end)
assert String.contains?(output, "FAILED: Expected minimum coverage of 100%, got 50%.")
end

test_with_mock "Exit status code is 0 when actual coverage reaches the minimum",
ExCoveralls.Settings, [
get_coverage_options: fn -> %{"minimum_coverage" => 49.9} end,
get_file_col_width: fn -> 40 end,
get_print_summary: fn -> true end,
get_print_files: fn -> true end
] do
assert capture_io(fn ->
Local.execute(@source_info)
end) =~ @stats_result
end

test_with_mock "No output if print_summary is false",
ExCoveralls.Settings, [
get_coverage_options: fn -> %{"minimum_coverage" => 49.9} end,
Expand Down
12 changes: 6 additions & 6 deletions test/mix/tasks_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Mix.Tasks.CoverallsTest do
test_with_mock "local", Runner, [run: fn(_, _) -> nil end] do
Mix.Tasks.Coveralls.run([])
assert(called Runner.run("test", ["--cover"]))
assert(ExCoveralls.ConfServer.get == [type: "local", args: []])
assert(ExCoveralls.ConfServer.get == [enforce_minimum_coverage: true, type: "local", args: []])
end

test "local with help option" do
Expand All @@ -43,7 +43,7 @@ defmodule Mix.Tasks.CoverallsTest do
Mix.Tasks.Coveralls.run(["--umbrella"])
assert(called Runner.run("test", ["--cover"]))
assert(ExCoveralls.ConfServer.get ==
[type: "local", umbrella: true, sub_apps: [], apps_path: nil, args: []])
[enforce_minimum_coverage: true, type: "local", umbrella: true, sub_apps: [], apps_path: nil, args: []])
end)
end

Expand Down Expand Up @@ -72,25 +72,25 @@ defmodule Mix.Tasks.CoverallsTest do
test_with_mock "detail", Runner, [run: fn(_, _) -> nil end] do
Mix.Tasks.Coveralls.Detail.run([])
assert(called Runner.run("test", ["--cover"]))
assert(ExCoveralls.ConfServer.get == [type: "local", detail: true, args: []])
assert(ExCoveralls.ConfServer.get == [enforce_minimum_coverage: true, type: "local", detail: true, args: []])
end

test_with_mock "detail and filter", Runner, [run: fn(_, _) -> nil end] do
Mix.Tasks.Coveralls.Detail.run(["--filter", "x"])
assert(called Runner.run("test", ["--cover"]))
assert(ExCoveralls.ConfServer.get == [type: "local", detail: true, filter: "x", args: []])
assert(ExCoveralls.ConfServer.get == [enforce_minimum_coverage: true, type: "local", detail: true, filter: "x", args: []])
end

test_with_mock "html", Runner, [run: fn(_, _) -> nil end] do
Mix.Tasks.Coveralls.Html.run([])
assert(called Runner.run("test", ["--cover"]))
assert(ExCoveralls.ConfServer.get == [type: "html", args: []])
assert(ExCoveralls.ConfServer.get == [enforce_minimum_coverage: true, type: "html", args: []])
end

test_with_mock "cobertura", Runner, [run: fn(_, _) -> nil end] do
Mix.Tasks.Coveralls.Cobertura.run([])
assert(called Runner.run("test", ["--cover"]))
assert(ExCoveralls.ConfServer.get == [type: "cobertura", args: []])
assert(ExCoveralls.ConfServer.get == [enforce_minimum_coverage: true, type: "cobertura", args: []])
end

test_with_mock "multiple", Runner, [run: fn(_, _) -> nil end] do
Expand Down

0 comments on commit a132609

Please sign in to comment.