Skip to content

Commit

Permalink
Use subtests
Browse files Browse the repository at this point in the history
Signed-off-by: Harald Albers <[email protected]>
  • Loading branch information
albers committed Oct 30, 2024
1 parent 33d3246 commit ef6cca9
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions cli/command/container/completion_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package container

import (
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -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))
}
}

Expand Down Expand Up @@ -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))
})
}
}

Expand Down

0 comments on commit ef6cca9

Please sign in to comment.