oef/util/template/template_test.go

47 lines
755 B
Go
Raw Normal View History

2019-11-04 15:00:46 +01:00
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))
}