newTestRuntimeWithStdin creates a RuntimeContext with string flags and a fake stdin.
(flags map[string]string, stdin string)
| 15 | |
| 16 | // newTestRuntimeWithStdin creates a RuntimeContext with string flags and a fake stdin. |
| 17 | func newTestRuntimeWithStdin(flags map[string]string, stdin string) *RuntimeContext { |
| 18 | cmd := &cobra.Command{Use: "test"} |
| 19 | for name := range flags { |
| 20 | cmd.Flags().String(name, "", "") |
| 21 | } |
| 22 | cmd.ParseFlags(nil) |
| 23 | for name, val := range flags { |
| 24 | cmd.Flags().Set(name, val) |
| 25 | } |
| 26 | return &RuntimeContext{ |
| 27 | Cmd: cmd, |
| 28 | Factory: &cmdutil.Factory{ |
| 29 | IOStreams: &cmdutil.IOStreams{ |
| 30 | In: strings.NewReader(stdin), |
| 31 | }, |
| 32 | }, |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | func TestResolveInputFlags_DirectValue(t *testing.T) { |
| 37 | rctx := newTestRuntimeWithStdin(map[string]string{"markdown": "hello world"}, "") |
no test coverage detected