Files
docker-cli/internal/containerizedengine/containerd_test.go
Sebastiaan van Stijn 4fe6b837b7 bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 2c0e93063b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:43:18 +02:00

46 lines
1.1 KiB
Go

package containerizedengine
import (
"bytes"
"context"
"fmt"
"testing"
"github.com/containerd/containerd"
"github.com/docker/cli/cli/streams"
"github.com/docker/docker/api/types"
"gotest.tools/v3/assert"
)
func TestPullWithAuthPullFail(t *testing.T) {
ctx := context.Background()
client := baseClient{
cclient: &fakeContainerdClient{
pullFunc: func(ctx context.Context, ref string, opts ...containerd.RemoteOpt) (containerd.Image, error) {
return nil, fmt.Errorf("pull failure")
},
},
}
imageName := "testnamegoeshere"
_, err := client.pullWithAuth(ctx, imageName, streams.NewOut(&bytes.Buffer{}), &types.AuthConfig{})
assert.ErrorContains(t, err, "pull failure")
}
func TestPullWithAuthPullPass(t *testing.T) {
ctx := context.Background()
client := baseClient{
cclient: &fakeContainerdClient{
pullFunc: func(ctx context.Context, ref string, opts ...containerd.RemoteOpt) (containerd.Image, error) {
return nil, nil
},
},
}
imageName := "testnamegoeshere"
_, err := client.pullWithAuth(ctx, imageName, streams.NewOut(&bytes.Buffer{}), &types.AuthConfig{})
assert.NilError(t, err)
}