From 09eca591f723f9acd0909b04144c229b6cd59912 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Wed, 7 Jun 2017 05:23:26 +0000 Subject: [PATCH] builder: add a test for `ENV name` (without `=value`) Signed-off-by: Akihiro Suda --- builder/dockerfile/parser/line_parsers_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/builder/dockerfile/parser/line_parsers_test.go b/builder/dockerfile/parser/line_parsers_test.go index cd6d57af3a..cf0b21bb51 100644 --- a/builder/dockerfile/parser/line_parsers_test.go +++ b/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") +}