From a132609ccc3e8198e4cb43b39b87f06f6e8ad8e4 Mon Sep 17 00:00:00 2001 From: Chris Bailey Date: Thu, 16 Mar 2023 11:56:47 +0000 Subject: [PATCH] Pass tests --- test/excoveralls_test.exs | 1 + test/html_test.exs | 33 --------------------------------- test/local_test.exs | 26 -------------------------- test/mix/tasks_test.exs | 12 ++++++------ 4 files changed, 7 insertions(+), 65 deletions(-) diff --git a/test/excoveralls_test.exs b/test/excoveralls_test.exs index 15fe86d6..0d5857e4 100644 --- a/test/excoveralls_test.exs +++ b/test/excoveralls_test.exs @@ -59,4 +59,5 @@ defmodule ExCoverallsTest do ExCoveralls.analyze(@stats, "Undefined Type", []) end end + end diff --git a/test/html_test.exs b/test/html_test.exs index 571ad244..b69552a5 100644 --- a/test/html_test.exs +++ b/test/html_test.exs @@ -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 diff --git a/test/local_test.exs b/test/local_test.exs index 8d13f637..29f7e7e1 100644 --- a/test/local_test.exs +++ b/test/local_test.exs @@ -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, diff --git a/test/mix/tasks_test.exs b/test/mix/tasks_test.exs index 4dd5d721..e020e678 100644 --- a/test/mix/tasks_test.exs +++ b/test/mix/tasks_test.exs @@ -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 @@ -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 @@ -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