about summary refs log tree commit diff
path: root/templater/templater_test.go
diff options
context:
space:
mode:
authorJude Venn <judev@cuttlefish.com>2019-04-30T07·44+0100
committerVincent Ambo <github@tazj.in>2019-05-01T22·30+0100
commitc422686f8488df917d206b36354ca7903a0906d3 (patch)
treebeebf85d5de26d9e59bf745f85a1bd1491d49b70 /templater/templater_test.go
parent6353ed9d142412ee2c9c656c47459c56b3cdf698 (diff)
test(templater): Add a test for the `insertTemplate` function
Diffstat (limited to 'templater/templater_test.go')
-rw-r--r--templater/templater_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/templater/templater_test.go b/templater/templater_test.go
index 2a9ddaa2bb10..4237681c1a01 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()
+	}
+}