Skip to content

Commit

Permalink
fix(error): Incorrect IsErrorNotFound behaviour
Browse files Browse the repository at this point in the history
Return value instead of pointer in `NewErrorNotFound` that caused
`IsErrorNotFound` to return false when expecting true.

Signed-off-by: Maximilian Blatt <[email protected]>
  • Loading branch information
MisterMX committed Feb 14, 2024
1 parent c50d6f1 commit b57d73c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion error.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type errNotFound struct {
}

func NewErrorNotFound(name string) error {
return &errNotFound{name: name}
return errNotFound{name: name}
}

func (e errNotFound) Error() string {
Expand Down
10 changes: 9 additions & 1 deletion error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ func TestIsErrorNotFound(t *testing.T) {
}{
"ExpectTrue": {
args: args{
err: errNotFound{},
err: NewErrorNotFound("not-found"),
},
want: want{
isNotFound: true,
},
},
"ExpectWrappedTrue": {
args: args{
err: errors.Wrap(NewErrorNotFound("not-found"), "wrap"),
},
want: want{
isNotFound: true,
Expand Down

0 comments on commit b57d73c

Please sign in to comment.