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

Function TestNewCmdComment

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

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected