Replace errors.Cause() with errors.Is()
Dependencies may be switching to use the new `%w` formatting option to wrap errors; switching to use `errors.Is()` makes sure that we are still able to unwrap the error and detect the underlying cause. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -55,7 +55,7 @@ func TestLeases(t *testing.T) {
|
||||
if err := db.Update(func(tx *bolt.Tx) error {
|
||||
lease, err := lm.Create(WithTransactionContext(ctx, tx), leases.WithID(tc.ID))
|
||||
if err != nil {
|
||||
if tc.CreateErr != nil && errors.Cause(err) == tc.CreateErr {
|
||||
if tc.CreateErr != nil && errors.Is(err, tc.CreateErr) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
@@ -88,7 +88,7 @@ func TestLeases(t *testing.T) {
|
||||
if err := lm.Delete(ctx, leases.Lease{
|
||||
ID: tc.ID,
|
||||
}); err != nil {
|
||||
if tc.DeleteErr == nil && errors.Cause(err) != tc.DeleteErr {
|
||||
if tc.DeleteErr == nil && !errors.Is(err, tc.DeleteErr) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ func TestLeaseResource(t *testing.T) {
|
||||
for i, tc := range testCases {
|
||||
if err := db.Update(func(tx *bolt.Tx) error {
|
||||
err0 := lm.AddResource(WithTransactionContext(ctx, tx), tc.lease, tc.resource)
|
||||
if got := errors.Cause(err0); got != tc.err {
|
||||
if !errors.Is(err0, tc.err) {
|
||||
return errors.Errorf("expect error (%v), but got (%v)", tc.err, err0)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user