mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
tests: migrate simple cases to assert.ErrorIs
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>
This commit is contained in:
@@ -3,7 +3,6 @@ package client // import "github.com/docker/docker/client"
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
@@ -125,7 +124,7 @@ func TestCanceledContext(t *testing.T) {
|
||||
|
||||
_, err := client.sendRequest(ctx, http.MethodGet, testEndpoint, nil, nil, nil)
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsCancelled))
|
||||
assert.Check(t, errors.Is(err, context.Canceled))
|
||||
assert.Check(t, is.ErrorIs(err, context.Canceled))
|
||||
}
|
||||
|
||||
func TestDeadlineExceededContext(t *testing.T) {
|
||||
@@ -145,5 +144,5 @@ func TestDeadlineExceededContext(t *testing.T) {
|
||||
|
||||
_, err := client.sendRequest(ctx, http.MethodGet, testEndpoint, nil, nil, nil)
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsDeadline))
|
||||
assert.Check(t, errors.Is(err, context.DeadlineExceeded))
|
||||
assert.Check(t, is.ErrorIs(err, context.DeadlineExceeded))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user