mirror of https://github.com/docker/cli.git
cli/command/container: TestWaitExitOrRemoved use subtests
=== RUN TestWaitExitOrRemoved === RUN TestWaitExitOrRemoved/normal-container === RUN TestWaitExitOrRemoved/give-me-exit-code-42 === RUN TestWaitExitOrRemoved/i-want-a-wait-error time="2024-10-13T18:48:14+02:00" level=error msg="Error waiting for container: removal failed" === RUN TestWaitExitOrRemoved/non-existent-container-id time="2024-10-13T18:48:14+02:00" level=error msg="error waiting for container: no such container: non-existent-container-id" --- PASS: TestWaitExitOrRemoved (0.00s) --- PASS: TestWaitExitOrRemoved/normal-container (0.00s) --- PASS: TestWaitExitOrRemoved/give-me-exit-code-42 (0.00s) --- PASS: TestWaitExitOrRemoved/i-want-a-wait-error (0.00s) --- PASS: TestWaitExitOrRemoved/non-existent-container-id (0.00s) PASS Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
3b38dc67be
commit
35d7b1a7a6
|
@ -38,7 +38,7 @@ func waitFn(cid string) (<-chan container.WaitResponse, <-chan error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWaitExitOrRemoved(t *testing.T) {
|
func TestWaitExitOrRemoved(t *testing.T) {
|
||||||
testcases := []struct {
|
tests := []struct {
|
||||||
cid string
|
cid string
|
||||||
exitCode int
|
exitCode int
|
||||||
}{
|
}{
|
||||||
|
@ -61,9 +61,11 @@ func TestWaitExitOrRemoved(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
client := &fakeClient{waitFunc: waitFn, Version: api.DefaultVersion}
|
client := &fakeClient{waitFunc: waitFn, Version: api.DefaultVersion}
|
||||||
for _, testcase := range testcases {
|
for _, tc := range tests {
|
||||||
statusC := waitExitOrRemoved(context.Background(), client, testcase.cid, true)
|
t.Run(tc.cid, func(t *testing.T) {
|
||||||
exitCode := <-statusC
|
statusC := waitExitOrRemoved(context.Background(), client, tc.cid, true)
|
||||||
assert.Check(t, is.Equal(testcase.exitCode, exitCode))
|
exitCode := <-statusC
|
||||||
|
assert.Check(t, is.Equal(tc.exitCode, exitCode))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue