test(templater): Add a test for the insertTemplate function

This commit is contained in:
Jude Venn 2019-04-30 08:44:06 +01:00 committed by Vincent Ambo
parent 6353ed9d14
commit c422686f84
2 changed files with 25 additions and 0 deletions

View file

@ -179,3 +179,27 @@ func TestDefaultTemplateFunction(t *testing.T) {
t.Fail()
}
}
func TestInsertTemplateFunction(t *testing.T) {
ctx := context.Context{}
resourceSet := context.ResourceSet{
Path: "testdata",
Values: map[string]interface{}{
"testName": "TestInsertTemplateFunction",
},
}
res, err := templateFile(&ctx, &resourceSet, "testdata/test-insertTemplate.txt")
if err != nil {
t.Error(err)
t.Errorf("Templating with an insertTemplate call should have succeeded.\n")
t.Fail()
}
if res.Rendered != "Inserting \"Template for test TestInsertTemplateFunction\".\n" {
t.Error("Result does not contain expected rendered template value.")
t.Error(res.Rendered)
t.Fail()
}
}

View file

@ -0,0 +1 @@
Inserting "{{ insertTemplate "test-template.txt" | trim }}".