Explorar o código

Merge pull request #33557 from AkihiroSuda/test-no-unset

builder: add a test for `ENV name` (without `=value`)
Vincent Demeester %!s(int64=8) %!d(string=hai) anos
pai
achega
d2c6e78371
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      builder/dockerfile/parser/line_parsers_test.go

+ 8 - 0
builder/dockerfile/parser/line_parsers_test.go

@@ -64,3 +64,11 @@ func TestNodeFromLabels(t *testing.T) {
 	assert.Equal(t, expected, node)
 
 }
+
+func TestParseNameValWithoutVal(t *testing.T) {
+	directive := Directive{}
+	// In Config.Env, a variable without `=` is removed from the environment. (#31634)
+	// However, in Dockerfile, we don't allow "unsetting" an environment variable. (#11922)
+	_, err := parseNameVal("foo", "ENV", &directive)
+	assert.Error(t, err, "ENV must have two arguments")
+}