| 993 | } |
| 994 | |
| 995 | func TestParseLabelfileVariables(t *testing.T) { |
| 996 | expErr := "--label-file: open nonexistent: no such file or directory" |
| 997 | if runtime.GOOS == "windows" { |
| 998 | expErr = "--label-file: open nonexistent: The system cannot find the file specified." |
| 999 | } |
| 1000 | // label ko |
| 1001 | if _, _, _, err := parseRun([]string{"--label-file=nonexistent", "img", "cmd"}); err == nil || err.Error() != expErr { |
| 1002 | t.Fatalf("Expected an error with message '%s', got %v", expErr, err) |
| 1003 | } |
| 1004 | // label ok |
| 1005 | config, _, _, err := parseRun([]string{"--label-file=testdata/valid.label", "img", "cmd"}) |
| 1006 | if err != nil { |
| 1007 | t.Fatal(err) |
| 1008 | } |
| 1009 | if len(config.Labels) != 1 || config.Labels["LABEL1"] != "value1" { |
| 1010 | t.Fatalf("Expected a config with [LABEL1:value1], got %v", config.Labels) |
| 1011 | } |
| 1012 | config, _, _, err = parseRun([]string{"--label-file=testdata/valid.label", "--label=LABEL2=value2", "img", "cmd"}) |
| 1013 | if err != nil { |
| 1014 | t.Fatal(err) |
| 1015 | } |
| 1016 | if len(config.Labels) != 2 || config.Labels["LABEL1"] != "value1" || config.Labels["LABEL2"] != "value2" { |
| 1017 | t.Fatalf("Expected a config with [LABEL1:value1 LABEL2:value2], got %v", config.Labels) |
| 1018 | } |
| 1019 | } |
| 1020 | |
| 1021 | func TestParseEntryPoint(t *testing.T) { |
| 1022 | config, _, _, err := parseRun([]string{"--entrypoint=anything", "cmd", "img"}) |