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

Function TestNewCmdComment

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

Source from the content-addressed store, hash-verified

28)
29
30func TestNewCmdComment(t *testing.T) {
31 tmpFile := filepath.Join(t.TempDir(), "my-body.md")
32 err := os.WriteFile(tmpFile, []byte("a body from file"), 0600)
33 require.NoError(t, err)
34
35 tmpImage := filepath.Join(t.TempDir(), "login.png")
36 require.NoError(t, os.WriteFile(tmpImage, []byte("the bytes"), 0600))
37
38 attachmentEvent := []ghtelemetry.Event{{
39 Type: "attachment_invocation",
40 Dimensions: ghtelemetry.Dimensions{"command": "comment"},
41 Measures: ghtelemetry.Measures{
42 "attach_count": 1, "append_ops_count": 0, "replace_ops_count": 0,
43 },
44 }}
45
46 tests := []struct {
47 name string
48 input string
49 stdin string
50 output shared.CommentableOptions
51 wantsErr bool
52 wantsErrContains string
53 isTTY bool
54 wantEvents []ghtelemetry.Event
55 wantSampleRate int
56
57 // Which fields the lookup asks for is decided at construction, so it
58 // can only be proved here.
59 queryWants string
60 queryOmits string
61 }{
62 {
63 name: "no arguments",
64 input: "",
65 output: shared.CommentableOptions{},
66 isTTY: true,
67 wantsErr: true,
68 },
69 {
70 name: "issue 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: "issue url",
82 input: "https://github.com/OWNER/REPO/issues/12",
83 output: shared.CommentableOptions{
84 Interactive: true,
85 InputType: 0,
86 Body: "",
87 },

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
EventsMethod · 0.80

Tested by

no test coverage detected