50 lines
1.6 KiB
Elixir
50 lines
1.6 KiB
Elixir
defmodule Firehose.MutationConfigTest do
|
|
# Same wiring pins as blogex, plus the app-specific one: because the app
|
|
# scope is deliberately empty (Q45), the aliases must fail loudly. A sensor
|
|
# that reports a score for a run that tested nothing is worse than no sensor.
|
|
use ExUnit.Case
|
|
|
|
test "muex is a dev/test-only, non-runtime dependency" do
|
|
deps = Mix.Project.config()[:deps]
|
|
|
|
assert {:muex, requirement, opts} = dep!(deps, :muex)
|
|
assert requirement =~ "0.12"
|
|
assert opts[:only] == [:dev, :test]
|
|
assert opts[:runtime] == false
|
|
end
|
|
|
|
test "mutate and mutate.fast aliases are defined" do
|
|
aliases = Mix.Project.config()[:aliases]
|
|
|
|
assert is_function(aliases[:mutate], 1)
|
|
assert is_function(aliases[:"mutate.fast"], 1)
|
|
end
|
|
|
|
test "an empty app scope fails loudly instead of running over nothing" do
|
|
assert_raise Mix.Error, ~r/empty/, fn ->
|
|
Firehose.MixProject.mutation_args("mutation_scope.txt", [])
|
|
end
|
|
end
|
|
|
|
test "ad-hoc args do not bypass the empty-scope failure" do
|
|
assert_raise Mix.Error, ~r/empty/, fn ->
|
|
Firehose.MixProject.mutation_args("mutation_scope.txt", [
|
|
"--files",
|
|
"lib/firehose/accounts/user.ex"
|
|
])
|
|
end
|
|
end
|
|
|
|
defp dep!(deps, name) do
|
|
case Enum.find(deps, fn
|
|
{^name, _requirement} -> true
|
|
{^name, _requirement, _opts} -> true
|
|
_ -> false
|
|
end) do
|
|
{^name, requirement} -> {name, requirement, []}
|
|
{^name, requirement, opts} -> {name, requirement, opts}
|
|
nil -> flunk("expected #{inspect(name)} in deps/0")
|
|
end
|
|
end
|
|
end
|