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

Function TestNewCmdComment

pkg/cmd/issue/comment/comment_test.go:24–298  ·  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 isTTY: true,
42 wantsErr: true,
43 },
44 {
45 name: "issue number",
46 input: "1",
47 output: shared.CommentableOptions{
48 Interactive: true,
49 InputType: 0,
50 Body: "",
51 },
52 isTTY: true,
53 wantsErr: false,
54 },
55 {
56 name: "issue url",
57 input: "https://github.com/OWNER/REPO/issues/12",
58 output: shared.CommentableOptions{
59 Interactive: true,
60 InputType: 0,
61 Body: "",
62 },
63 isTTY: true,
64 wantsErr: false,
65 },
66 {
67 name: "body flag",
68 input: "1 --body test",
69 output: shared.CommentableOptions{
70 Interactive: false,
71 InputType: shared.InputTypeInline,
72 Body: "test",
73 },
74 isTTY: true,
75 wantsErr: false,
76 },
77 {
78 name: "body from stdin",
79 input: "1 --body-file -",
80 stdin: "this is on standard input",
81 output: shared.CommentableOptions{

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