templatefile/pkg/utils/templates_test.go

35 lines
725 B
Go

package utils
import (
"io/ioutil"
"testing"
)
func TestProcessHCLTemplate(t *testing.T) {
// load the Full configuration from a file
values, err := ioutil.ReadFile("../../data/config/go-test-conf.json")
if err != nil {
t.Error(err)
}
data, err := ProcessHCLTemplate("../../data/templates/go-test-hcl.pktpl.hcl", values)
if err != nil {
t.Errorf(err.Error())
}
t.Logf("%s", data)
}
func TestProcessGoTemplate(t *testing.T) {
// load values from testing json file
values, err := ioutil.ReadFile("../../data/config/go-test-conf.json")
if err != nil {
t.Error(err)
}
data, err := ProcessGoTemplate("../../data/templates/go-test-go.tpl", values)
if err != nil {
t.Error(err)
}
t.Logf("%s", data)
}