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

Function TestGetExitStatus

cli/command/container/attach_test.go:95–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestGetExitStatus(t *testing.T) {
96 expectedErr := errors.New("unexpected error")
97
98 testcases := []struct {
99 result *container.WaitResponse
100 err error
101 expectedError error
102 }{
103 {
104 result: &container.WaitResponse{
105 StatusCode: 0,
106 },
107 },
108 {
109 err: expectedErr,
110 expectedError: expectedErr,
111 },
112 {
113 result: &container.WaitResponse{
114 Error: &container.WaitExitError{Message: expectedErr.Error()},
115 },
116 expectedError: expectedErr,
117 },
118 {
119 result: &container.WaitResponse{
120 StatusCode: 15,
121 },
122 expectedError: cli.StatusError{StatusCode: 15},
123 },
124 }
125
126 for _, testcase := range testcases {
127 errC := make(chan error, 1)
128 resultC := make(chan container.WaitResponse, 1)
129 if testcase.err != nil {
130 errC <- testcase.err
131 }
132 if testcase.result != nil {
133 resultC <- *testcase.result
134 }
135
136 err := getExitStatus(client.ContainerWaitResult{
137 Result: resultC,
138 Error: errC,
139 })
140
141 if testcase.expectedError == nil {
142 assert.NilError(t, err)
143 } else {
144 assert.Error(t, err, testcase.expectedError.Error())
145 }
146 }
147}

Callers

nothing calls this directly

Calls 2

getExitStatusFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…