(t *testing.T)
| 272 | } |
| 273 | |
| 274 | func TestGranularUpdateIssueLabels(t *testing.T) { |
| 275 | tests := []struct { |
| 276 | name string |
| 277 | requestArgs map[string]any |
| 278 | expectedReq map[string]any |
| 279 | }{ |
| 280 | { |
| 281 | name: "labels as plain strings", |
| 282 | requestArgs: map[string]any{ |
| 283 | "owner": "owner", |
| 284 | "repo": "repo", |
| 285 | "issue_number": float64(1), |
| 286 | "labels": []any{"bug", "enhancement"}, |
| 287 | }, |
| 288 | expectedReq: map[string]any{ |
| 289 | "labels": []any{"bug", "enhancement"}, |
| 290 | }, |
| 291 | }, |
| 292 | { |
| 293 | name: "label objects without rationale serialize as strings", |
| 294 | requestArgs: map[string]any{ |
| 295 | "owner": "owner", |
| 296 | "repo": "repo", |
| 297 | "issue_number": float64(1), |
| 298 | "labels": []any{ |
| 299 | map[string]any{"name": "bug"}, |
| 300 | "enhancement", |
| 301 | }, |
| 302 | }, |
| 303 | expectedReq: map[string]any{ |
| 304 | "labels": []any{"bug", "enhancement"}, |
| 305 | }, |
| 306 | }, |
| 307 | { |
| 308 | name: "mixed strings and label objects with rationale", |
| 309 | requestArgs: map[string]any{ |
| 310 | "owner": "owner", |
| 311 | "repo": "repo", |
| 312 | "issue_number": float64(1), |
| 313 | "labels": []any{ |
| 314 | "triage", |
| 315 | map[string]any{"name": "bug", "rationale": " Reports a crash when saving "}, |
| 316 | map[string]any{"name": "frontend", "rationale": "Mentions the UI button"}, |
| 317 | }, |
| 318 | }, |
| 319 | expectedReq: map[string]any{ |
| 320 | "labels": []any{ |
| 321 | "triage", |
| 322 | map[string]any{"name": "bug", "rationale": "Reports a crash when saving"}, |
| 323 | map[string]any{"name": "frontend", "rationale": "Mentions the UI button"}, |
| 324 | }, |
| 325 | }, |
| 326 | }, |
| 327 | } |
| 328 | |
| 329 | for _, tc := range tests { |
| 330 | t.Run(tc.name, func(t *testing.T) { |
| 331 | client := mustNewGHClient(t, MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ |
nothing calls this directly
no test coverage detected