mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-19 13:03:14 +12:00
chore: Cleanup Test Output (#366)
This commit is contained in:
parent
bc0cb6babd
commit
2d1c7d48ce
3 changed files with 52 additions and 47 deletions
|
@ -379,7 +379,7 @@ defmodule AshPostgres.MigrationGenerator do
|
|||
|
||||
operations ->
|
||||
if opts.check do
|
||||
IO.puts("""
|
||||
Mix.shell().error("""
|
||||
Migrations would have been generated, but the --check flag was provided.
|
||||
|
||||
To see what migration would have been generated, run with the `--dry-run`
|
||||
|
@ -1028,7 +1028,7 @@ defmodule AshPostgres.MigrationGenerator do
|
|||
end
|
||||
rescue
|
||||
exception ->
|
||||
IO.puts("""
|
||||
Mix.shell().error("""
|
||||
Exception while formatting:
|
||||
|
||||
#{inspect(exception)}
|
||||
|
|
|
@ -4,7 +4,17 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
|
||||
import ExUnit.CaptureLog
|
||||
|
||||
defmacrop defposts(mod \\ Post, do: body) do
|
||||
setup do
|
||||
current_shell = Mix.shell()
|
||||
|
||||
:ok = Mix.shell(Mix.Shell.Process)
|
||||
|
||||
on_exit(fn ->
|
||||
Mix.shell(current_shell)
|
||||
end)
|
||||
end
|
||||
|
||||
defmacrop defresource(mod, do: body) do
|
||||
quote do
|
||||
Code.compiler_options(ignore_module_conflict: true)
|
||||
|
||||
|
@ -13,6 +23,16 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
domain: nil,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
unquote(body)
|
||||
end
|
||||
|
||||
Code.compiler_options(ignore_module_conflict: false)
|
||||
end
|
||||
end
|
||||
|
||||
defmacrop defposts(mod \\ Post, do: body) do
|
||||
quote do
|
||||
defresource unquote(mod) do
|
||||
postgres do
|
||||
table "posts"
|
||||
repo(AshPostgres.TestRepo)
|
||||
|
@ -30,8 +50,23 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
|
||||
unquote(body)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Code.compiler_options(ignore_module_conflict: false)
|
||||
defmacrop defcomments(mod \\ Comment, do: body) do
|
||||
quote do
|
||||
defresource unquote(mod) do
|
||||
postgres do
|
||||
table "comments"
|
||||
repo(AshPostgres.TestRepo)
|
||||
end
|
||||
|
||||
actions do
|
||||
defaults([:create, :read, :update, :destroy])
|
||||
end
|
||||
|
||||
unquote(body)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -108,8 +143,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
|
||||
defdomain([Post])
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
AshPostgres.MigrationGenerator.generate(Domain,
|
||||
snapshot_path: "test_snapshots_path",
|
||||
migration_path: "test_migration_path",
|
||||
|
@ -208,8 +241,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
|
||||
defdomain([Post])
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
{:ok, _} =
|
||||
Ecto.Adapters.SQL.query(
|
||||
AshPostgres.TestRepo,
|
||||
|
@ -291,7 +322,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
end
|
||||
|
||||
defdomain([Post])
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
AshPostgres.MigrationGenerator.generate(Domain,
|
||||
snapshot_path: "test_snapshots_path",
|
||||
|
@ -336,7 +366,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
end
|
||||
|
||||
defdomain([Post])
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
AshPostgres.MigrationGenerator.generate(Domain,
|
||||
snapshot_path: "test_snapshots_path",
|
||||
|
@ -378,8 +407,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
|
||||
defdomain([Post])
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
AshPostgres.MigrationGenerator.generate(Domain,
|
||||
snapshot_path: "test_snapshots_path",
|
||||
migration_path: "test_migration_path",
|
||||
|
@ -470,8 +497,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
|
||||
defdomain([Post])
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
AshPostgres.MigrationGenerator.generate(Domain,
|
||||
snapshot_path: "test_snapshots_path",
|
||||
migration_path: "test_migration_path",
|
||||
|
@ -833,8 +858,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
|
||||
defdomain([Post])
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
AshPostgres.MigrationGenerator.generate(Domain,
|
||||
snapshot_path: "test_snapshots_path",
|
||||
migration_path: "test_migration_path",
|
||||
|
@ -1635,11 +1658,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
File.rm_rf!("test_migration_path")
|
||||
end)
|
||||
|
||||
defmodule Comment do
|
||||
use Ash.Resource,
|
||||
domain: nil,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
defcomments do
|
||||
postgres do
|
||||
polymorphic?(true)
|
||||
repo(AshPostgres.TestRepo)
|
||||
|
@ -1832,16 +1851,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
end
|
||||
end
|
||||
|
||||
defmodule Comment do
|
||||
use Ash.Resource,
|
||||
domain: nil,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
postgres do
|
||||
table "comments"
|
||||
repo AshPostgres.TestRepo
|
||||
end
|
||||
|
||||
defcomments do
|
||||
attributes do
|
||||
uuid_primary_key(:id)
|
||||
end
|
||||
|
@ -1855,8 +1865,6 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
|
||||
defdomain([Post, Comment])
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
AshPostgres.MigrationGenerator.generate(Domain,
|
||||
snapshot_path: "test_snapshots_path",
|
||||
migration_path: "test_migration_path",
|
||||
|
@ -1881,16 +1889,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
|
|||
end
|
||||
end
|
||||
|
||||
defmodule Comment do
|
||||
use Ash.Resource,
|
||||
domain: nil,
|
||||
data_layer: AshPostgres.DataLayer
|
||||
|
||||
postgres do
|
||||
table "comments"
|
||||
repo AshPostgres.TestRepo
|
||||
end
|
||||
|
||||
defcomments do
|
||||
attributes do
|
||||
uuid_primary_key(:id)
|
||||
end
|
||||
|
|
|
@ -2,6 +2,16 @@ defmodule AshPostgres.MixSquashSnapshotsTest do
|
|||
use AshPostgres.RepoCase, async: false
|
||||
@moduletag :migration
|
||||
|
||||
setup do
|
||||
current_shell = Mix.shell()
|
||||
|
||||
:ok = Mix.shell(Mix.Shell.Process)
|
||||
|
||||
on_exit(fn ->
|
||||
Mix.shell(current_shell)
|
||||
end)
|
||||
end
|
||||
|
||||
defmacrop defposts(mod \\ Post, do: body) do
|
||||
quote do
|
||||
Code.compiler_options(ignore_module_conflict: true)
|
||||
|
@ -67,8 +77,6 @@ defmodule AshPostgres.MixSquashSnapshotsTest do
|
|||
File.rm_rf!("test_migration_path")
|
||||
end)
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
defposts do
|
||||
identities do
|
||||
identity(:title, [:title])
|
||||
|
@ -154,8 +162,6 @@ defmodule AshPostgres.MixSquashSnapshotsTest do
|
|||
File.rm_rf!("test_migration_path")
|
||||
end)
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
defposts do
|
||||
identities do
|
||||
identity(:title, [:title])
|
||||
|
|
Loading…
Reference in a new issue