@@ -530,6 +530,29 @@ func TestParseEnvfileVariables(t *testing.T) {
530530 }
531531}
532532
533+ func TestParseEnvfileVariablesWithoutEqualSign (t * testing.T ) {
534+ e := "open nonexistent: no such file or directory"
535+ if runtime .GOOS == "windows" {
536+ e = "open nonexistent: The system cannot find the file specified."
537+ }
538+ // env without equal sign
539+ config , _ , _ , err := parseRun ([]string {"--env-file=testdata/noequalsign.env" , "img" , "cmd" })
540+ if err != nil {
541+ t .Fatal (err )
542+ }
543+ if len (config .Env ) != 2 || config .Env [0 ] != "bar=" || config .Env [1 ] != "demo=true" {
544+ t .Fatalf ("Expected a config with [bar= demo=true], got %v" , config .Env )
545+ }
546+ os .Setenv ("foo" , "bar" )
547+ config , _ , _ , err = parseRun ([]string {"--env-file=testdata/noequalsign.env" , "img" , "cmd" })
548+ if err != nil {
549+ t .Fatal (err )
550+ }
551+ if len (config .Env ) != 3 || config .Env [0 ] != "foo=bar" || config .Env [1 ] != "bar=" || config .Env [2 ] != "demo=true" {
552+ t .Fatalf ("Expected a config with [foo=bar bar= demo=true], got %v" , config .Env )
553+ }
554+ }
555+
533556func TestParseEnvfileVariablesWithBOMUnicode (t * testing.T ) {
534557 // UTF8 with BOM
535558 config , _ , _ , err := parseRun ([]string {"--env-file=testdata/utf8.env" , "img" , "cmd" })
@@ -583,6 +606,28 @@ func TestParseLabelfileVariables(t *testing.T) {
583606 }
584607}
585608
609+ func TestParseLabelfileVariablesWithoutEqualSign (t * testing.T ) {
610+ e := "open nonexistent: no such file or directory"
611+ if runtime .GOOS == "windows" {
612+ e = "open nonexistent: The system cannot find the file specified."
613+ }
614+ // label without equal sign
615+ config , _ , _ , err := parseRun ([]string {"--label-file=testdata/noequalsign.label" , "img" , "cmd" })
616+ if err != nil {
617+ t .Fatal (err )
618+ }
619+ if len (config .Labels ) != 3 || config .Labels ["demo" ] != "true" || config .Labels ["foo" ] != "" || config .Labels ["bar" ] != "" {
620+ t .Fatalf ("Expected a config with [foo: bar: demo=true], got %v" , config .Labels )
621+ }
622+ config , _ , _ , err = parseRun ([]string {"--label-file=testdata/noequalsign.label" , "--label=foo=bar" , "img" , "cmd" })
623+ if err != nil {
624+ t .Fatal (err )
625+ }
626+ if len (config .Labels ) != 3 || config .Labels ["demo" ] != "true" || config .Labels ["foo" ] != "bar" || config .Labels ["bar" ] != "" {
627+ t .Fatalf ("Expected a config with [foo:bar bar: demo=true], got %v" , config .Labels )
628+ }
629+ }
630+
586631func TestParseEntryPoint (t * testing.T ) {
587632 config , _ , _ , err := parseRun ([]string {"--entrypoint=anything" , "cmd" , "img" })
588633 if err != nil {
0 commit comments