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

Function TestNodePs

cli/command/node/ps_test.go:66–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestNodePs(t *testing.T) {
67 testCases := []struct {
68 name string
69 args []string
70 flags map[string]string
71 nodeInspectFunc func() (client.NodeInspectResult, error)
72 taskListFunc func(options client.TaskListOptions) (client.TaskListResult, error)
73 taskInspectFunc func(taskID string) (client.TaskInspectResult, error)
74 serviceInspectFunc func(ctx context.Context, serviceID string, opts client.ServiceInspectOptions) (client.ServiceInspectResult, error)
75 }{
76 {
77 name: "simple",
78 args: []string{"nodeID"},
79 nodeInspectFunc: func() (client.NodeInspectResult, error) {
80 return client.NodeInspectResult{
81 Node: *builders.Node(),
82 }, nil
83 },
84 taskListFunc: func(options client.TaskListOptions) (client.TaskListResult, error) {
85 return client.TaskListResult{
86 Items: []swarm.Task{
87 *builders.Task(builders.WithStatus(builders.Timestamp(time.Now().Add(-2*time.Hour)), builders.PortStatus([]swarm.PortConfig{
88 {
89 TargetPort: 80,
90 PublishedPort: 80,
91 Protocol: "tcp",
92 },
93 }))),
94 },
95 }, nil
96 },
97 serviceInspectFunc: func(ctx context.Context, serviceID string, opts client.ServiceInspectOptions) (client.ServiceInspectResult, error) {
98 return client.ServiceInspectResult{
99 Service: swarm.Service{
100 ID: serviceID,
101 Spec: swarm.ServiceSpec{
102 Annotations: swarm.Annotations{
103 Name: serviceID,
104 },
105 },
106 },
107 }, nil
108 },
109 },
110 {
111 name: "with-errors",
112 args: []string{"nodeID"},
113 nodeInspectFunc: func() (client.NodeInspectResult, error) {
114 return client.NodeInspectResult{
115 Node: *builders.Node(),
116 }, nil
117 },
118 taskListFunc: func(options client.TaskListOptions) (client.TaskListResult, error) {
119 return client.TaskListResult{
120 Items: []swarm.Task{
121 *builders.Task(builders.TaskID("taskID1"), builders.TaskServiceID("failure"),
122 builders.WithStatus(builders.Timestamp(time.Now().Add(-2*time.Hour)), builders.StatusErr("a task error"))),
123 *builders.Task(builders.TaskID("taskID2"), builders.TaskServiceID("failure"),

Callers

nothing calls this directly

Calls 6

OutBufferMethod · 0.95
NodeMethod · 0.80
SetArgsMethod · 0.80
newPsCommandFunction · 0.70
StringMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…