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:
Aleksa Sarai
2024-11-22 12:20:52 +11:00
parent caae3c051d
commit 557e4ed83b
5 changed files with 7 additions and 10 deletions

View File

@@ -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))
}