(t *testing.T)
| 301 | } |
| 302 | |
| 303 | func TestExpandLabelTriggerShorthand(t *testing.T) { |
| 304 | tests := []struct { |
| 305 | name string |
| 306 | entityType string |
| 307 | labelNames []string |
| 308 | wantTriggerKey string |
| 309 | wantItemTypeName string |
| 310 | }{ |
| 311 | { |
| 312 | name: "issues with single label", |
| 313 | entityType: "issues", |
| 314 | labelNames: []string{"bug"}, |
| 315 | wantTriggerKey: "issues", |
| 316 | wantItemTypeName: "issue", |
| 317 | }, |
| 318 | { |
| 319 | name: "issues with multiple labels", |
| 320 | entityType: "issues", |
| 321 | labelNames: []string{"bug", "enhancement"}, |
| 322 | wantTriggerKey: "issues", |
| 323 | wantItemTypeName: "issue", |
| 324 | }, |
| 325 | { |
| 326 | name: "pull_request with single label", |
| 327 | entityType: "pull_request", |
| 328 | labelNames: []string{"needs-review"}, |
| 329 | wantTriggerKey: "pull_request", |
| 330 | wantItemTypeName: "pull request", |
| 331 | }, |
| 332 | { |
| 333 | name: "pull_request with multiple labels", |
| 334 | entityType: "pull_request", |
| 335 | labelNames: []string{"needs-review", "approved"}, |
| 336 | wantTriggerKey: "pull_request", |
| 337 | wantItemTypeName: "pull request", |
| 338 | }, |
| 339 | { |
| 340 | name: "discussion with single label", |
| 341 | entityType: "discussion", |
| 342 | labelNames: []string{"question"}, |
| 343 | wantTriggerKey: "discussion", |
| 344 | wantItemTypeName: "discussion", |
| 345 | }, |
| 346 | { |
| 347 | name: "discussion with multiple labels", |
| 348 | entityType: "discussion", |
| 349 | labelNames: []string{"question", "announcement"}, |
| 350 | wantTriggerKey: "discussion", |
| 351 | wantItemTypeName: "discussion", |
| 352 | }, |
| 353 | } |
| 354 | |
| 355 | for _, tt := range tests { |
| 356 | t.Run(tt.name, func(t *testing.T) { |
| 357 | result := expandLabelTriggerShorthand(tt.entityType, tt.labelNames) |
| 358 | |
| 359 | // Check that the trigger key exists |
| 360 | if _, exists := result[tt.wantTriggerKey]; !exists { |
nothing calls this directly
no test coverage detected