about summary refs log tree commit diff
path: root/templater/templater_test.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-07-14T19·40+0200
committerVincent Ambo <github@tazj.in>2018-07-14T21·21+0200
commitdf1a9a1625f01478b1ce6a5754363468f4342924 (patch)
treeacec7b145a8ffc30adce5221290a4ab509a311c9 /templater/templater_test.go
parentab059ad41c7195e5c4a3f456b7f590d881884dcf (diff)
test(templater): Add a test for the `default` template function
Diffstat (limited to 'templater/templater_test.go')
-rw-r--r--templater/templater_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/templater/templater_test.go b/templater/templater_test.go
index f6b12c758057..2a9ddaa2bb10 100644
--- a/templater/templater_test.go
+++ b/templater/templater_test.go
@@ -162,3 +162,20 @@ func TestFailOnMissingKeys(t *testing.T) {
 		t.Errorf("Templating failed with unexpected error: %v\n", err)
 	}
 }
+
+func TestDefaultTemplateFunction(t *testing.T) {
+	ctx := context.Context{}
+	resourceSet := context.ResourceSet{}
+
+	res, err := templateFile(&ctx, &resourceSet, "testdata/test-default.txt")
+
+	if err != nil {
+		t.Errorf("Templating with default values should have succeeded.\n")
+		t.Fail()
+	}
+
+	if res.Rendered != "defaultValue\n" {
+		t.Error("Result does not contain expected rendered default value.")
+		t.Fail()
+	}
+}