@@ -1250,6 +1250,53 @@ defmodule AshPostgres.MigrationGeneratorTest do
12501250 end
12511251 end
12521252
1253+ describe "--dev option" do
1254+ setup do
1255+ on_exit ( fn ->
1256+ File . rm_rf! ( "test_snapshots_path" )
1257+ File . rm_rf! ( "test_migration_path" )
1258+ end )
1259+ end
1260+
1261+ test "generates dev migration" do
1262+ defposts do
1263+ attributes do
1264+ uuid_primary_key ( :id )
1265+ attribute ( :title , :string , public?: true )
1266+ end
1267+ end
1268+
1269+ defdomain ( [ Post ] )
1270+
1271+ AshPostgres.MigrationGenerator . generate ( Domain ,
1272+ snapshot_path: "test_snapshots_path" ,
1273+ snapshots_only: false ,
1274+ migration_path: "test_migration_path" ,
1275+ dev: true
1276+ )
1277+
1278+ assert [ dev_file ] =
1279+ Path . wildcard ( "test_migration_path/**/*_migrate_resources*.exs" )
1280+ |> Enum . reject ( & String . contains? ( & 1 , "extensions" ) )
1281+
1282+ assert String . contains? ( dev_file , "_dev.exs" )
1283+ contents = File . read! ( dev_file )
1284+
1285+ AshPostgres.MigrationGenerator . generate ( Domain ,
1286+ snapshot_path: "test_snapshots_path" ,
1287+ migration_path: "test_migration_path"
1288+ )
1289+
1290+ assert [ file ] =
1291+ Path . wildcard ( "test_migration_path/**/*_migrate_resources*.exs" )
1292+ |> Enum . reject ( & String . contains? ( & 1 , "extensions" ) )
1293+
1294+ refute String . contains? ( file , "_dev.exs" )
1295+
1296+ assert contents == File . read! ( file )
1297+ end
1298+ end
1299+
12531300 describe "references" do
12541301 setup do
12551302 on_exit ( fn ->
0 commit comments