about summary refs log tree commit diff
path: root/context/context_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'context/context_test.go')
-rw-r--r--context/context_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/context/context_test.go b/context/context_test.go
index e700cf41978a..34c77cc9b7c6 100644
--- a/context/context_test.go
+++ b/context/context_test.go
@@ -293,3 +293,25 @@ func TestSetInvalidVariablesFromArguments(t *testing.T) {
 		t.Error("Expected invalid variable to return an error")
 	}
 }
+
+// This test ensures that variables are merged in the correct order.
+// Please consult the test data in `testdata/merging`.
+func TestValueMergePrecedence(t *testing.T) {
+	cliVars:= []string{"cliVar=cliVar"}
+	ctx, _ := LoadContext("testdata/merging/context.yaml", &cliVars)
+
+	expected := map[string]interface{}{
+		"defaultVar": "defaultVar",
+		"importVar": "importVar",
+		"globalVar": "globalVar",
+		"includeVar": "includeVar",
+		"cliVar": "cliVar",
+	}
+
+	result := ctx.ResourceSets[0].Values
+
+	if !reflect.DeepEqual(expected, result) {
+		t.Errorf("Merged values did not match expected result: \n%v", result)
+		t.Fail()
+	}
+}