(t *testing.T)
| 26 | } |
| 27 | |
| 28 | func TestCompletePid(t *testing.T) { |
| 29 | tests := []struct { |
| 30 | containerListFunc func(client.ContainerListOptions) (client.ContainerListResult, error) |
| 31 | toComplete string |
| 32 | expectedCompletions []string |
| 33 | expectedDirective cobra.ShellCompDirective |
| 34 | }{ |
| 35 | { |
| 36 | toComplete: "", |
| 37 | expectedCompletions: []string{"container:", "host"}, |
| 38 | expectedDirective: cobra.ShellCompDirectiveNoFileComp, |
| 39 | }, |
| 40 | { |
| 41 | toComplete: "c", |
| 42 | expectedCompletions: []string{"container:"}, |
| 43 | expectedDirective: cobra.ShellCompDirectiveNoSpace, |
| 44 | }, |
| 45 | { |
| 46 | containerListFunc: func(client.ContainerListOptions) (client.ContainerListResult, error) { |
| 47 | return client.ContainerListResult{ |
| 48 | Items: []container.Summary{ |
| 49 | *builders.Container("c1"), |
| 50 | *builders.Container("c2"), |
| 51 | }, |
| 52 | }, nil |
| 53 | }, |
| 54 | toComplete: "container:", |
| 55 | expectedCompletions: []string{"container:c1", "container:c2"}, |
| 56 | expectedDirective: cobra.ShellCompDirectiveNoFileComp, |
| 57 | }, |
| 58 | } |
| 59 | |
| 60 | for _, tc := range tests { |
| 61 | t.Run(tc.toComplete, func(t *testing.T) { |
| 62 | cli := test.NewFakeCli(&fakeClient{ |
| 63 | containerListFunc: tc.containerListFunc, |
| 64 | }) |
| 65 | completions, directive := completePid(cli)(newRunCommand(cli), nil, tc.toComplete) |
| 66 | assert.Check(t, is.DeepEqual(completions, tc.expectedCompletions)) |
| 67 | assert.Check(t, is.Equal(directive, tc.expectedDirective)) |
| 68 | }) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | func TestCompleteRestartPolicies(t *testing.T) { |
| 73 | values, directives := completeRestartPolicies(nil, nil, "") |
nothing calls this directly
no test coverage detected
searching dependent graphs…