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

Function Test_ListCommand

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

Source from the content-addressed store, hash-verified

125}
126
127func Test_ListCommand(t *testing.T) {
128 t.Parallel()
129 t.Run("ok", func(t *testing.T) {
130 mock := teststore.NewMockStore(teststore.WithStore(map[store.ID]store.Secret{
131 store.MustParseID("foo"): pass.NewPassValue([]byte("bar")),
132 store.MustParseID("baz"): pass.NewPassValue([]byte("0")),
133 }))
134 out, err := execute(t, ListCommand(), mock)
135 assert.NoError(t, err)
136 assert.Equal(t, "baz\nfoo\n", out)
137 })
138 t.Run("store error", func(t *testing.T) {
139 errGetAll := errors.New("get error")
140 mock := teststore.NewMockStore(teststore.WithStoreGetAllErr(errGetAll))
141 out, err := execute(t, ListCommand(), mock)
142 assert.ErrorIs(t, err, errGetAll)
143 assert.Equal(t, "Error: "+errGetAll.Error()+"\n", out)
144 })
145}
146
147func Test_RmCommand(t *testing.T) {
148 t.Parallel()

Callers

nothing calls this directly

Calls 4

executeFunction · 0.85
ListCommandFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected