@@ -965,6 +965,25 @@ func TestParseEnvfileVariables(t *testing.T) {
965965 }
966966}
967967
968+ func TestParseEnvfileVariablesWithoutEqualSign (t * testing.T ) {
969+ // env without equal sign
970+ config , _ , _ , err := parseRun ([]string {"--env-file=testdata/noequalsign.env" , "img" , "cmd" })
971+ if err != nil {
972+ t .Fatal (err )
973+ }
974+ if len (config .Env ) != 2 || config .Env [0 ] != "bar=" || config .Env [1 ] != "demo=true" {
975+ t .Fatalf ("Expected a config with [bar= demo=true], got %v" , config .Env )
976+ }
977+ t .Setenv ("foo" , "bar" )
978+ config , _ , _ , err = parseRun ([]string {"--env-file=testdata/noequalsign.env" , "img" , "cmd" })
979+ if err != nil {
980+ t .Fatal (err )
981+ }
982+ if len (config .Env ) != 3 || config .Env [0 ] != "foo=bar" || config .Env [1 ] != "bar=" || config .Env [2 ] != "demo=true" {
983+ t .Fatalf ("Expected a config with [foo=bar bar= demo=true], got %v" , config .Env )
984+ }
985+ }
986+
968987func TestParseEnvfileVariablesWithBOMUnicode (t * testing.T ) {
969988 // UTF8 with BOM
970989 config , _ , _ , err := parseRun ([]string {"--env-file=testdata/utf8.env" , "img" , "cmd" })
@@ -1018,6 +1037,24 @@ func TestParseLabelfileVariables(t *testing.T) {
10181037 }
10191038}
10201039
1040+ func TestParseLabelfileVariablesWithoutEqualSign (t * testing.T ) {
1041+ // label without equal sign
1042+ config , _ , _ , err := parseRun ([]string {"--label-file=testdata/noequalsign.label" , "img" , "cmd" })
1043+ if err != nil {
1044+ t .Fatal (err )
1045+ }
1046+ if len (config .Labels ) != 3 || config .Labels ["demo" ] != "true" || config .Labels ["foo" ] != "" || config .Labels ["bar" ] != "" {
1047+ t .Fatalf ("Expected a config with [foo: bar: demo=true], got %v" , config .Labels )
1048+ }
1049+ config , _ , _ , err = parseRun ([]string {"--label-file=testdata/noequalsign.label" , "--label=foo=bar" , "img" , "cmd" })
1050+ if err != nil {
1051+ t .Fatal (err )
1052+ }
1053+ if len (config .Labels ) != 3 || config .Labels ["demo" ] != "true" || config .Labels ["foo" ] != "bar" || config .Labels ["bar" ] != "" {
1054+ t .Fatalf ("Expected a config with [foo=bar bar: demo:true], got %v" , config .Labels )
1055+ }
1056+ }
1057+
10211058func TestParseEntryPoint (t * testing.T ) {
10221059 config , _ , _ , err := parseRun ([]string {"--entrypoint=anything" , "cmd" , "img" })
10231060 assert .NilError (t , err )
0 commit comments