commentableCmd builds the flag set the comment commands share, so that CommentablePreRun sees the same command shape it does in production.
(t *testing.T, opts *CommentableOptions, input string)
| 25 | // commentableCmd builds the flag set the comment commands share, so that |
| 26 | // CommentablePreRun sees the same command shape it does in production. |
| 27 | func commentableCmd(t *testing.T, opts *CommentableOptions, input string) *cobra.Command { |
| 28 | t.Helper() |
| 29 | |
| 30 | cmd := &cobra.Command{Use: "comment"} |
| 31 | cmd.Flags().String("body", "", "") |
| 32 | cmd.Flags().String("body-file", "", "") |
| 33 | cmd.Flags().Bool("web", false, "") |
| 34 | cmd.Flags().Bool("editor", false, "") |
| 35 | cmd.Flags().BoolVar(&opts.EditLast, "edit-last", false, "") |
| 36 | cmd.Flags().BoolVar(&opts.DeleteLast, "delete-last", false, "") |
| 37 | cmd.Flags().BoolVar(&opts.DeleteLastConfirmed, "yes", false, "") |
| 38 | cmd.Flags().BoolVar(&opts.CreateIfNone, "create-if-none", false, "") |
| 39 | opts.AttachFlag = attachments.AddFlag(cmd) |
| 40 | |
| 41 | argv, err := shlex.Split(input) |
| 42 | require.NoError(t, err) |
| 43 | require.NoError(t, cmd.Flags().Parse(argv)) |
| 44 | |
| 45 | return cmd |
| 46 | } |
| 47 | |
| 48 | func TestCommentablePreRun(t *testing.T) { |
| 49 | tests := []struct { |
no test coverage detected