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

Function TestRollback

cli/command/service/rollback_test.go:16–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestRollback(t *testing.T) {
17 testCases := []struct {
18 name string
19 args []string
20 serviceUpdateFunc func(ctx context.Context, serviceID string, options client.ServiceUpdateOptions) (client.ServiceUpdateResult, error)
21 expectedDockerCliErr string
22 }{
23 {
24 name: "rollback-service",
25 args: []string{"service-id"},
26 },
27 {
28 name: "rollback-service-with-warnings",
29 args: []string{"service-id"},
30 serviceUpdateFunc: func(ctx context.Context, serviceID string, options client.ServiceUpdateOptions) (client.ServiceUpdateResult, error) {
31 return client.ServiceUpdateResult{
32 Warnings: []string{
33 "- warning 1",
34 "- warning 2",
35 },
36 }, nil
37 },
38 expectedDockerCliErr: "- warning 1\n- warning 2",
39 },
40 }
41
42 for _, tc := range testCases {
43 cli := test.NewFakeCli(&fakeClient{
44 serviceUpdateFunc: tc.serviceUpdateFunc,
45 })
46 cmd := newRollbackCommand(cli)
47 cmd.SetArgs(tc.args)
48 assert.NilError(t, cmd.Flags().Set("quiet", "true"))
49 assert.NilError(t, cmd.Flags().Set("detach", "true"))
50 cmd.SetOut(io.Discard)
51 assert.NilError(t, cmd.Execute())
52 assert.Check(t, is.Equal(strings.TrimSpace(cli.ErrBuffer().String()), tc.expectedDockerCliErr))
53 }
54}
55
56func TestRollbackWithErrors(t *testing.T) {
57 testCases := []struct {

Callers

nothing calls this directly

Calls 6

ErrBufferMethod · 0.95
newRollbackCommandFunction · 0.85
SetArgsMethod · 0.80
StringMethod · 0.65
SetMethod · 0.45
SetOutMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…