MCPcopy
hub / github.com/flosch/pongo2 / TestMisc

Method TestMisc

pongo2_test.go:38–66  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

36}
37
38func (s *TestSuite) TestMisc(c *C) {
39 // Must
40 // TODO: Add better error message (see issue #18)
41 c.Check(
42 func() { pongo2.Must(testSuite2.FromFile("template_tests/inheritance/base2.tpl")) },
43 PanicMatches,
44 `\[Error \(where: fromfile\) in .*template_tests[/\\]inheritance[/\\]doesnotexist.tpl | Line 1 Col 12 near 'doesnotexist.tpl'\] open .*template_tests[/\\]inheritance[/\\]doesnotexist.tpl: no such file or directory`,
45 )
46
47 // Context
48 c.Check(parseTemplateFn("", pongo2.Context{"'illegal": nil}), PanicMatches, ".*not a valid identifier.*")
49
50 // Registers
51 c.Check(pongo2.RegisterFilter("escape", nil).Error(), Matches, ".*is already registered")
52 c.Check(pongo2.RegisterTag("for", nil).Error(), Matches, ".*is already registered")
53
54 // ApplyFilter
55 v, err := pongo2.ApplyFilter("title", pongo2.AsValue("this is a title"), nil)
56 if err != nil {
57 c.Fatal(err)
58 }
59 c.Check(v.String(), Equals, "This Is A Title")
60 c.Check(func() {
61 _, err := pongo2.ApplyFilter("doesnotexist", nil, nil)
62 if err != nil {
63 panic(err)
64 }
65 }, PanicMatches, `\[Error \(where: applyfilter\)\] filter with name 'doesnotexist' not found`)
66}
67
68func (s *TestSuite) TestImplicitExecCtx(c *C) {
69 tpl, err := pongo2.FromString("{{ ImplicitExec }}")

Callers

nothing calls this directly

Calls 4

parseTemplateFnFunction · 0.85
FromFileMethod · 0.80
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected