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

Function TestCommentablePreRun

pkg/cmd/pr/shared/commentable_test.go:49–175  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47}
48
49func TestCommentablePreRun(t *testing.T) {
50 tests := []struct {
51 name string
52 input string
53 canPrompt bool
54 wantErr string
55 // wantErrIsNotExist covers an error whose text the operating system
56 // words differently, so the assertion cannot be on the message.
57 wantErrIsNotExist bool
58 wantInputType InputType
59 wantAssetPaths []string
60 wantInteractive bool
61 wantBodyProvided bool
62 }{
63 {
64 name: "attach alone is a body input and is resolved",
65 input: "--attach ./shot.png",
66 wantInputType: InputTypeInline,
67 wantAssetPaths: []string{"./shot.png"},
68 },
69 {
70 name: "attach with body is still resolved",
71 input: "--attach ./shot.png --body 'see below'",
72 wantInputType: InputTypeInline,
73 wantBodyProvided: true,
74 wantAssetPaths: []string{"./shot.png"},
75 },
76 {
77 name: "a file that does not exist stops the command",
78 input: "--attach ./gone.png",
79 wantErr: "./gone.png: ",
80 wantErrIsNotExist: true,
81 },
82 {
83 // `--body ""` clears a comment, and only the flag being present can
84 // say so.
85 name: "attach with an empty body",
86 input: "--attach ./shot.png --body ''",
87 wantInputType: InputTypeInline,
88 wantBodyProvided: true,
89 wantAssetPaths: []string{"./shot.png"},
90 },
91 {
92 name: "attach with body-file",
93 input: "--attach ./shot.png --body-file ./body.md",
94 wantInputType: InputTypeInline,
95 wantBodyProvided: true,
96 wantAssetPaths: []string{"./shot.png"},
97 },
98 {
99 name: "attach with editor",
100 input: "--attach ./shot.png --editor",
101 wantInputType: InputTypeEditor,
102 wantAssetPaths: []string{"./shot.png"},
103 },
104 {
105 name: "attach with web",
106 input: "--attach ./shot.png --web",

Callers

nothing calls this directly

Calls 9

TestFunction · 0.92
commentableCmdFunction · 0.85
CommentablePreRunFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
PathMethod · 0.65

Tested by

no test coverage detected