Commit e3c2cb4
committed
🧪 [test] Harden cache-directory tests: pre-create macOS/XDG caches and localize env/state
- Pre-create macOS and XDG cache directories in tests so Initialize-CacheDirectory can resolve real candidates.
- Inject test paths into the module scope (InModuleScope -Parameters @{ TestHomePath = ... } / @{ TestXdgPath = ... }) and set HOME via Set-Variable inside the module scope to avoid leaking global HOME.
- Null, clear and restore APPDATA/XDG_CACHE_HOME within module scope; wrap Initialize-CacheDirectory calls in try/finally to guarantee environment restoration.
- Initialize module state (ConfigurationData, ConfigurationInitialized, CacheInitialized, CacheDir, IsWindows/IsMacOS) for deterministic behavior during tests.
- Remove direct env modifications outside InModuleScope and adjust mocks/assertions to use the injected test paths to reduce test pollution and flakiness.
Signed-off-by: Nick2bad4u <20943337+Nick2bad4u@users.noreply.github.com>1 parent 451f3e2 commit e3c2cb4
2 files changed
Lines changed: 43 additions & 17 deletions
Lines changed: 35 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2242 | 2242 | | |
2243 | 2243 | | |
2244 | 2244 | | |
2245 | | - | |
2246 | 2245 | | |
2247 | 2246 | | |
2248 | 2247 | | |
2249 | | - | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
2250 | 2252 | | |
2251 | 2253 | | |
2252 | 2254 | | |
2253 | 2255 | | |
2254 | 2256 | | |
2255 | 2257 | | |
2256 | | - | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
2257 | 2263 | | |
2258 | 2264 | | |
| 2265 | + | |
| 2266 | + | |
2259 | 2267 | | |
2260 | 2268 | | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
2261 | 2272 | | |
2262 | 2273 | | |
2263 | 2274 | | |
2264 | 2275 | | |
2265 | 2276 | | |
2266 | 2277 | | |
2267 | 2278 | | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
2268 | 2282 | | |
2269 | 2283 | | |
2270 | | - | |
2271 | | - | |
2272 | 2284 | | |
2273 | 2285 | | |
2274 | 2286 | | |
2275 | | - | |
2276 | 2287 | | |
2277 | 2288 | | |
2278 | 2289 | | |
2279 | | - | |
| 2290 | + | |
| 2291 | + | |
| 2292 | + | |
| 2293 | + | |
2280 | 2294 | | |
2281 | 2295 | | |
2282 | 2296 | | |
2283 | 2297 | | |
2284 | 2298 | | |
2285 | 2299 | | |
2286 | | - | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
| 2304 | + | |
2287 | 2305 | | |
2288 | 2306 | | |
| 2307 | + | |
| 2308 | + | |
2289 | 2309 | | |
2290 | 2310 | | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
2291 | 2314 | | |
2292 | 2315 | | |
2293 | 2316 | | |
2294 | | - | |
| 2317 | + | |
2295 | 2318 | | |
2296 | 2319 | | |
2297 | 2320 | | |
2298 | 2321 | | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
2299 | 2325 | | |
2300 | 2326 | | |
2301 | | - | |
2302 | | - | |
2303 | 2327 | | |
2304 | 2328 | | |
2305 | 2329 | | |
| |||
Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1184 | 1184 | | |
1185 | 1185 | | |
1186 | 1186 | | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | 1187 | | |
1191 | 1188 | | |
1192 | 1189 | | |
1193 | | - | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1194 | 1198 | | |
1195 | 1199 | | |
1196 | 1200 | | |
1197 | | - | |
1198 | | - | |
1199 | 1201 | | |
1200 | 1202 | | |
1201 | 1203 | | |
| |||
0 commit comments