Skip to content

Commit

Permalink
test: Use error.Is(errorType, errorInstance) to check for error equal…
Browse files Browse the repository at this point in the history
…ity (#666)

Checking error with == operator might fail on wrapped errors
  • Loading branch information
himanshu-patel-dev authored Oct 5, 2023
1 parent a52d8bf commit c129115
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion graph/bellmanford_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestBellmanford(t *testing.T) {
if resIsReachable != test.isReachable {
t.Errorf("Reachable, Expected: %t, Computed: %t", test.isReachable, resIsReachable)
}
if resError != test.err {
if !errors.Is(test.err, resError) {
if resError == nil || test.err == nil {
t.Errorf("Reachable, Expected: %s, Computed: %s", test.err, resError)
} else if resError.Error() != test.err.Error() {
Expand Down

0 comments on commit c129115

Please sign in to comment.