MCPcopy Create free account
hub / github.com/cli/cli / commentableCmd

Function commentableCmd

pkg/cmd/pr/shared/commentable_test.go:24–43  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

TestCommentablePreRunFunction · 0.85

Calls 3

AddFlagFunction · 0.92
HelperMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected