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

Function TestCommentablePreRun

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

Source from the content-addressed store, hash-verified

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

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