(t *testing.T)
| 3124 | } |
| 3125 | |
| 3126 | func TestUpdate(t *testing.T) { |
| 3127 | repo := ghrepo.New("OWNER", "REPO") |
| 3128 | |
| 3129 | titleStr := "Updated title" |
| 3130 | bodyStr := "Updated body" |
| 3131 | catID := "CAT_2" |
| 3132 | |
| 3133 | tests := []struct { |
| 3134 | name string |
| 3135 | input UpdateDiscussionInput |
| 3136 | httpStubs func(*testing.T, *httpmock.Registry) |
| 3137 | wantErr string |
| 3138 | assertDisc *Discussion |
| 3139 | }{ |
| 3140 | { |
| 3141 | name: "nothing to update", |
| 3142 | input: UpdateDiscussionInput{ |
| 3143 | DiscussionID: "D_1", |
| 3144 | }, |
| 3145 | wantErr: "nothing to update", |
| 3146 | }, |
| 3147 | { |
| 3148 | name: "maps all fields", |
| 3149 | input: UpdateDiscussionInput{ |
| 3150 | DiscussionID: "D_1", |
| 3151 | Title: &titleStr, |
| 3152 | Body: &bodyStr, |
| 3153 | CategoryID: &catID, |
| 3154 | AddLabelIDs: []string{"L_bug", "L_enh"}, |
| 3155 | RemoveLabelIDs: []string{"L_old", "L_stale"}, |
| 3156 | }, |
| 3157 | httpStubs: func(t *testing.T, reg *httpmock.Registry) { |
| 3158 | reg.Register( |
| 3159 | httpmock.GraphQL(`mutation UpdateDiscussion\b`), |
| 3160 | httpmock.StringResponse(heredoc.Doc(` |
| 3161 | { |
| 3162 | "data": { |
| 3163 | "updateDiscussion": { |
| 3164 | "discussion": { |
| 3165 | "id": "D_1", |
| 3166 | "number": 5, |
| 3167 | "title": "Updated title", |
| 3168 | "body": "Updated body", |
| 3169 | "url": "https://github.com/OWNER/REPO/discussions/5", |
| 3170 | "closed": false, |
| 3171 | "stateReason": "", |
| 3172 | "isAnswered": false, |
| 3173 | "answerChosenAt": "0001-01-01T00:00:00Z", |
| 3174 | "author": {"__typename": "User", "login": "alice", "id": "U1", "name": "Alice"}, |
| 3175 | "category": {"id": "CAT_2", "name": "Q&A", "slug": "q-a", "emoji": ":question:", "isAnswerable": true}, |
| 3176 | "answerChosenBy": null, |
| 3177 | "labels": {"nodes": [{"id": "L_bug", "name": "bug", "color": "d73a4a"}, {"id": "L_enh", "name": "enhancement", "color": "a2eeef"}]}, |
| 3178 | "reactionGroups": [{"content": "THUMBS_UP", "users": {"totalCount": 0}}], |
| 3179 | "createdAt": "2025-06-01T00:00:00Z", |
| 3180 | "updatedAt": "2025-06-02T00:00:00Z", |
| 3181 | "closedAt": "0001-01-01T00:00:00Z", |
| 3182 | "locked": false |
| 3183 | } |
nothing calls this directly
no test coverage detected