(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestExtractLabelNames(t *testing.T) { |
| 17 | compiler := &Compiler{} |
| 18 | |
| 19 | tests := []struct { |
| 20 | name string |
| 21 | frontmatter map[string]any |
| 22 | expected []string |
| 23 | }{ |
| 24 | { |
| 25 | name: "single label name as string", |
| 26 | frontmatter: map[string]any{ |
| 27 | "on": map[string]any{ |
| 28 | "pull_request_target": map[string]any{ |
| 29 | "types": []any{"labeled"}, |
| 30 | }, |
| 31 | "labels": "panel-review", |
| 32 | }, |
| 33 | }, |
| 34 | expected: []string{"panel-review"}, |
| 35 | }, |
| 36 | { |
| 37 | name: "multiple label names as array", |
| 38 | frontmatter: map[string]any{ |
| 39 | "on": map[string]any{ |
| 40 | "pull_request_target": map[string]any{ |
| 41 | "types": []any{"labeled"}, |
| 42 | }, |
| 43 | "labels": []any{"panel-review", "needs-triage"}, |
| 44 | }, |
| 45 | }, |
| 46 | expected: []string{"panel-review", "needs-triage"}, |
| 47 | }, |
| 48 | { |
| 49 | name: "no labels field returns nil", |
| 50 | frontmatter: map[string]any{ |
| 51 | "on": map[string]any{ |
| 52 | "pull_request_target": map[string]any{ |
| 53 | "types": []any{"labeled"}, |
| 54 | }, |
| 55 | }, |
| 56 | }, |
| 57 | expected: nil, |
| 58 | }, |
| 59 | { |
| 60 | name: "no on section returns nil", |
| 61 | frontmatter: map[string]any{}, |
| 62 | expected: nil, |
| 63 | }, |
| 64 | } |
| 65 | |
| 66 | for _, tt := range tests { |
| 67 | t.Run(tt.name, func(t *testing.T) { |
| 68 | result := compiler.extractLabelNames(tt.frontmatter) |
| 69 | assert.Equal(t, tt.expected, result, "extractLabelNames should return expected label names") |
| 70 | }) |
| 71 | } |
| 72 | } |
| 73 |
nothing calls this directly
no test coverage detected