MCPcopy
hub / github.com/helm/helm / TestSortTemplates

Function TestSortTemplates

pkg/engine/engine_test.go:42–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40)
41
42func 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
76func TestFuncMap(t *testing.T) {
77 fns := funcMap()

Callers

nothing calls this directly

Calls 3

sortTemplatesFunction · 0.85
FatalMethod · 0.80
FatalfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…