Skip to content

Commit

Permalink
atlasexec: fix error field names of applied file model (#75)
Browse files Browse the repository at this point in the history
* atlasexec: add dirName, url and drvier to migrate apply output

* atlasexec: fix field names of applied file error
  • Loading branch information
ronenlu authored Jun 19, 2024
1 parent 0e0db50 commit a9fdd42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions atlasexec/atlas_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type (
Applied []string // SQL statements applied with success
Checks []*FileChecks // Assertion checks
Error *struct {
SQL string // SQL statement that failed.
Error string // Error returned by the database.
Stmt string // SQL statement that failed.
Text string // Error returned by the database.
}
}
// RevertedFile is part of a MigrateDown containing information about a reverted file in a downgrade attempt.
Expand All @@ -38,8 +38,8 @@ type (
Applied []string // SQL statements applied with success
Scope string // Scope of the revert. e.g., statement, versions, etc.
Error *struct {
SQL string // SQL statement that failed.
Error string // Error returned by the database.
Stmt string // SQL statement that failed.
Text string // Error returned by the database.
}
}
// MigrateApply contains a summary of a migration applying attempt on a database.
Expand Down
8 changes: 8 additions & 0 deletions atlasexec/atlas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ func TestBrokenApply(t *testing.T) {
report, ok := err.(*atlasexec.MigrateApplyError)
require.True(t, ok)
require.Equal(t, "20231029112426", report.Result[0].Target)
require.Equal(t, "sql/migrate: executing statement \"broken;\" from version \"20231029112426\": near \"broken\": syntax error", report.Error())
require.Len(t, report.Result[0].Applied, 1)
require.Equal(t, &struct {
Stmt, Text string
}{
Stmt: "broken;",
Text: "near \"broken\": syntax error",
}, report.Result[0].Applied[0].Error)
}

func TestMigrateLint(t *testing.T) {
Expand Down

0 comments on commit a9fdd42

Please sign in to comment.