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:
@@ -125,8 +125,8 @@ func testFMountatWithFileFd(t *testing.T, root string) {
|
||||
defer f.Close()
|
||||
|
||||
err = FMountat(f.Fd(), filepath.Join(root, "empty"), filepath.Join(root, "work"), "", 0, "")
|
||||
if got := errors.Cause(err); got != expectedErr {
|
||||
t.Fatalf("expected error %v, but got %v", expectedErr, got)
|
||||
if !errors.Is(err, expectedErr) {
|
||||
t.Fatalf("expected error %v, but got %v", expectedErr, errors.Cause(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,8 +146,8 @@ func testFMountatWithInvalidSource(t *testing.T, root string) {
|
||||
defer f.Close()
|
||||
|
||||
err = FMountat(f.Fd(), filepath.Join(root, "oops"), "at", "bind", unix.MS_BIND, "")
|
||||
if got := errors.Cause(err); got != expectedErr {
|
||||
t.Fatalf("expected error %v, but got %v", expectedErr, got)
|
||||
if !errors.Is(err, expectedErr) {
|
||||
t.Fatalf("expected error %v, but got %v", expectedErr, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user