@@ -47,29 +47,8 @@ defmodule AshPostgres.MigrationGeneratorTest do
4747describe "creating initial snapshots" do
4848setup do
4949on_exit ( fn ->
50- "test_snapshots_path/**/*.json"
51- |> Path . wildcard ( )
52- |> Enum . each ( & File . rm! / 1 )
53-
54- "test_snapshots_path/*"
55- |> Path . wildcard ( )
56- |> Enum . each ( & File . rmdir! / 1 )
57-
58- "test_migration_path/**/*.exs"
59- |> Path . wildcard ( )
60- |> Enum . each ( & File . rm! / 1 )
61-
62- "test_migration_path/*"
63- |> Path . wildcard ( )
64- |> Enum . each ( & File . rmdir! / 1 )
65-
66- if File . exists? ( "test_snapshots_path" ) do
67- File . rmdir ( "test_snapshots_path" )
68- end
69-
70- if File . exists? ( "test_migration_path" ) do
71- File . rmdir ( "test_migration_path" )
72- end
50+ File . rm_rf! ( "test_snapshots_path" )
51+ File . rm_rf! ( "test_migration_path" )
7352end )
7453
7554defposts do
@@ -113,27 +92,27 @@ defmodule AshPostgres.MigrationGeneratorTest do
11392end
11493
11594test "the migration creates the table" do
116- assert [ file ] = Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" )
95+ assert [ file ] = Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" )
11796
11897assert File . read! ( file ) =~ "create table(:posts, primary_key: false) do"
11998end
12099
121100test "the migration adds the id, with its default" do
122- assert [ file ] = Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" )
101+ assert [ file ] = Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" )
123102
124103assert File . read! ( file ) =~
125104~S[ add :id, :binary_id, null: true, default: fragment("uuid_generate_v4()"), primary_key: true]
126105end
127106
128107test "the migration adds other attributes" do
129- assert [ file ] = Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" )
108+ assert [ file ] = Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" )
130109
131110assert File . read! ( file ) =~
132111~S[ add :title, :text, null: true, default: nil, primary_key: false]
133112end
134113
135114test "the migration creates unique_indexes based on the identities of the resource" do
136- assert [ file ] = Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" )
115+ assert [ file ] = Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" )
137116
138117assert File . read! ( file ) =~
139118~S{ create unique_index(:posts, [:title], name: "posts_title_unique_index")}
@@ -143,29 +122,8 @@ defmodule AshPostgres.MigrationGeneratorTest do
143122describe "creating follow up migrations" do
144123setup do
145124on_exit ( fn ->
146- "test_snapshots_path/**/*.json"
147- |> Path . wildcard ( )
148- |> Enum . each ( & File . rm! / 1 )
149-
150- "test_snapshots_path/*"
151- |> Path . wildcard ( )
152- |> Enum . each ( & File . rmdir! / 1 )
153-
154- "test_migration_path/**/*.exs"
155- |> Path . wildcard ( )
156- |> Enum . each ( & File . rm! / 1 )
157-
158- "test_migration_path/*"
159- |> Path . wildcard ( )
160- |> Enum . each ( & File . rmdir! / 1 )
161-
162- if File . exists? ( "test_snapshots_path" ) do
163- File . rmdir ( "test_snapshots_path" )
164- end
165-
166- if File . exists? ( "test_migration_path" ) do
167- File . rmdir ( "test_migration_path" )
168- end
125+ File . rm_rf! ( "test_snapshots_path" )
126+ File . rm_rf! ( "test_migration_path" )
169127end )
170128
171129defposts do
@@ -220,7 +178,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
220178)
221179
222180assert [ _file1 , file2 ] =
223- Enum . sort ( Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" ) )
181+ Enum . sort ( Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" ) )
224182
225183assert File . read! ( file2 ) =~
226184~S[ add :name, :text, null: false, default: nil, primary_key: false]
@@ -246,7 +204,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
246204)
247205
248206assert [ _file1 , file2 ] =
249- Enum . sort ( Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" ) )
207+ Enum . sort ( Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" ) )
250208
251209assert File . read! ( file2 ) =~ ~S[ rename table(:posts), :title, to: :name]
252210end
@@ -271,7 +229,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
271229)
272230
273231assert [ _file1 , file2 ] =
274- Enum . sort ( Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" ) )
232+ Enum . sort ( Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" ) )
275233
276234assert File . read! ( file2 ) =~
277235~S[ add :name, :text, null: false, default: nil, primary_key: false]
@@ -299,7 +257,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
299257)
300258
301259assert [ _file1 , file2 ] =
302- Enum . sort ( Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" ) )
260+ Enum . sort ( Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" ) )
303261
304262assert File . read! ( file2 ) =~ ~S[ rename table(:posts), :title, to: :subject]
305263end
@@ -325,7 +283,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
325283)
326284
327285assert [ _file1 , file2 ] =
328- Enum . sort ( Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" ) )
286+ Enum . sort ( Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" ) )
329287
330288assert File . read! ( file2 ) =~
331289~S[ add :subject, :text, null: false, default: nil, primary_key: false]
@@ -350,7 +308,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
350308)
351309
352310assert [ _file1 , file2 ] =
353- Enum . sort ( Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" ) )
311+ Enum . sort ( Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" ) )
354312
355313assert File . read! ( file2 ) =~
356314~S[ add :guid, :binary_id, null: true, default: fragment("uuid_generate_v4()"), primary_key: true]
@@ -382,7 +340,7 @@ defmodule AshPostgres.MigrationGeneratorTest do
382340)
383341
384342assert [ _file1 , file2 ] =
385- Enum . sort ( Path . wildcard ( "test_migration_path/*_migrate_resources*.exs" ) )
343+ Enum . sort ( Path . wildcard ( "test_migration_path/**/* _migrate_resources*.exs" ) )
386344
387345assert File . read! ( file2 ) =~
388346~S[ add :foobar, :text, null: true, default: nil, primary_key: false]