MCPcopy Index your code
hub / github.com/docker/cli / TestStackPsErrors

Function TestStackPsErrors

cli/command/stack/ps_test.go:19–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestStackPsErrors(t *testing.T) {
20 testCases := []struct {
21 args []string
22 taskListFunc func(options client.TaskListOptions) (client.TaskListResult, error)
23 expectedError string
24 }{
25 {
26 args: []string{},
27 expectedError: "requires 1 argument",
28 },
29 {
30 args: []string{"foo", "bar"},
31 expectedError: "requires 1 argument",
32 },
33 {
34 args: []string{"foo"},
35 taskListFunc: func(options client.TaskListOptions) (client.TaskListResult, error) {
36 return client.TaskListResult{}, errors.New("error getting tasks")
37 },
38 expectedError: "error getting tasks",
39 },
40 }
41
42 for _, tc := range testCases {
43 t.Run(tc.expectedError, func(t *testing.T) {
44 cmd := newPsCommand(test.NewFakeCli(&fakeClient{
45 taskListFunc: tc.taskListFunc,
46 }))
47 cmd.SetArgs(tc.args)
48 cmd.SetOut(io.Discard)
49 cmd.SetErr(io.Discard)
50 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
51 })
52 }
53}
54
55func TestStackPs(t *testing.T) {
56 testCases := []struct {

Callers

nothing calls this directly

Calls 4

SetArgsMethod · 0.80
newPsCommandFunction · 0.70
SetOutMethod · 0.45
SetErrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…