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

Function commentableCmd

pkg/cmd/pr/shared/commentable_test.go:27–46  ·  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

25// commentableCmd builds the flag set the comment commands share, so that
26// CommentablePreRun sees the same command shape it does in production.
27func 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
48func TestCommentablePreRun(t *testing.T) {
49 tests := []struct {

Callers 1

TestCommentablePreRunFunction · 0.85

Calls 3

AddFlagFunction · 0.92
HelperMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected