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

Function TestRunCommit

cli/command/container/commit_test.go:15–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestRunCommit(t *testing.T) {
16 cli := test.NewFakeCli(&fakeClient{
17 containerCommitFunc: func(ctx context.Context, ctr string, options client.ContainerCommitOptions) (client.ContainerCommitResult, error) {
18 assert.Check(t, is.Equal(options.Author, "Author Name <author@name.com>"))
19 assert.Check(t, is.DeepEqual(options.Changes, []string{"EXPOSE 80"}))
20 assert.Check(t, is.Equal(options.Comment, "commit message"))
21 assert.Check(t, is.Equal(options.NoPause, true))
22 assert.Check(t, is.Equal(ctr, "container-id"))
23
24 return client.ContainerCommitResult{ID: "image-id"}, nil
25 },
26 })
27
28 cmd := newCommitCommand(cli)
29 cmd.SetOut(io.Discard)
30 cmd.SetArgs(
31 []string{
32 "--author", "Author Name <author@name.com>",
33 "--change", "EXPOSE 80",
34 "--message", "commit message",
35 "--no-pause",
36 "container-id",
37 },
38 )
39
40 err := cmd.Execute()
41 assert.NilError(t, err)
42
43 assert.Assert(t, is.Equal(cli.OutBuffer().String(), "image-id\n"))
44}
45
46func TestRunCommitClientError(t *testing.T) {
47 clientError := errors.New("client error")

Callers

nothing calls this directly

Calls 5

OutBufferMethod · 0.95
newCommitCommandFunction · 0.85
SetArgsMethod · 0.80
StringMethod · 0.65
SetOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…