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

Function Test_processFile_optional_env_file_present

pkg/compose/publish_test.go:178–206  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

176}
177
178func Test_processFile_optional_env_file_present(t *testing.T) {
179 dir := t.TempDir()
180 envPath := filepath.Join(dir, "app.env")
181 assert.NilError(t, os.WriteFile(envPath, []byte("FOO=bar\n"), 0o600))
182
183 composePath := filepath.Join(dir, "compose.yaml")
184 composeContent := `name: test
185services:
186 web:
187 image: nginx
188 env_file:
189 - path: app.env
190 required: false
191`
192 assert.NilError(t, os.WriteFile(composePath, []byte(composeContent), 0o600))
193
194 project, err := loader.LoadWithContext(t.Context(), types.ConfigDetails{
195 WorkingDir: dir,
196 Environment: types.Mapping{},
197 ConfigFiles: []types.ConfigFile{{Filename: composePath}},
198 })
199 assert.NilError(t, err)
200
201 extFiles := map[string]string{}
202 envFiles := map[string]string{}
203 _, err = processFile(t.Context(), composePath, project, extFiles, envFiles)
204 assert.NilError(t, err)
205 assert.Equal(t, len(envFiles), 1, "present optional env file should be added")
206}
207
208func Test_checkForSensitiveData_optional_env_file_missing(t *testing.T) {
209 dir := t.TempDir()

Callers

nothing calls this directly

Calls 3

processFileFunction · 0.85
TempDirMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected