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

Function TestSwarmUnlock

cli/command/swarm/unlock_test.go:86–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

84}
85
86func TestSwarmUnlock(t *testing.T) {
87 input := "unlockKey"
88 dockerCli := test.NewFakeCli(&fakeClient{
89 infoFunc: func() (system.Info, error) {
90 return system.Info{
91 Swarm: swarm.Info{
92 LocalNodeState: swarm.LocalNodeStateLocked,
93 },
94 }, nil
95 },
96 swarmUnlockFunc: func(req client.SwarmUnlockOptions) (client.SwarmUnlockResult, error) {
97 if req.Key != input {
98 return client.SwarmUnlockResult{}, errors.New("invalid unlock key")
99 }
100 return client.SwarmUnlockResult{}, nil
101 },
102 })
103 dockerCli.SetIn(streams.NewIn(io.NopCloser(strings.NewReader(input))))
104 cmd := newUnlockCommand(dockerCli)
105 cmd.SetArgs([]string{})
106 cmd.SetOut(io.Discard)
107 cmd.SetErr(io.Discard)
108 assert.NilError(t, cmd.Execute())
109}

Callers

nothing calls this directly

Calls 5

SetInMethod · 0.95
newUnlockCommandFunction · 0.85
SetArgsMethod · 0.80
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…