Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 1.36 KB

File metadata and controls

23 lines (18 loc) · 1.36 KB

← Back to Backlog

[REFACT-004] ✅ DONE - Remove redundant Test-WslInstalled guard checks (DRY)

Status: Done (2026-02-24) Priority: Medium Component: tools/pslib/wsl/ (8 source files, 8 test files)

Description: Removed 32 redundant Test-WslInstalled guard blocks from 8 source files and ~250 Mock Test-WslInstalled { $true } boilerplate lines from 8 test files. WSL 2 availability is now validated once at the Invoke-WslManager entry point via a new Assert-Wsl2Installed function. This also upgraded the check from WSL 1 detection to WSL 2 detection (wsl --version only exists in the WSL 2 store app).

Acceptance Criteria:

  • New Assert-Wsl2Installed function that throws if WSL 2 is not installed
  • Invoke-WslManager calls the assertion once before dispatching
  • All 32 if (-not (Test-WslInstalled)) guard blocks removed from individual functions
  • 23 "When WSL is not installed" test contexts deleted from test files
  • ~250 Mock Test-WslInstalled { $true } lines removed from remaining test contexts
  • Mocks preserved in Test-WslInstalled and Assert-Wsl2Installed test describes
  • Test-WslInstalled (the boolean check) remains available for non-throwing use cases
  • All tests pass (27 redundant guard tests removed)
  • No change in user-facing behavior

← Back to Backlog