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

Function TestCommentablePreRun

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected