MCPcopy
hub / github.com/cli/cli / TestNewCmdComment

Function TestNewCmdComment

pkg/cmd/discussion/comment/comment_test.go:21–237  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestNewCmdComment(t *testing.T) {
22 tests := []struct {
23 name string
24 args string
25 isTTY bool
26 wantOpts CommentOptions
27 wantBaseRepo ghrepo.Interface
28 wantErr string
29 }{
30 {
31 name: "add comment with body",
32 args: "123 --body 'Hello world'",
33 isTTY: true,
34 wantOpts: CommentOptions{
35 ParsedArg: &shared.ParsedDiscussionOrCommentArg{Number: 123},
36 Body: "Hello world",
37 },
38 },
39 {
40 name: "reply to comment by node ID",
41 args: "DC_abc --body 'Reply text'",
42 isTTY: true,
43 wantOpts: CommentOptions{
44 ParsedArg: &shared.ParsedDiscussionOrCommentArg{CommentNodeID: "DC_abc"},
45 Body: "Reply text",
46 },
47 },
48 {
49 name: "reply to comment by comment URL",
50 args: "https://github.com/OWNER/REPO/discussions/5#discussioncomment-999 --body 'Reply text'",
51 isTTY: true,
52 wantOpts: CommentOptions{
53 ParsedArg: &shared.ParsedDiscussionOrCommentArg{
54 Number: 5,
55 CommentDatabaseID: 999,
56 },
57 Body: "Reply text",
58 },
59 wantBaseRepo: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
60 },
61 {
62 name: "edit comment by node ID",
63 args: "DC_abc --edit --body 'Updated'",
64 isTTY: true,
65 wantOpts: CommentOptions{
66 ParsedArg: &shared.ParsedDiscussionOrCommentArg{CommentNodeID: "DC_abc"},
67 Edit: true,
68 Body: "Updated",
69 },
70 },
71 {
72 name: "edit comment by comment URL",
73 args: "https://github.com/OWNER/REPO/discussions/5#discussioncomment-999 --edit --body 'Updated'",
74 isTTY: true,
75 wantOpts: CommentOptions{
76 ParsedArg: &shared.ParsedDiscussionOrCommentArg{
77 Number: 5,
78 CommentDatabaseID: 999,

Callers

nothing calls this directly

Calls 11

NewWithHostFunction · 0.92
TestFunction · 0.92
IsSameFunction · 0.92
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
ContainsMethod · 0.80
EqualMethod · 0.80
NewCmdCommentFunction · 0.70
RunMethod · 0.65
BaseRepoMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected