Skip to content

Commit

Permalink
Extend hook tests to cover complete phase hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-farries committed Apr 8, 2024
1 parent 46cc42c commit 000be71
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/roll/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,14 @@ func TestMigrationHooksAreInvoked(t *testing.T) {
_, err := m.PgConn().ExecContext(context.Background(), "CREATE TABLE after_start_ddl (id integer)")
return err
},
BeforeCompleteDDL: func(m *roll.Roll) error {
_, err := m.PgConn().ExecContext(context.Background(), "CREATE TABLE before_complete_ddl (id integer)")
return err
},
AfterCompleteDDL: func(m *roll.Roll) error {
_, err := m.PgConn().ExecContext(context.Background(), "CREATE TABLE after_complete_ddl (id integer)")
return err
},
})}

testutils.WithMigratorInSchemaAndConnectionToContainerWithOptions(t, "public", options, func(mig *roll.Roll, db *sql.DB) {
Expand All @@ -584,6 +592,10 @@ func TestMigrationHooksAreInvoked(t *testing.T) {
// Complete the migration
err = mig.Complete(ctx)
assert.NoError(t, err)

// Ensure that both the before_complete_ddl and after_complete_ddl tables were created
assert.True(t, tableExists(t, db, "public", "before_complete_ddl"))
assert.True(t, tableExists(t, db, "public", "after_complete_ddl"))
})
}

Expand Down

0 comments on commit 000be71

Please sign in to comment.