(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestReconstructContent(t *testing.T) { |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | frontmatterLines []string |
| 17 | markdown string |
| 18 | expectedInContent []string |
| 19 | }{ |
| 20 | { |
| 21 | name: "basic reconstruction", |
| 22 | frontmatterLines: []string{ |
| 23 | "on: workflow_dispatch", |
| 24 | "permissions:", |
| 25 | " contents: read", |
| 26 | }, |
| 27 | markdown: "# Test\n\nContent", |
| 28 | expectedInContent: []string{ |
| 29 | "---", |
| 30 | "on: workflow_dispatch", |
| 31 | "permissions:", |
| 32 | " contents: read", |
| 33 | "---", |
| 34 | "# Test", |
| 35 | }, |
| 36 | }, |
| 37 | { |
| 38 | name: "no markdown body", |
| 39 | frontmatterLines: []string{ |
| 40 | "on: workflow_dispatch", |
| 41 | }, |
| 42 | markdown: "", |
| 43 | expectedInContent: []string{ |
| 44 | "---", |
| 45 | "on: workflow_dispatch", |
| 46 | "---", |
| 47 | }, |
| 48 | }, |
| 49 | } |
| 50 | |
| 51 | for _, tt := range tests { |
| 52 | t.Run(tt.name, func(t *testing.T) { |
| 53 | result := reconstructContent(tt.frontmatterLines, tt.markdown) |
| 54 | for _, expected := range tt.expectedInContent { |
| 55 | assert.Contains(t, result, expected, "Expected content to contain %q", expected) |
| 56 | } |
| 57 | }) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestParseFrontmatterLines(t *testing.T) { |
| 62 | tests := []struct { |
nothing calls this directly
no test coverage detected