Skip to content

Commit d1cb7d4

Browse files
committed
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>
1 parent 34d42bd commit d1cb7d4

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

cli/command/container/exec_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func TestRunExec(t *testing.T) {
162162
testcases := []struct {
163163
doc string
164164
options ExecOptions
165-
client fakeClient
165+
client *fakeClient
166166
expectedError string
167167
expectedOut string
168168
expectedErr string
@@ -172,12 +172,12 @@ func TestRunExec(t *testing.T) {
172172
options: withDefaultOpts(ExecOptions{
173173
Detach: true,
174174
}),
175-
client: fakeClient{execCreateFunc: execCreateWithID},
175+
client: &fakeClient{execCreateFunc: execCreateWithID},
176176
},
177177
{
178178
doc: "inspect error",
179179
options: NewExecOptions(),
180-
client: fakeClient{
180+
client: &fakeClient{
181181
inspectFunc: func(string) (types.ContainerJSON, error) {
182182
return types.ContainerJSON{}, errors.New("failed inspect")
183183
},
@@ -188,12 +188,13 @@ func TestRunExec(t *testing.T) {
188188
doc: "missing exec ID",
189189
options: NewExecOptions(),
190190
expectedError: "exec ID empty",
191+
client: &fakeClient{},
191192
},
192193
}
193194

194195
for _, testcase := range testcases {
195196
t.Run(testcase.doc, func(t *testing.T) {
196-
fakeCLI := test.NewFakeCli(&testcase.client)
197+
fakeCLI := test.NewFakeCli(testcase.client)
197198

198199
err := RunExec(context.TODO(), fakeCLI, "thecontainer", testcase.options)
199200
if testcase.expectedError != "" {

cli/command/container/logs_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestRunLogs(t *testing.T) {
3030
testcases := []struct {
3131
doc string
3232
options *logsOptions
33-
client fakeClient
33+
client *fakeClient
3434
expectedError string
3535
expectedOut string
3636
expectedErr string
@@ -39,13 +39,13 @@ func TestRunLogs(t *testing.T) {
3939
doc: "successful logs",
4040
expectedOut: "foo",
4141
options: &logsOptions{},
42-
client: fakeClient{logFunc: logFn("foo"), inspectFunc: inspectFn},
42+
client: &fakeClient{logFunc: logFn("foo"), inspectFunc: inspectFn},
4343
},
4444
}
4545

4646
for _, testcase := range testcases {
4747
t.Run(testcase.doc, func(t *testing.T) {
48-
cli := test.NewFakeCli(&testcase.client)
48+
cli := test.NewFakeCli(testcase.client)
4949

5050
err := runLogs(context.TODO(), cli, testcase.options)
5151
if testcase.expectedError != "" {

cli/command/registry/login_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ type fakeClient struct {
2929
client.Client
3030
}
3131

32-
func (c fakeClient) Info(context.Context) (system.Info, error) {
32+
func (c *fakeClient) Info(context.Context) (system.Info, error) {
3333
return system.Info{}, nil
3434
}
3535

36-
func (c fakeClient) RegistryLogin(_ context.Context, auth registrytypes.AuthConfig) (registrytypes.AuthenticateOKBody, error) {
36+
func (c *fakeClient) RegistryLogin(_ context.Context, auth registrytypes.AuthConfig) (registrytypes.AuthenticateOKBody, error) {
3737
if auth.Password == expiredPassword {
3838
return registrytypes.AuthenticateOKBody{}, errors.New("Invalid Username or Password")
3939
}

0 commit comments

Comments
 (0)