(t *testing.T, cmd *cobra.Command, mock store.Store, stdin *bytes.Buffer, args []string)
| 234 | } |
| 235 | |
| 236 | func runCobra(t *testing.T, cmd *cobra.Command, mock store.Store, stdin *bytes.Buffer, args []string) (string, error) { |
| 237 | t.Helper() |
| 238 | cmd.SilenceUsage = true |
| 239 | ctx := t.Context() |
| 240 | if mock != nil { |
| 241 | ctx = WithStore(ctx, mock) |
| 242 | } |
| 243 | cmd.SetContext(ctx) |
| 244 | buf := &bytes.Buffer{} |
| 245 | cmd.SetOut(buf) |
| 246 | cmd.SetErr(buf) |
| 247 | if stdin != nil { |
| 248 | cmd.SetIn(stdin) |
| 249 | } |
| 250 | cmd.SetArgs(args) |
| 251 | err := cmd.Execute() |
| 252 | return buf.String(), err |
| 253 | } |
| 254 | |
| 255 | // assertStoredValue asserts the secret stored under id "foo" — every set-test |
| 256 | // uses that id, so the helpers hard-code it rather than carrying a parameter |
no test coverage detected