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

Function TestCheckpointRemoveErrors

cli/command/checkpoint/remove_test.go:14–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestCheckpointRemoveErrors(t *testing.T) {
15 testCases := []struct {
16 args []string
17 checkpointDeleteFunc func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error)
18 expectedError string
19 }{
20 {
21 args: []string{"too-few-arguments"},
22 expectedError: "requires 2 arguments",
23 },
24 {
25 args: []string{"too", "many", "arguments"},
26 expectedError: "requires 2 arguments",
27 },
28 {
29 args: []string{"foo", "bar"},
30 checkpointDeleteFunc: func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error) {
31 return client.CheckpointRemoveResult{}, errors.New("error deleting checkpoint")
32 },
33 expectedError: "error deleting checkpoint",
34 },
35 }
36
37 for _, tc := range testCases {
38 cli := test.NewFakeCli(&fakeClient{
39 checkpointDeleteFunc: tc.checkpointDeleteFunc,
40 })
41 cmd := newRemoveCommand(cli)
42 cmd.SetArgs(tc.args)
43 cmd.SetOut(io.Discard)
44 cmd.SetErr(io.Discard)
45 assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
46 }
47}
48
49func TestCheckpointRemoveWithOptions(t *testing.T) {
50 var containerID, checkpointID, checkpointDir string

Callers

nothing calls this directly

Calls 4

SetArgsMethod · 0.80
newRemoveCommandFunction · 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…