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

Function TestNewCmdComment

pkg/cmd/pr/comment/comment_test.go:29–513  ·  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 attachmentEvent := []ghtelemetry.Event{{
38 Type: "attachment_invocation",
39 Dimensions: ghtelemetry.Dimensions{"command": "comment"},
40 Measures: ghtelemetry.Measures{
41 "attach_count": 1, "append_ops_count": 0, "replace_ops_count": 0,
42 },
43 }}
44
45 tests := []struct {
46 name string
47 input string
48 stdin string
49 output shared.CommentableOptions
50 wantsErr bool
51 wantsErrContains string
52 isTTY bool
53 wantEvents []ghtelemetry.Event
54 wantSampleRate int
55
56 // Which fields the lookup asks for is decided at construction, so it
57 // can only be proved here.
58 queryWants string
59 queryOmits string
60 }{
61 {
62 name: "no arguments",
63 input: "",
64 output: shared.CommentableOptions{
65 Interactive: true,
66 InputType: 0,
67 Body: "",
68 },
69 isTTY: true,
70 wantsErr: false,
71 },
72 {
73 name: "two arguments",
74 input: "1 2",
75 output: shared.CommentableOptions{},
76 isTTY: true,
77 wantsErr: true,
78 },
79 {
80 name: "pr number",
81 input: "1",
82 output: shared.CommentableOptions{
83 Interactive: true,
84 InputType: 0,
85 Body: "",
86 },

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
WriteFileMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected