Skip to content

Commit

Permalink
Fix Card test in generated project (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoefmoraes authored Jan 5, 2024
1 parent 2452d4b commit 81a9c57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion priv/templates/surface.init/demo/card_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ defmodule <%= inspect(web_module) %>.Components.CardTest do
use <%= inspect(web_module) %>.ConnCase, async: true
use Surface.LiveViewTest

catalogue_test <%= inspect(web_module) %>.Card
catalogue_test <%= inspect(web_module) %>.Components.Card
end
16 changes: 12 additions & 4 deletions test/mix/tasks/surface/surface.init/integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Mix.Tasks.Surface.Init.IntegrationTest do

output =
cmd(
"mix surface.init --catalogue --demo --layouts --yes --no-install --dry-run --web-module SurfaceInitTestWeb",
"mix surface.init --catalogue --demo --layouts --yes --no-install --web-module SurfaceInitTestWeb",
opts
)

Expand Down Expand Up @@ -56,6 +56,9 @@ defmodule Mix.Tasks.Surface.Init.IntegrationTest do
Finished running 31 patches for 21 files.
31 changes applied, 0 skipped.
"""

compile(project_folder, warnings_as_errors: true)
cmd("mix test --warnings-as-errors", opts)
end

test "surfice.init on an already patched project applies no changes", %{project_folder_patched: project_folder} do
Expand Down Expand Up @@ -151,7 +154,7 @@ defmodule Mix.Tasks.Surface.Init.IntegrationTest do
cmd("mix phx.gen.release --docker", cd: project_folder)
end

compile_output = cmd("mix compile", cd: project_folder)
compile_output = cmd("mix compile --warnings-as-errors", cd: project_folder)
compiled? = String.contains?(compile_output, "Compiling")

status =
Expand Down Expand Up @@ -193,10 +196,15 @@ defmodule Mix.Tasks.Surface.Init.IntegrationTest do
end
end

defp compile(project_folder) do
defp compile(project_folder, opts \\ []) do
Mix.shell().info([:green, "* compiling ", :reset, project_folder])
cmd("mix deps.get", cd: project_folder)
cmd("mix compile", cd: project_folder)

if opts[:warnings_as_errors] do
cmd("mix compile --warnings-as-errors", cd: project_folder)
else
cmd("mix compile", cd: project_folder)
end
end

defp restore(project_folder) do
Expand Down

0 comments on commit 81a9c57

Please sign in to comment.