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

Function TestNewCmdComment

pkg/cmd/pr/comment/comment_test.go:27–477  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestNewCmdComment(t *testing.T) {
28 tmpFile := filepath.Join(t.TempDir(), "my-body.md")
29 err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
30 require.NoError(t, err)
31
32 tmpImage := filepath.Join(t.TempDir(), "login.png")
33 require.NoError(t, os.WriteFile(tmpImage, []byte("the bytes"), 0600))
34
35 tests := []struct {
36 name string
37 input string
38 stdin string
39 output shared.CommentableOptions
40 wantsErr bool
41 wantsErrContains string
42 isTTY bool
43
44 // Which fields the lookup asks for is decided at construction, so it
45 // can only be proved here.
46 queryWants string
47 queryOmits string
48 }{
49 {
50 name: "no arguments",
51 input: "",
52 output: shared.CommentableOptions{
53 Interactive: true,
54 InputType: 0,
55 Body: "",
56 },
57 isTTY: true,
58 wantsErr: false,
59 },
60 {
61 name: "two arguments",
62 input: "1 2",
63 output: shared.CommentableOptions{},
64 isTTY: true,
65 wantsErr: true,
66 },
67 {
68 name: "pr number",
69 input: "1",
70 output: shared.CommentableOptions{
71 Interactive: true,
72 InputType: 0,
73 Body: "",
74 },
75 isTTY: true,
76 wantsErr: false,
77 },
78 {
79 name: "pr url",
80 input: "https://github.com/OWNER/REPO/pull/12",
81 output: shared.CommentableOptions{
82 Interactive: true,
83 InputType: 0,
84 Body: "",

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RegisterMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
JoinMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
ContainsMethod · 0.80

Tested by

no test coverage detected