12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package template
- import (
- "strings"
- "testing"
- "text/template"
- "github.com/remogatto/prettytest"
- )
- var funcMap = template.FuncMap{
- "toUpper": toUpper,
- }
- type testSuite struct {
- prettytest.Suite
- }
- func toUpper(s string) string {
- return strings.ToUpper(s)
- }
- func TestRunner(t *testing.T) {
- prettytest.Run(
- t,
- new(testSuite),
- )
- }
- func (t *testSuite) TestLoadTXTTemplate() {
- tpl, err := LoadTextTemplate("testdata/test.tpl")
- t.Nil(err)
- t.Not(t.Nil(tpl))
- }
- func (t *testSuite) TestLoadTXTTemplateWithFuncs() {
- tpl, err := LoadTextTemplate("testdata/test.tpl", funcMap)
- t.Nil(err)
- t.Not(t.Nil(tpl))
- }
- func (t *testSuite) TestLoadTemplateFromString() {
- tpl, err := LoadTextTemplateFromString("{{.}}")
- t.Nil(err)
- t.Not(t.Nil(tpl))
- }
|