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

Function TestCheckpointCreateWithOptions

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

Source from the content-addressed store, hash-verified

49}
50
51func TestCheckpointCreateWithOptions(t *testing.T) {
52 const (
53 containerName = "container-foo"
54 checkpointName = "checkpoint-bar"
55 checkpointDir = "/dir/foo"
56 )
57
58 for _, tc := range []bool{true, false} {
59 leaveRunning := strconv.FormatBool(tc)
60 t.Run("leave-running="+leaveRunning, func(t *testing.T) {
61 var actualContainerName string
62 var actualOptions client.CheckpointCreateOptions
63 cli := test.NewFakeCli(&fakeClient{
64 checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) {
65 actualContainerName = container
66 actualOptions = options
67 return client.CheckpointCreateResult{}, nil
68 },
69 })
70 cmd := newCreateCommand(cli)
71 cmd.SetOut(io.Discard)
72 cmd.SetErr(io.Discard)
73 cmd.SetArgs([]string{containerName, checkpointName})
74 assert.Check(t, cmd.Flags().Set("leave-running", leaveRunning))
75 assert.Check(t, cmd.Flags().Set("checkpoint-dir", checkpointDir))
76 assert.NilError(t, cmd.Execute())
77 assert.Check(t, is.Equal(actualContainerName, containerName))
78 expected := client.CheckpointCreateOptions{
79 CheckpointID: checkpointName,
80 CheckpointDir: checkpointDir,
81 Exit: !tc,
82 }
83 assert.Check(t, is.Equal(actualOptions, expected))
84 assert.Check(t, is.Equal(strings.TrimSpace(cli.OutBuffer().String()), checkpointName))
85 })
86 }
87}

Callers

nothing calls this directly

Calls 7

OutBufferMethod · 0.95
SetArgsMethod · 0.80
newCreateCommandFunction · 0.70
StringMethod · 0.65
SetOutMethod · 0.45
SetErrMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…