Skip to content

Commit

Permalink
Merge pull request #1504 from simonferquel/bump-moby-fix-tests
Browse files Browse the repository at this point in the history
Bump moby/moby vendoring and fix tests
  • Loading branch information
silvin-lubecki authored Nov 8, 2018
2 parents 6b71e84 + 8efa6a9 commit 3a6f8b6
Show file tree
Hide file tree
Showing 21 changed files with 248 additions and 65 deletions.
10 changes: 6 additions & 4 deletions cli/command/engine/activate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package engine

import (
"fmt"
"os"
"testing"

"github.com/docker/cli/internal/test"
Expand Down Expand Up @@ -34,18 +35,19 @@ func TestActivateNoContainerd(t *testing.T) {
}

func TestActivateBadLicense(t *testing.T) {
testCli.SetContainerizedEngineClient(
isRoot = func() bool { return true }
c := test.NewFakeCli(&verClient{client.Client{}, types.Version{}, nil, types.Info{}, nil})
c.SetContainerizedEngineClient(
func(string) (clitypes.ContainerizedClient, error) {
return &fakeContainerizedEngineClient{}, nil
},
)
isRoot = func() bool { return true }
cmd := newActivateCommand(testCli)
cmd := newActivateCommand(c)
cmd.SilenceUsage = true
cmd.SilenceErrors = true
cmd.Flags().Set("license", "invalidpath")
err := cmd.Execute()
assert.Error(t, err, "open invalidpath: no such file or directory")
assert.Assert(t, os.IsNotExist(err))
}

func TestActivateExpiredLicenseDryRun(t *testing.T) {
Expand Down
22 changes: 15 additions & 7 deletions cli/command/node/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (

type fakeClient struct {
client.Client
infoFunc func() (types.Info, error)
nodeInspectFunc func() (swarm.Node, []byte, error)
nodeListFunc func() ([]swarm.Node, error)
nodeRemoveFunc func() error
nodeUpdateFunc func(nodeID string, version swarm.Version, node swarm.NodeSpec) error
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
infoFunc func() (types.Info, error)
nodeInspectFunc func() (swarm.Node, []byte, error)
nodeListFunc func() ([]swarm.Node, error)
nodeRemoveFunc func() error
nodeUpdateFunc func(nodeID string, version swarm.Version, node swarm.NodeSpec) error
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
serviceInspectFunc func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error)
}

func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) {
Expand Down Expand Up @@ -67,3 +68,10 @@ func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptio
}
return []swarm.Task{}, nil
}

func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
if cli.serviceInspectFunc != nil {
return cli.serviceInspectFunc(ctx, serviceID, opts)
}
return swarm.Service{}, []byte{}, nil
}
45 changes: 34 additions & 11 deletions cli/command/node/ps_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package node

import (
"context"
"fmt"
"io/ioutil"
"testing"
Expand Down Expand Up @@ -66,13 +67,14 @@ func TestNodePsErrors(t *testing.T) {

func TestNodePs(t *testing.T) {
testCases := []struct {
name string
args []string
flags map[string]string
infoFunc func() (types.Info, error)
nodeInspectFunc func() (swarm.Node, []byte, error)
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
name string
args []string
flags map[string]string
infoFunc func() (types.Info, error)
nodeInspectFunc func() (swarm.Node, []byte, error)
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
serviceInspectFunc func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error)
}{
{
name: "simple",
Expand All @@ -91,6 +93,16 @@ func TestNodePs(t *testing.T) {
}))),
}, nil
},
serviceInspectFunc: func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
return swarm.Service{
ID: serviceID,
Spec: swarm.ServiceSpec{
Annotations: swarm.Annotations{
Name: serviceID,
},
},
}, []byte{}, nil
},
},
{
name: "with-errors",
Expand All @@ -108,14 +120,25 @@ func TestNodePs(t *testing.T) {
WithStatus(Timestamp(time.Now().Add(-4*time.Hour)), StatusErr("a task error"))),
}, nil
},
serviceInspectFunc: func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
return swarm.Service{
ID: serviceID,
Spec: swarm.ServiceSpec{
Annotations: swarm.Annotations{
Name: serviceID,
},
},
}, []byte{}, nil
},
},
}
for _, tc := range testCases {
cli := test.NewFakeCli(&fakeClient{
infoFunc: tc.infoFunc,
nodeInspectFunc: tc.nodeInspectFunc,
taskInspectFunc: tc.taskInspectFunc,
taskListFunc: tc.taskListFunc,
infoFunc: tc.infoFunc,
nodeInspectFunc: tc.nodeInspectFunc,
taskInspectFunc: tc.taskInspectFunc,
taskListFunc: tc.taskListFunc,
serviceInspectFunc: tc.serviceInspectFunc,
})
cmd := newPsCommand(cli)
cmd.SetArgs(tc.args)
Expand Down
4 changes: 4 additions & 0 deletions cli/command/plugin/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ func (c *fakeClient) PluginInspectWithRaw(ctx context.Context, name string) (*ty

return nil, nil, nil
}

func (c *fakeClient) Info(ctx context.Context) (types.Info, error) {
return types.Info{}, nil
}
4 changes: 4 additions & 0 deletions cli/command/registry/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ type fakeClient struct {
client.Client
}

func (c fakeClient) Info(ctx context.Context) (types.Info, error) {
return types.Info{}, nil
}

func (c fakeClient) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registrytypes.AuthenticateOKBody, error) {
if auth.Password == expiredPassword {
return registrytypes.AuthenticateOKBody{}, fmt.Errorf("Invalid Username or Password")
Expand Down
11 changes: 11 additions & 0 deletions cli/command/stack/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error
return nil
}

func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
return swarm.Service{
ID: serviceID,
Spec: swarm.ServiceSpec{
Annotations: swarm.Annotations{
Name: serviceID,
},
},
}, []byte{}, nil
}

func serviceFromName(name string) swarm.Service {
return swarm.Service{
ID: "ID-" + name,
Expand Down
16 changes: 16 additions & 0 deletions cli/command/trust/inspect_pretty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ package trust

import (
"bytes"
"context"
"encoding/hex"
"io"
"io/ioutil"
"testing"

"github.com/docker/cli/cli/trust"
"github.com/docker/cli/internal/test"
notaryfake "github.com/docker/cli/internal/test/notary"
"github.com/docker/docker/api/types"
dockerClient "github.com/docker/docker/client"
"github.com/theupdateframework/notary"
"github.com/theupdateframework/notary/client"
"github.com/theupdateframework/notary/tuf/data"
"github.com/theupdateframework/notary/tuf/utils"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/golden"
Expand All @@ -24,6 +28,18 @@ type fakeClient struct {
dockerClient.Client
}

func (c *fakeClient) Info(ctx context.Context) (types.Info, error) {
return types.Info{}, nil
}

func (c *fakeClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) {
return types.ImageInspect{}, []byte{}, nil
}

func (c *fakeClient) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error) {
return &utils.NoopCloser{Reader: bytes.NewBuffer([]byte{})}, nil
}

func TestTrustInspectPrettyCommandErrors(t *testing.T) {
testCases := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion cli/command/trust/sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,6 @@ func TestSignCommandLocalFlag(t *testing.T) {
cmd := newSignCommand(cli)
cmd.SetArgs([]string{"--local", "reg-name.io/image:red"})
cmd.SetOutput(ioutil.Discard)
assert.ErrorContains(t, cmd.Execute(), "error during connect: Get /images/reg-name.io/image:red/json: unsupported protocol scheme")
assert.ErrorContains(t, cmd.Execute(), "error contacting notary server: dial tcp: lookup reg-name.io")

}
2 changes: 1 addition & 1 deletion vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ github.com/cpuguy83/go-md2man v1.0.8
github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76 # v1.1.0
github.com/dgrijalva/jwt-go a2c85815a77d0f951e33ba4db5ae93629a1530af
github.com/docker/distribution 83389a148052d74ac602f5f1d62f86ff2f3c4aa5
github.com/docker/docker 9f296d1e6fccd9f73bae345e4aad4f3f6e92fdeb
github.com/docker/docker bd224b5fe564f343e22fa76ae8569ec949f35802
github.com/docker/docker-credential-helpers 5241b46610f2491efdf9d1c85f1ddf5b02f6d962
# the docker/go package contains a customized version of canonical/json
# and is used by Notary. The package is periodically rebased on current Go versions.
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/docker/docker/api/common.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/github.com/docker/docker/api/types/mount/mount.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions vendor/github.com/docker/docker/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions vendor/github.com/docker/docker/client/request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vendor/github.com/docker/docker/client/service_update.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion vendor/github.com/docker/docker/pkg/archive/archive.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/docker/docker/pkg/fileutils/fileutils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3a6f8b6

Please sign in to comment.