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

Function TestBuildEnvironment

cli/command/stack/loader_test.go:50–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestBuildEnvironment(t *testing.T) {
51 inputEnv := []string{
52 "LEGIT_VAR=LEGIT_VALUE",
53 "EMPTY_VARIABLE=",
54 }
55
56 if runtime.GOOS == "windows" {
57 inputEnv = []string{
58 "LEGIT_VAR=LEGIT_VALUE",
59
60 // cmd.exe has some special environment variables which start with "=".
61 // These should be ignored as they're only there for MS-DOS compatibility.
62 "=ExitCode=00000041",
63 "=ExitCodeAscii=A",
64 `=C:=C:\some\dir`,
65 `=D:=D:\some\different\dir`,
66 `=X:=X:\`,
67 `=::=::\`,
68
69 "EMPTY_VARIABLE=",
70 }
71 }
72
73 env, err := buildEnvironment(inputEnv)
74 assert.NilError(t, err)
75
76 assert.Check(t, is.Len(env, 2))
77 assert.Check(t, is.Equal("LEGIT_VALUE", env["LEGIT_VAR"]))
78 assert.Check(t, is.Equal("", env["EMPTY_VARIABLE"]))
79}

Callers

nothing calls this directly

Calls 2

buildEnvironmentFunction · 0.85
LenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…