(t *testing.T)
| 1150 | } |
| 1151 | |
| 1152 | func TestGetWithComments(t *testing.T) { |
| 1153 | repo := ghrepo.New("OWNER", "REPO") |
| 1154 | |
| 1155 | tests := []struct { |
| 1156 | name string |
| 1157 | limit int |
| 1158 | after string |
| 1159 | newest bool |
| 1160 | httpStubs func(*testing.T, *httpmock.Registry) |
| 1161 | wantErr string |
| 1162 | assertDisc func(*testing.T, *Discussion) |
| 1163 | }{ |
| 1164 | { |
| 1165 | name: "maps comments with replies", |
| 1166 | limit: 10, |
| 1167 | newest: false, |
| 1168 | httpStubs: func(t *testing.T, reg *httpmock.Registry) { |
| 1169 | reg.Register( |
| 1170 | httpmock.GraphQL(`query RepositoryMetaForDiscussions\b`), |
| 1171 | httpmock.StringResponse(repoMetaResp("R_1", true)), |
| 1172 | ) |
| 1173 | reg.Register( |
| 1174 | httpmock.GraphQL(`query DiscussionWithComments\b`), |
| 1175 | httpmock.StringResponse(heredoc.Doc(` |
| 1176 | { |
| 1177 | "data": { |
| 1178 | "repository": { |
| 1179 | "discussion": { |
| 1180 | "id": "D_1", |
| 1181 | "number": 42, |
| 1182 | "title": "Test Discussion", |
| 1183 | "body": "Discussion body", |
| 1184 | "url": "https://github.com/OWNER/REPO/discussions/42", |
| 1185 | "closed": true, |
| 1186 | "stateReason": "RESOLVED", |
| 1187 | "isAnswered": true, |
| 1188 | "answerChosenAt": "2025-06-01T12:00:00Z", |
| 1189 | "author": {"__typename": "User", "login": "alice", "id": "U_alice", "name": "Alice"}, |
| 1190 | "category": {"id": "CAT1", "name": "Q&A", "slug": "q-a", "emoji": ":question:", "isAnswerable": true}, |
| 1191 | "answerChosenBy": {"__typename": "User", "login": "bob", "id": "U_bob", "name": "Bob"}, |
| 1192 | "labels": {"nodes": [{"id": "L1", "name": "bug", "color": "d73a4a"}]}, |
| 1193 | "reactionGroups": [{"content": "THUMBS_UP", "users": {"totalCount": 3}}], |
| 1194 | "createdAt": "2025-01-01T00:00:00Z", |
| 1195 | "updatedAt": "2025-01-02T00:00:00Z", |
| 1196 | "closedAt": "2025-06-01T00:00:00Z", |
| 1197 | "locked": true, |
| 1198 | "comments": { |
| 1199 | "totalCount": 1, |
| 1200 | "pageInfo": {"endCursor": "COM_CUR", "hasNextPage": true, "startCursor": "COM_START", "hasPreviousPage": false}, |
| 1201 | "nodes": [ |
| 1202 | { |
| 1203 | "id": "C1", |
| 1204 | "url": "https://github.com/OWNER/REPO/discussions/42#comment-1", |
| 1205 | "author": {"__typename": "User", "login": "octocat", "id": "U_octocat", "name": "Octocat"}, |
| 1206 | "body": "Main comment", |
| 1207 | "createdAt": "2025-03-01T00:00:00Z", |
| 1208 | "isAnswer": true, |
| 1209 | "upvoteCount": 5, |
nothing calls this directly
no test coverage detected