(t *testing.T)
| 3545 | } |
| 3546 | |
| 3547 | func TestUpdateComment(t *testing.T) { |
| 3548 | tests := []struct { |
| 3549 | name string |
| 3550 | commentID string |
| 3551 | body string |
| 3552 | httpStubs func(*testing.T, *httpmock.Registry) |
| 3553 | wantErr string |
| 3554 | wantComment *DiscussionComment |
| 3555 | }{ |
| 3556 | { |
| 3557 | name: "updates comment body", |
| 3558 | commentID: "DC_1", |
| 3559 | body: "Updated body", |
| 3560 | httpStubs: func(t *testing.T, reg *httpmock.Registry) { |
| 3561 | reg.Register( |
| 3562 | httpmock.GraphQLMutationMatcher(`mutation UpdateDiscussionComment\b`, func(input map[string]interface{}) bool { |
| 3563 | assert.Equal(t, "DC_1", input["commentId"]) |
| 3564 | assert.Equal(t, "Updated body", input["body"]) |
| 3565 | return true |
| 3566 | }), |
| 3567 | httpmock.StringResponse(`{ |
| 3568 | "data": { |
| 3569 | "updateDiscussionComment": { |
| 3570 | "comment": { |
| 3571 | "id": "DC_1", |
| 3572 | "url": "https://github.com/OWNER/REPO/discussions/1#discussioncomment-1", |
| 3573 | "author": {"__typename": "User", "login": "monalisa", "id": "U1", "name": "Mona"}, |
| 3574 | "body": "Updated body", |
| 3575 | "createdAt": "2025-06-01T00:00:00Z", |
| 3576 | "isAnswer": true, |
| 3577 | "upvoteCount": 5, |
| 3578 | "reactionGroups": [{"content": "HEART", "users": {"totalCount": 3}}] |
| 3579 | } |
| 3580 | } |
| 3581 | } |
| 3582 | }`), |
| 3583 | ) |
| 3584 | }, |
| 3585 | wantComment: &DiscussionComment{ |
| 3586 | ID: "DC_1", |
| 3587 | URL: "https://github.com/OWNER/REPO/discussions/1#discussioncomment-1", |
| 3588 | Author: DiscussionActor{ID: "U1", Login: "monalisa", Name: "Mona"}, |
| 3589 | Body: "Updated body", |
| 3590 | CreatedAt: time.Date(2025, 6, 1, 0, 0, 0, 0, time.UTC), |
| 3591 | IsAnswer: true, |
| 3592 | UpvoteCount: 5, |
| 3593 | ReactionGroups: []ReactionGroup{{Content: "HEART", TotalCount: 3}}, |
| 3594 | }, |
| 3595 | }, |
| 3596 | { |
| 3597 | name: "mutation error", |
| 3598 | commentID: "DC_bad", |
| 3599 | body: "text", |
| 3600 | httpStubs: func(t *testing.T, reg *httpmock.Registry) { |
| 3601 | reg.Register( |
| 3602 | httpmock.GraphQL(`mutation UpdateDiscussionComment\b`), |
| 3603 | httpmock.StringResponse(`{"data":null,"errors":[{"message":"not found"}]}`), |
| 3604 | ) |
nothing calls this directly
no test coverage detected