(t *testing.T)
| 176 | } |
| 177 | |
| 178 | func 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 |
| 185 | services: |
| 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 | |
| 208 | func Test_checkForSensitiveData_optional_env_file_missing(t *testing.T) { |
| 209 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected