about summary refs log tree commit diff
path: root/templater/templater_test.go
diff options
context:
space:
mode:
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 b262787ae9ba..4aeee254d1c2 100644
--- a/templater/templater_test.go
+++ b/templater/templater_test.go
@@ -3,6 +3,7 @@ package templater
 import (
 	"github.com/tazjin/kontemplate/context"
 	"reflect"
+	"strings"
 	"testing"
 )
 
@@ -136,3 +137,19 @@ func TestApplyLimitsExcludeIncludePrecedence(t *testing.T) {
 		t.Fail()
 	}
 }
+
+func TestFailOnMissingKeys(t *testing.T) {
+	ctx := context.Context{}
+	resourceSet := context.ResourceSet{}
+
+	_, err := templateFile(&ctx, &resourceSet, "testdata/test-template.txt")
+
+	if err == nil {
+		t.Errorf("Template with missing keys should have failed.\n")
+		t.Fail()
+	}
+
+	if !strings.Contains(err.Error(), "map has no entry for key \"testName\"") {
+		t.Errorf("Templating failed with unexpected error: %v\n", err)
+	}
+}