浏览代码

builder: add a test for `ENV name` (without `=value`)

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
Akihiro Suda 8 年之前
父节点
当前提交
09eca591f7
共有 1 个文件被更改,包括 8 次插入0 次删除
  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")
+}