Skip to content

Commit

Permalink
Format generators related files to eliminate future changes interfere…
Browse files Browse the repository at this point in the history
…nce.
  • Loading branch information
ShPakvel committed Dec 7, 2024
1 parent 5e62a39 commit 3f720b9
Show file tree
Hide file tree
Showing 16 changed files with 748 additions and 554 deletions.
30 changes: 24 additions & 6 deletions integration_test/test/code_generation/app_with_defaults_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog")

mix_run!(~w(phx.gen.html Blog Post posts title:unique body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.html Blog Post posts title:unique body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -50,7 +53,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog")

mix_run!(~w(phx.gen.html Blog Post posts title:unique body:string status:enum:unpublished:published:deleted order:integer:unique), app_root_path)
mix_run!(
~w(phx.gen.html Blog Post posts title:unique body:string status:enum:unpublished:published:deleted order:integer:unique),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -74,7 +80,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog")

mix_run!(~w(phx.gen.json Blog Post posts title:unique body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.json Blog Post posts title:unique body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -97,7 +106,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog")

mix_run!(~w(phx.gen.json Blog Post posts title:unique body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.json Blog Post posts title:unique body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -121,7 +133,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--live"])

mix_run!(~w(phx.gen.live Blog Post posts title:unique body:string p:boolean s:enum:a:b:c), app_root_path)
mix_run!(
~w(phx.gen.live Blog Post posts title:unique body:string p:boolean s:enum:a:b:c),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -147,7 +162,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--live"])

mix_run!(~w(phx.gen.live Blog Post posts title body:string public:boolean status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.live Blog Post posts title body:string public:boolean status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mssql_app", ["--database", "mssql"])

mix_run!(~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_mssql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -34,7 +37,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mssql_app", ["--database", "mssql"])

mix_run!(~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_mssql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -60,7 +66,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mssql_app", ["--database", "mssql", "--live"])

mix_run!(~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_mssql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -85,7 +94,8 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
describe "phx.gen.auth + pbkdf2 + existing context" do
test "has no compilation or formatter warnings (--live)" do
with_installer_tmp("new with defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])

mix_run!(~w(phx.gen.html Accounts Group groups name), app_root_path)

Expand All @@ -100,7 +110,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
""")
end)

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --live), app_root_path)
mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --live),
app_root_path
)

assert_no_compilation_warnings(app_root_path)
assert_passes_formatter_check(app_root_path)
Expand All @@ -109,7 +122,8 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do

test "has no compilation or formatter warnings (--no-live)" do
with_installer_tmp("new with defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])

mix_run!(~w(phx.gen.html Accounts Group groups name), app_root_path)

Expand All @@ -124,7 +138,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
""")
end)

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --no-live), app_root_path)
mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --no-live),
app_root_path
)

assert_no_compilation_warnings(app_root_path)
assert_passes_formatter_check(app_root_path)
Expand All @@ -134,7 +151,8 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
@tag database: :mssql
test "has a passing test suite" do
with_installer_tmp("app_with_defaults (--live)", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])

mix_run!(~w(phx.gen.html Accounts Group groups name), app_root_path)

Expand All @@ -149,7 +167,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
""")
end)

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --live), app_root_path)
mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --live),
app_root_path
)

drop_test_database(app_root_path)
assert_tests_pass(app_root_path)
Expand All @@ -159,7 +180,8 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
@tag database: :mssql
test "has a passing test suite (--no-live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])

mix_run!(~w(phx.gen.html Accounts Group groups name), app_root_path)

Expand All @@ -174,7 +196,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
""")
end)

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --no-live), app_root_path)
mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --no-live),
app_root_path
)

drop_test_database(app_root_path)
assert_tests_pass(app_root_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mysql_app", ["--database", "mysql"])

mix_run!(~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_mysql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -34,7 +37,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mysql_app", ["--database", "mysql"])

mix_run!(~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_mysql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -60,7 +66,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mysql_app", ["--database", "mysql", "--live"])

mix_run!(~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_mysql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -85,7 +94,8 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
describe "phx.gen.auth + argon2" do
test "has no compilation or formatter warnings (--live)" do
with_installer_tmp("new with defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mysql", "--binary-id"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mysql", "--binary-id"])

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib argon2 --live), app_root_path)

Expand All @@ -96,9 +106,13 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do

test "has no compilation or formatter warnings (--no-live)" do
with_installer_tmp("new with defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mysql", "--binary-id"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mysql", "--binary-id"])

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib argon2 --no-live), app_root_path)
mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib argon2 --no-live),
app_root_path
)

assert_no_compilation_warnings(app_root_path)
assert_passes_formatter_check(app_root_path)
Expand All @@ -108,7 +122,8 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
@tag database: :mysql
test "has a passing test suite (--live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "default_app", ["--database", "mysql", "--binary-id"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_app", ["--database", "mysql", "--binary-id"])

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib argon2 --live), app_root_path)

Expand All @@ -120,9 +135,13 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
@tag database: :mysql
test "has a passing test suite (--no-live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "default_app", ["--database", "mysql", "--binary-id"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_app", ["--database", "mysql", "--binary-id"])

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib argon2 --no-live), app_root_path)
mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib argon2 --no-live),
app_root_path
)

drop_test_database(app_root_path)
assert_tests_pass(app_root_path)
Expand Down
15 changes: 12 additions & 3 deletions integration_test/test/code_generation/app_with_no_options_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithNoOptionsTest do

assert_no_compilation_warnings(app_root_path)

File.touch!(Path.join(app_root_path, "lib/phx_blog_web/components/core_components.ex"), @epoch)
File.touch!(
Path.join(app_root_path, "lib/phx_blog_web/components/core_components.ex"),
@epoch
)

File.touch!(Path.join(app_root_path, "lib/phx_blog_web/controllers/page_html.ex"), @epoch)

spawn_link(fn ->
Expand All @@ -46,8 +50,13 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithNoOptionsTest do
assert response.status_code == 200
assert response.body =~ "PhxBlog"

assert File.stat!(Path.join(app_root_path, "lib/phx_blog_web/components/core_components.ex")) > @epoch
assert File.stat!(Path.join(app_root_path, "lib/phx_blog_web/controllers/page_html.ex")) > @epoch
assert File.stat!(
Path.join(app_root_path, "lib/phx_blog_web/components/core_components.ex")
) > @epoch

assert File.stat!(Path.join(app_root_path, "lib/phx_blog_web/controllers/page_html.ex")) >
@epoch

assert_tests_pass(app_root_path)
end)
end
Expand Down
21 changes: 16 additions & 5 deletions integration_test/test/code_generation/app_with_sqlite3_adapter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithSQLite3AdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_sqlite3_app", ["--database", "sqlite3"])

mix_run!(~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_sqlite3_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -34,7 +37,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithSQLite3AdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_sqlite3_app", ["--database", "sqlite3"])

mix_run!(~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_sqlite3_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -60,7 +66,10 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithSQLite3AdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_sqlite3_app", ["--database", "sqlite3", "--live"])

mix_run!(~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)
mix_run!(
~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)

modify_file(Path.join(app_root_path, "lib/default_sqlite3_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand Down Expand Up @@ -108,7 +117,8 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithSQLite3AdapterTest do
@tag database: :sqlite3
test "has a passing test suite (--live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "default_app", ["--database", "sqlite3"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_app", ["--database", "sqlite3"])

mix_run!(~w(phx.gen.auth Accounts User users --live), app_root_path)

Expand All @@ -119,7 +129,8 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithSQLite3AdapterTest do

test "has a passing test suite (--no-live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "default_app", ["--database", "sqlite3"])
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_app", ["--database", "sqlite3"])

mix_run!(~w(phx.gen.auth Accounts User users --no-live), app_root_path)

Expand Down
Loading

0 comments on commit 3f720b9

Please sign in to comment.