73 lines
1.4 KiB
Go
73 lines
1.4 KiB
Go
package templater
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"testing"
|
|
)
|
|
|
|
func TestProcessHCLTemplate(t *testing.T) {
|
|
// load the Full configuration from a file
|
|
values, err := ioutil.ReadFile("../../data/config/loki-stack.json")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
_, err = processHCLTemplate("../../data/templates/loki-local-config.tpl", values)
|
|
if err != nil {
|
|
t.Errorf(err.Error())
|
|
}
|
|
}
|
|
|
|
func TestProcessGoTemplate(t *testing.T) {
|
|
// load the Full configuration from a file
|
|
values, err := ioutil.ReadFile("../../data/config/loki-stack.json")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
_, err = processGoTemplate("../../data/templates/loki-local-config.tpl", values)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
func TestProcessTemplate(t *testing.T) {
|
|
|
|
goFile := ConfigFile{
|
|
Destination: "/tmp/test.txt",
|
|
Source: "loki-local-config.tpl",
|
|
TemplateType: "go",
|
|
Mode: "700",
|
|
TemplateDir: "../../data/templates/",
|
|
}
|
|
|
|
values, err := ioutil.ReadFile("../../data/config/loki-stack.json")
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
_, err = goFile.ProcessTemplate("/tmp/", values)
|
|
if err != nil {
|
|
t.Errorf(err.Error())
|
|
}
|
|
}
|
|
|
|
/*
|
|
func TestGenerate(t *testing.T) {
|
|
|
|
tFile := ConfigFile{
|
|
Destination: "/tmp/test.txt",
|
|
Source: "../../data/templates/loki-local-config.tpl",
|
|
TemplateType: "go",
|
|
Mode: "700",
|
|
}
|
|
|
|
values := json.Unmarshal(File.)
|
|
|
|
_, err := tFile.Generate("/tmp/","../../data/templates/",values)
|
|
if err != nil {
|
|
t.Errorf(err.Error())
|
|
}
|
|
}
|
|
*/
|