From c422686f8488df917d206b36354ca7903a0906d3 Mon Sep 17 00:00:00 2001 From: Jude Venn Date: Tue, 30 Apr 2019 08:44:06 +0100 Subject: test(templater): Add a test for the `insertTemplate` function --- templater/templater_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'templater/templater_test.go') diff --git a/templater/templater_test.go b/templater/templater_test.go index 2a9ddaa2bb..4237681c1a 100644 --- a/templater/templater_test.go +++ b/templater/templater_test.go @@ -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() + } +} -- cgit 1.4.1