MCPcopy Index your code
hub / github.com/docker/cli / TestParseLabelfileVariables

Function TestParseLabelfileVariables

cli/command/container/opts_test.go:995–1019  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

993}
994
995func 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
1021func TestParseEntryPoint(t *testing.T) {
1022 config, _, _, err := parseRun([]string{"--entrypoint=anything", "cmd", "img"})

Callers

nothing calls this directly

Calls 2

parseRunFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…