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

Function runCobra

plugins/pass/commands/command_test.go:236–253  ·  view source on GitHub ↗
(t *testing.T, cmd *cobra.Command, mock store.Store, stdin *bytes.Buffer, args []string)

Source from the content-addressed store, hash-verified

234}
235
236func 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

Callers 2

executeFunction · 0.85
executeWithStdinFunction · 0.85

Calls 2

WithStoreFunction · 0.70
StringMethod · 0.65

Tested by

no test coverage detected