(t *testing.T)
| 199 | } |
| 200 | |
| 201 | func 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 |
nothing calls this directly
no test coverage detected