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

Function TestCheckpointCreateErrors

cli/command/checkpoint/create_test.go:16–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

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