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 38b6a76e7aff..6dc27466a579 100644
--- a/context/context_test.go
+++ b/context/context_test.go
@@ -280,3 +280,25 @@ func TestExplicitSubresourcePathLoading(t *testing.T) {
 		t.Fail()
 	}
 }
+
+func TestSetVariablesFromArguments(t *testing.T) {
+	vars := []string{"version=some-service-version"}
+	ctx, _ := LoadContextFromFile("testdata/default-loading.yaml")
+
+	if err := ctx.SetVariablesFromArguments(&vars); err != nil {
+		t.Error(err)
+	}
+
+	if version := ctx.Global["version"]; version != "some-service-version" {
+		t.Errorf(`Expected variable "version" to have value "some-service-version" but was "%s"`, version)
+	}
+}
+
+func TestSetInvalidVariablesFromArguments(t *testing.T) {
+	vars := []string{"version: some-service-version"}
+	ctx, _ := LoadContextFromFile("testdata/default-loading.yaml")
+
+	if err := ctx.SetVariablesFromArguments(&vars); err == nil {
+		t.Error("Expected invalid variable to return an error")
+	}
+}