(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestParseTriggerShorthand(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | input string |
| 13 | wantEvent string |
| 14 | wantTypes []string |
| 15 | wantFilters map[string]any |
| 16 | wantConds []string |
| 17 | wantNil bool |
| 18 | wantErr bool |
| 19 | }{ |
| 20 | // Source Control Patterns - Push |
| 21 | { |
| 22 | name: "simple push (left as-is)", |
| 23 | input: "push", |
| 24 | wantNil: true, // Simple triggers left as-is |
| 25 | }, |
| 26 | { |
| 27 | name: "push to branch", |
| 28 | input: "push to main", |
| 29 | wantEvent: "push", |
| 30 | wantFilters: map[string]any{ |
| 31 | "branches": []string{"main"}, |
| 32 | }, |
| 33 | }, |
| 34 | { |
| 35 | name: "push to branch with spaces", |
| 36 | input: "push to feature branch", |
| 37 | wantEvent: "push", |
| 38 | wantFilters: map[string]any{ |
| 39 | "branches": []string{"feature branch"}, |
| 40 | }, |
| 41 | }, |
| 42 | { |
| 43 | name: "push tags", |
| 44 | input: "push tags v*", |
| 45 | wantEvent: "push", |
| 46 | wantFilters: map[string]any{ |
| 47 | "tags": []string{"v*"}, |
| 48 | }, |
| 49 | }, |
| 50 | |
| 51 | // Source Control Patterns - Pull Request |
| 52 | { |
| 53 | name: "simple pull_request (left as-is)", |
| 54 | input: "pull_request", |
| 55 | wantNil: true, // Simple triggers left as-is |
| 56 | }, |
| 57 | { |
| 58 | name: "simple pull (left as-is)", |
| 59 | input: "pull", |
| 60 | wantNil: true, // Simple triggers left as-is |
| 61 | }, |
| 62 | { |
| 63 | name: "pull_request opened", |
| 64 | input: "pull_request opened", |
| 65 | wantEvent: "pull_request", |
| 66 | wantTypes: []string{"opened"}, |
nothing calls this directly
no test coverage detected