Skip to content

Commit

Permalink
feat: Add Unwrap to PartialError (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
rollulus authored Aug 26, 2024
1 parent c1ac45a commit 0ad04fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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)
}

0 comments on commit 0ad04fe

Please sign in to comment.