There were a handful of direct checks against errors.Is that can be
translated to assert.ErrorIs without too much thought. Unfortunately
there are a load of other examples where ErrorIs probably makes sense
but would require testing whether this subtly breaks the test.
These transformations were done by hand.
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
| ... | ... |
@@ -567,7 +567,7 @@ func TestGetBoolOrDefault(t *testing.T) {
|
| 567 | 567 |
assert.Check(t, is.DeepEqual(expected.Value, actual.Value)) |
| 568 | 568 |
|
| 569 | 569 |
wrappedErr := fmt.Errorf("something went wrong: %w", err)
|
| 570 |
- assert.Check(t, errors.Is(wrappedErr, err), "Expected a wrapped error to be detected as invalidFilter") |
|
| 570 |
+ assert.Check(t, is.ErrorIs(wrappedErr, err), "Expected a wrapped error to be detected as invalidFilter") |
|
| 571 | 571 |
} |
| 572 | 572 |
|
| 573 | 573 |
assert.Check(t, is.Equal(tc.expectedValue, value)) |
| ... | ... |
@@ -3,7 +3,6 @@ package client // import "github.com/docker/docker/client" |
| 3 | 3 |
import ( |
| 4 | 4 |
"bytes" |
| 5 | 5 |
"context" |
| 6 |
- "errors" |
|
| 7 | 6 |
"fmt" |
| 8 | 7 |
"io" |
| 9 | 8 |
"math/rand" |
| ... | ... |
@@ -125,7 +124,7 @@ func TestCanceledContext(t *testing.T) {
|
| 125 | 125 |
|
| 126 | 126 |
_, err := client.sendRequest(ctx, http.MethodGet, testEndpoint, nil, nil, nil) |
| 127 | 127 |
assert.Check(t, is.ErrorType(err, errdefs.IsCancelled)) |
| 128 |
- assert.Check(t, errors.Is(err, context.Canceled)) |
|
| 128 |
+ assert.Check(t, is.ErrorIs(err, context.Canceled)) |
|
| 129 | 129 |
} |
| 130 | 130 |
|
| 131 | 131 |
func TestDeadlineExceededContext(t *testing.T) {
|
| ... | ... |
@@ -145,5 +144,5 @@ func TestDeadlineExceededContext(t *testing.T) {
|
| 145 | 145 |
|
| 146 | 146 |
_, err := client.sendRequest(ctx, http.MethodGet, testEndpoint, nil, nil, nil) |
| 147 | 147 |
assert.Check(t, is.ErrorType(err, errdefs.IsDeadline)) |
| 148 |
- assert.Check(t, errors.Is(err, context.DeadlineExceeded)) |
|
| 148 |
+ assert.Check(t, is.ErrorIs(err, context.DeadlineExceeded)) |
|
| 149 | 149 |
} |
| ... | ... |
@@ -6,7 +6,6 @@ import ( |
| 6 | 6 |
"testing" |
| 7 | 7 |
|
| 8 | 8 |
"github.com/docker/docker/daemon/logger" |
| 9 |
- "github.com/pkg/errors" |
|
| 10 | 9 |
"gotest.tools/v3/assert" |
| 11 | 10 |
) |
| 12 | 11 |
|
| ... | ... |
@@ -36,7 +35,7 @@ func testDecode(t *testing.T, buf []byte, split int) {
|
| 36 | 36 |
assert.NilError(t, err) |
| 37 | 37 |
|
| 38 | 38 |
_, err = d.Decode() |
| 39 |
- assert.Assert(t, errors.Is(err, io.EOF)) |
|
| 39 |
+ assert.ErrorIs(t, err, io.EOF) |
|
| 40 | 40 |
|
| 41 | 41 |
_, err = fw.Write(buf[split:]) |
| 42 | 42 |
assert.NilError(t, err) |
| ... | ... |
@@ -181,7 +181,7 @@ func TestSharedTempFileConverter(t *testing.T) {
|
| 181 | 181 |
defer t.Logf("goroutine %v: exit", i)
|
| 182 | 182 |
start.Done() |
| 183 | 183 |
_, err := uut.Do(src) |
| 184 |
- assert.Check(t, errors.Is(err, fakeErr), "in goroutine %v", i) |
|
| 184 |
+ assert.Check(t, is.ErrorIs(err, fakeErr), "in goroutine %v", i) |
|
| 185 | 185 |
}() |
| 186 | 186 |
} |
| 187 | 187 |
done.Wait() |
| ... | ... |
@@ -190,7 +190,7 @@ func TestSharedTempFileConverter(t *testing.T) {
|
| 190 | 190 |
// request should retry from scratch. |
| 191 | 191 |
fakeErr = errors.New("another fake error")
|
| 192 | 192 |
_, err = uut.Do(src) |
| 193 |
- assert.Check(t, errors.Is(err, fakeErr)) |
|
| 193 |
+ assert.Check(t, is.ErrorIs(err, fakeErr)) |
|
| 194 | 194 |
|
| 195 | 195 |
fakeErr = nil |
| 196 | 196 |
f, err := uut.Do(src) |
| ... | ... |
@@ -4,7 +4,6 @@ import ( |
| 4 | 4 |
"archive/tar" |
| 5 | 5 |
"bytes" |
| 6 | 6 |
"compress/gzip" |
| 7 |
- "errors" |
|
| 8 | 7 |
"fmt" |
| 9 | 8 |
"io" |
| 10 | 9 |
"io/fs" |
| ... | ... |
@@ -1255,7 +1254,7 @@ func TestXGlobalNoParent(t *testing.T) {
|
| 1255 | 1255 |
|
| 1256 | 1256 |
_, err = os.Lstat(filepath.Join(tmpDir, "foo")) |
| 1257 | 1257 |
assert.Check(t, err != nil) |
| 1258 |
- assert.Check(t, errors.Is(err, os.ErrNotExist)) |
|
| 1258 |
+ assert.Check(t, is.ErrorIs(err, os.ErrNotExist)) |
|
| 1259 | 1259 |
} |
| 1260 | 1260 |
|
| 1261 | 1261 |
// TestImpliedDirectoryPermissions ensures that directories implied by paths in the tar file, but without their own |