MCPcopy Index your code
hub / github.com/cli/cli / TestNewCmdComment

Function TestNewCmdComment

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 9

TestFunction · 0.92
JoinMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
NewCmdCommentFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected