(t *testing.T)
| 378 | } |
| 379 | |
| 380 | func TestParseSourceControlTriggers(t *testing.T) { |
| 381 | tests := []struct { |
| 382 | name string |
| 383 | input string |
| 384 | wantEvent string |
| 385 | wantTypes []string |
| 386 | wantErr bool |
| 387 | }{ |
| 388 | { |
| 389 | name: "pull_request with synchronize", |
| 390 | input: "pull_request synchronize", |
| 391 | wantEvent: "pull_request", |
| 392 | wantTypes: []string{"synchronize"}, |
| 393 | }, |
| 394 | { |
| 395 | name: "pull_request with reopened", |
| 396 | input: "pull_request reopened", |
| 397 | wantEvent: "pull_request", |
| 398 | wantTypes: []string{"reopened"}, |
| 399 | }, |
| 400 | { |
| 401 | name: "pull_request with labeled", |
| 402 | input: "pull_request labeled", |
| 403 | wantEvent: "pull_request", |
| 404 | wantTypes: []string{"labeled"}, |
| 405 | }, |
| 406 | { |
| 407 | name: "invalid push format", |
| 408 | input: "push invalid format", |
| 409 | wantErr: true, |
| 410 | }, |
| 411 | { |
| 412 | name: "invalid pull_request type", |
| 413 | input: "pull_request invalid", |
| 414 | wantErr: true, |
| 415 | }, |
| 416 | } |
| 417 | |
| 418 | for _, tt := range tests { |
| 419 | t.Run(tt.name, func(t *testing.T) { |
| 420 | ir, err := ParseTriggerShorthand(tt.input) |
| 421 | |
| 422 | if tt.wantErr { |
| 423 | if err == nil { |
| 424 | t.Errorf("ParseTriggerShorthand() expected error but got none") |
| 425 | } |
| 426 | return |
| 427 | } |
| 428 | |
| 429 | if err != nil { |
| 430 | t.Errorf("ParseTriggerShorthand() unexpected error = %v", err) |
| 431 | return |
| 432 | } |
| 433 | |
| 434 | if ir == nil { |
| 435 | t.Errorf("ParseTriggerShorthand() returned nil") |
| 436 | return |
| 437 | } |
nothing calls this directly
no test coverage detected