(t *testing.T)
| 125 | } |
| 126 | |
| 127 | func 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 | |
| 147 | func Test_RmCommand(t *testing.T) { |
| 148 | t.Parallel() |
nothing calls this directly
no test coverage detected