Skip to content

Commit

Permalink
Add insurance test for all available extension template files
Browse files Browse the repository at this point in the history
  • Loading branch information
danschultzer committed Mar 12, 2019
1 parent 4f50182 commit febb385
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,27 @@ defmodule Mix.Tasks.Pow.Extension.Phoenix.Gen.TemplatesTest do
end

defp ls(path), do: path |> File.ls!() |> Enum.sort()

# This is for insurance that all available templates are being tested
test "test all templates" do
expected = Enum.into(@expected_template_files, %{})
all_templates =
"lib/extensions"
|> File.ls!()
|> Enum.filter(&File.dir?("lib/extensions/#{&1}/phoenix/views"))
|> Enum.map(fn dir ->
extension = Module.concat(["Pow#{Macro.camelize(dir)}"])
templates =
"lib/extensions/#{dir}/phoenix/views"
|> File.ls!()
|> Enum.map(&String.replace(&1, "_view.ex", ""))

{extension, templates}
end)

for {extension, templates} <- all_templates do
assert Map.has_key?(expected, extension), "Missing template tests for #{inspect(extension)} extension"
assert Map.keys(expected[extension]) == templates, "Not all templates are tested for the #{inspect(extension)} extension"
end
end
end

0 comments on commit febb385

Please sign in to comment.