about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--templater/templater_test.go24
-rw-r--r--templater/testdata/test-insertTemplate.txt1
2 files changed, 25 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()
+	}
+}
diff --git a/templater/testdata/test-insertTemplate.txt b/templater/testdata/test-insertTemplate.txt
new file mode 100644
index 000000000000..8155e174fe00
--- /dev/null
+++ b/templater/testdata/test-insertTemplate.txt
@@ -0,0 +1 @@
+Inserting "{{ insertTemplate "test-template.txt" | trim }}".