MCPcopy
hub / github.com/cli/cli / TestGetComment

Function TestGetComment

pkg/cmd/discussion/client/client_test.go:3690–3785  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3688}
3689
3690func TestGetComment(t *testing.T) {
3691 tests := []struct {
3692 name string
3693 commentID string
3694 httpStubs func(*httpmock.Registry)
3695 wantErr string
3696 wantComment *DiscussionComment
3697 }{
3698 {
3699 name: "fetches comment",
3700 commentID: "DC_1",
3701 httpStubs: func(reg *httpmock.Registry) {
3702 reg.Register(
3703 httpmock.GraphQL(`query GetDiscussionComment\b`),
3704 httpmock.StringResponse(`{
3705 "data": {
3706 "node": {
3707 "__typename": "DiscussionComment",
3708 "id": "DC_1",
3709 "url": "https://github.com/OWNER/REPO/discussions/1#discussioncomment-1",
3710 "author": {"__typename": "User", "login": "monalisa", "id": "U1", "name": "Mona"},
3711 "body": "Comment body",
3712 "createdAt": "2025-06-01T00:00:00Z",
3713 "isAnswer": false,
3714 "upvoteCount": 2,
3715 "reactionGroups": [{"content": "THUMBS_UP", "users": {"totalCount": 1}}]
3716 }
3717 }
3718 }`),
3719 )
3720 },
3721 wantComment: &DiscussionComment{
3722 ID: "DC_1",
3723 URL: "https://github.com/OWNER/REPO/discussions/1#discussioncomment-1",
3724 Author: DiscussionActor{ID: "U1", Login: "monalisa", Name: "Mona"},
3725 Body: "Comment body",
3726 CreatedAt: time.Date(2025, 6, 1, 0, 0, 0, 0, time.UTC),
3727 UpvoteCount: 2,
3728 ReactionGroups: []ReactionGroup{{Content: "THUMBS_UP", TotalCount: 1}},
3729 },
3730 },
3731 {
3732 name: "wrong node type",
3733 commentID: "I_123",
3734 httpStubs: func(reg *httpmock.Registry) {
3735 reg.Register(
3736 httpmock.GraphQL(`query GetDiscussionComment\b`),
3737 httpmock.StringResponse(`{
3738 "data": {
3739 "node": {
3740 "__typename": "Issue"
3741 }
3742 }
3743 }`),
3744 )
3745 },
3746 wantErr: "is not a discussion comment (got Issue)",
3747 },

Callers

nothing calls this directly

Calls 12

RegisterMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
newTestDiscussionClientFunction · 0.85
ContainsMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
GetCommentMethod · 0.65
RepoHostMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected