diff --git a/cli/command/container/completion_test.go b/cli/command/container/completion_test.go index dce3237092c5..ca75a49b5fe6 100644 --- a/cli/command/container/completion_test.go +++ b/cli/command/container/completion_test.go @@ -1,7 +1,6 @@ package container import ( - "fmt" "strings" "testing" @@ -56,14 +55,15 @@ func TestCompletePid(t *testing.T) { } for _, tc := range tests { - cli := test.NewFakeCli(&fakeClient{ - containerListFunc: tc.containerListFunc, + tc := tc + t.Run(tc.toComplete, func(t *testing.T) { + cli := test.NewFakeCli(&fakeClient{ + containerListFunc: tc.containerListFunc, + }) + completions, directive := completePid(cli)(NewRunCommand(cli), nil, tc.toComplete) + assert.Check(t, is.DeepEqual(completions, tc.expectedCompletions)) + assert.Check(t, is.Equal(directive, tc.expectedDirective)) }) - - completions, directive := completePid(cli)(NewRunCommand(cli), nil, tc.toComplete) - - assert.DeepEqual(t, completions, tc.expectedCompletions) - assert.Equal(t, directive, tc.expectedDirective, fmt.Sprintf("wrong directive in completion for '%s'", tc.toComplete)) } } @@ -119,9 +119,12 @@ func TestCompleteSecurityOpts(t *testing.T) { } for _, tc := range tests { - completions, directive := completeSecurityOpt(nil, nil, tc.toComplete) - assert.DeepEqual(t, completions, tc.expectedCompletions) - assert.Equal(t, directive, tc.expectedDirective, fmt.Sprintf("wrong directive in completion for '%s'", tc.toComplete)) + tc := tc + t.Run(tc.toComplete, func(t *testing.T) { + completions, directive := completeSecurityOpt(nil, nil, tc.toComplete) + assert.Check(t, is.DeepEqual(completions, tc.expectedCompletions)) + assert.Check(t, is.Equal(directive, tc.expectedDirective)) + }) } }