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

feat: Add Unwrap to PartialError #815

Merged
merged 1 commit into from
Aug 26, 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
4 changes: 4 additions & 0 deletions provider_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ func (e *PartialError) Error() string {
e.Failed.Source.Type, e.Failed.Source.Version, e.Err,
)
}

func (e *PartialError) Unwrap() error {
return e.Err
}
8 changes: 7 additions & 1 deletion provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func TestProvider(t *testing.T) {
check.Equal(t, len(sources), 2)
check.Equal(t, sources[0], newSource(goose.TypeSQL, "001_foo.sql", 1))
check.Equal(t, sources[1], newSource(goose.TypeSQL, "002_bar.sql", 2))

}

var (
Expand Down Expand Up @@ -76,3 +75,10 @@ ALTER TABLE my_foo DROP COLUMN timestamp;
ALTER TABLE my_foo RENAME TO foo;
`
)

func TestPartialErrorUnwrap(t *testing.T) {
err := &goose.PartialError{Err: goose.ErrNoCurrentVersion}

got := errors.Is(err, goose.ErrNoCurrentVersion)
check.Bool(t, got, true)
}