Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atlasexec: fix error field names of applied file model #75

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading