MCPcopy Create free account
hub / github.com/docker/secrets-engine / Test_GetCommand

Function Test_GetCommand

plugins/pass/commands/command_test.go:201–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func Test_GetCommand(t *testing.T) {
202 t.Parallel()
203 t.Run("ok", func(t *testing.T) {
204 mock := teststore.NewMockStore(teststore.WithStore(map[store.ID]store.Secret{
205 store.MustParseID("foo"): pass.NewPassValue([]byte("bar")),
206 }))
207 out, err := execute(t, GetCommand(), mock, "foo")
208 assert.NoError(t, err)
209 assert.Equal(t, "ID: foo\nValue: **********\n", out)
210 })
211 t.Run("store error", func(t *testing.T) {
212 errGet := errors.New("get error")
213 mock := teststore.NewMockStore(teststore.WithStoreGetErr(errGet))
214 out, err := execute(t, GetCommand(), mock, "foo")
215 assert.ErrorIs(t, err, errGet)
216 assert.Equal(t, "Error: "+errGet.Error()+"\n", out)
217 })
218}
219
220// execute runs cmd as if it were the root command: it attaches mock to the
221// command context so RunE bodies can pull it via StoreFrom, captures stdout

Callers

nothing calls this directly

Calls 4

executeFunction · 0.85
GetCommandFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected