mirror of https://github.com/docker/cli.git
cli/command: Don't copy fakeClient
The embedded `client.Client` has mutexes and it shouldn't be copied. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
34d42bdf0c
commit
d1cb7d41c2
|
@ -162,7 +162,7 @@ func TestRunExec(t *testing.T) {
|
|||
testcases := []struct {
|
||||
doc string
|
||||
options ExecOptions
|
||||
client fakeClient
|
||||
client *fakeClient
|
||||
expectedError string
|
||||
expectedOut string
|
||||
expectedErr string
|
||||
|
@ -172,12 +172,12 @@ func TestRunExec(t *testing.T) {
|
|||
options: withDefaultOpts(ExecOptions{
|
||||
Detach: true,
|
||||
}),
|
||||
client: fakeClient{execCreateFunc: execCreateWithID},
|
||||
client: &fakeClient{execCreateFunc: execCreateWithID},
|
||||
},
|
||||
{
|
||||
doc: "inspect error",
|
||||
options: NewExecOptions(),
|
||||
client: fakeClient{
|
||||
client: &fakeClient{
|
||||
inspectFunc: func(string) (types.ContainerJSON, error) {
|
||||
return types.ContainerJSON{}, errors.New("failed inspect")
|
||||
},
|
||||
|
@ -188,12 +188,13 @@ func TestRunExec(t *testing.T) {
|
|||
doc: "missing exec ID",
|
||||
options: NewExecOptions(),
|
||||
expectedError: "exec ID empty",
|
||||
client: &fakeClient{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testcase := range testcases {
|
||||
t.Run(testcase.doc, func(t *testing.T) {
|
||||
fakeCLI := test.NewFakeCli(&testcase.client)
|
||||
fakeCLI := test.NewFakeCli(testcase.client)
|
||||
|
||||
err := RunExec(context.TODO(), fakeCLI, "thecontainer", testcase.options)
|
||||
if testcase.expectedError != "" {
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestRunLogs(t *testing.T) {
|
|||
testcases := []struct {
|
||||
doc string
|
||||
options *logsOptions
|
||||
client fakeClient
|
||||
client *fakeClient
|
||||
expectedError string
|
||||
expectedOut string
|
||||
expectedErr string
|
||||
|
@ -39,13 +39,13 @@ func TestRunLogs(t *testing.T) {
|
|||
doc: "successful logs",
|
||||
expectedOut: "foo",
|
||||
options: &logsOptions{},
|
||||
client: fakeClient{logFunc: logFn("foo"), inspectFunc: inspectFn},
|
||||
client: &fakeClient{logFunc: logFn("foo"), inspectFunc: inspectFn},
|
||||
},
|
||||
}
|
||||
|
||||
for _, testcase := range testcases {
|
||||
t.Run(testcase.doc, func(t *testing.T) {
|
||||
cli := test.NewFakeCli(&testcase.client)
|
||||
cli := test.NewFakeCli(testcase.client)
|
||||
|
||||
err := runLogs(context.TODO(), cli, testcase.options)
|
||||
if testcase.expectedError != "" {
|
||||
|
|
|
@ -29,11 +29,11 @@ type fakeClient struct {
|
|||
client.Client
|
||||
}
|
||||
|
||||
func (c fakeClient) Info(context.Context) (system.Info, error) {
|
||||
func (c *fakeClient) Info(context.Context) (system.Info, error) {
|
||||
return system.Info{}, nil
|
||||
}
|
||||
|
||||
func (c fakeClient) RegistryLogin(_ context.Context, auth registrytypes.AuthConfig) (registrytypes.AuthenticateOKBody, error) {
|
||||
func (c *fakeClient) RegistryLogin(_ context.Context, auth registrytypes.AuthConfig) (registrytypes.AuthenticateOKBody, error) {
|
||||
if auth.Password == expiredPassword {
|
||||
return registrytypes.AuthenticateOKBody{}, errors.New("Invalid Username or Password")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue