50 lines
1.4 KiB
Elixir
50 lines
1.4 KiB
Elixir
defmodule Mix.Tasks.Compile.UnusedTest do
|
|
use ExUnit.Case, async: false
|
|
|
|
alias Mix.Tasks.Compile.Unused
|
|
|
|
describe "manifests/0" do
|
|
test "returns an empty list (no manifest tracking)" do
|
|
assert Unused.manifests() == []
|
|
end
|
|
end
|
|
|
|
describe "clean/0" do
|
|
test "returns :ok" do
|
|
assert Unused.clean() == :ok
|
|
end
|
|
end
|
|
|
|
describe "run/1" do
|
|
test "manifests/0 and clean/0 are idempotent" do
|
|
assert Unused.manifests() == Unused.manifests()
|
|
assert Unused.clean() == :ok
|
|
assert Unused.clean() == :ok
|
|
end
|
|
|
|
@tag :slow
|
|
test "runs against the project and returns either :ok or :error tuple" do
|
|
ExUnit.CaptureIO.capture_io(fn ->
|
|
result = Unused.run([])
|
|
assert match?({:ok, _}, result) or match?({:error, _}, result)
|
|
end)
|
|
end
|
|
|
|
test "honors --severity option override" do
|
|
ExUnit.CaptureIO.capture_io(fn ->
|
|
result = Unused.run(["--severity", "error"])
|
|
assert match?({:ok, _}, result) or match?({:error, _}, result)
|
|
end)
|
|
end
|
|
|
|
@tag :slow
|
|
test "accepts --severity warning, info, and unknown values" do
|
|
for severity <- ["warning", "info", "garbage"] do
|
|
ExUnit.CaptureIO.capture_io(fn ->
|
|
result = Unused.run(["--severity", severity])
|
|
assert match?({:ok, _}, result) or match?({:error, _}, result)
|
|
end)
|
|
end
|
|
end
|
|
end
|
|
end
|