(t *testing.T)
| 40 | ) |
| 41 | |
| 42 | func TestSortTemplates(t *testing.T) { |
| 43 | tpls := map[string]renderable{ |
| 44 | "/mychart/templates/foo.tpl": {}, |
| 45 | "/mychart/templates/charts/foo/charts/bar/templates/foo.tpl": {}, |
| 46 | "/mychart/templates/bar.tpl": {}, |
| 47 | "/mychart/templates/charts/foo/templates/bar.tpl": {}, |
| 48 | "/mychart/templates/_foo.tpl": {}, |
| 49 | "/mychart/templates/charts/foo/templates/foo.tpl": {}, |
| 50 | "/mychart/templates/charts/bar/templates/foo.tpl": {}, |
| 51 | } |
| 52 | got := sortTemplates(tpls) |
| 53 | if len(got) != len(tpls) { |
| 54 | t.Fatal("Sorted results are missing templates") |
| 55 | } |
| 56 | |
| 57 | expect := []string{ |
| 58 | "/mychart/templates/charts/foo/charts/bar/templates/foo.tpl", |
| 59 | "/mychart/templates/charts/foo/templates/foo.tpl", |
| 60 | "/mychart/templates/charts/foo/templates/bar.tpl", |
| 61 | "/mychart/templates/charts/bar/templates/foo.tpl", |
| 62 | "/mychart/templates/foo.tpl", |
| 63 | "/mychart/templates/bar.tpl", |
| 64 | "/mychart/templates/_foo.tpl", |
| 65 | } |
| 66 | for i, e := range expect { |
| 67 | if got[i] != e { |
| 68 | t.Fatalf("\n\tExp:\n%s\n\tGot:\n%s", |
| 69 | strings.Join(expect, "\n"), |
| 70 | strings.Join(got, "\n"), |
| 71 | ) |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func TestFuncMap(t *testing.T) { |
| 77 | fns := funcMap() |
nothing calls this directly
no test coverage detected
searching dependent graphs…