MCPcopy
hub / github.com/docker/compose / TestProviderRawSetEnvOverridesUserEnv

Function TestProviderRawSetEnvOverridesUserEnv

pkg/e2e/providers_test.go:101–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

99}
100
101func TestProviderRawSetEnvOverridesUserEnv(t *testing.T) {
102 provider, err := findExecutable("example-provider")
103 assert.NilError(t, err)
104
105 path := fmt.Sprintf("%s%s%s", os.Getenv("PATH"), string(os.PathListSeparator), filepath.Dir(provider))
106 c := NewParallelCLI(t, WithEnv("PATH="+path))
107 const projectName = "rawsetenv-override"
108 t.Cleanup(func() {
109 c.cleanupWithDown(t, projectName)
110 })
111
112 res := c.RunDockerComposeCmd(t, "-f", "fixtures/providers/rawsetenv-override.yaml", "--project-name", projectName, "up")
113 res.Assert(t, icmd.Success)
114 env := getEnv(res.Combined())
115 // rawsetenv overrides a user-defined environment variable
116 assert.Check(t, slices.Contains(env, "CLOUD_REGION=us-east-1"), env)
117 assert.Check(t, !slices.Contains(env, "CLOUD_REGION=user-defined-region"), env)
118 // the override is surfaced to the user rather than happening silently
119 assert.Check(t, strings.Contains(res.Combined(), "overrides environment variable"), res.Combined())
120}
121
122func TestProviderRawSetEnvOverridesInheritedEnv(t *testing.T) {
123 provider, err := findExecutable("example-provider")

Callers

nothing calls this directly

Calls 7

findExecutableFunction · 0.85
NewParallelCLIFunction · 0.85
WithEnvFunction · 0.85
getEnvFunction · 0.85
cleanupWithDownMethod · 0.80
RunDockerComposeCmdMethod · 0.80
DirMethod · 0.45

Tested by

no test coverage detected