(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestExtractFeatures(t *testing.T) { |
| 10 | compiler := &Compiler{} |
| 11 | |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | frontmatter map[string]any |
| 15 | expected map[string]any |
| 16 | }{ |
| 17 | { |
| 18 | name: "valid features map with boolean values", |
| 19 | frontmatter: map[string]any{ |
| 20 | "features": map[string]any{ |
| 21 | "feature1": true, |
| 22 | "feature2": false, |
| 23 | "feature3": true, |
| 24 | }, |
| 25 | }, |
| 26 | expected: map[string]any{ |
| 27 | "feature1": true, |
| 28 | "feature2": false, |
| 29 | "feature3": true, |
| 30 | }, |
| 31 | }, |
| 32 | { |
| 33 | name: "features key not present", |
| 34 | frontmatter: map[string]any{"other": "value"}, |
| 35 | expected: nil, |
| 36 | }, |
| 37 | { |
| 38 | name: "empty frontmatter", |
| 39 | frontmatter: map[string]any{}, |
| 40 | expected: nil, |
| 41 | }, |
| 42 | { |
| 43 | name: "features is not a map", |
| 44 | frontmatter: map[string]any{ |
| 45 | "features": "not a map", |
| 46 | }, |
| 47 | expected: nil, |
| 48 | }, |
| 49 | { |
| 50 | name: "features map with mixed value types", |
| 51 | frontmatter: map[string]any{ |
| 52 | "features": map[string]any{ |
| 53 | "feature1": true, |
| 54 | "feature2": "string value", |
| 55 | "action-tag": "2d4c6ce24c55704d72ec674d1f5c357831435180", |
| 56 | }, |
| 57 | }, |
| 58 | expected: map[string]any{ |
| 59 | "feature1": true, |
| 60 | "feature2": "string value", |
| 61 | "action-tag": "2d4c6ce24c55704d72ec674d1f5c357831435180", |
| 62 | }, |
| 63 | }, |
| 64 | { |
| 65 | name: "empty features map", |
| 66 | frontmatter: map[string]any{ |
nothing calls this directly
no test coverage detected