Description
Multiple unit tests have Set-StrictMode commented out due to uninitialized variable issues. These should be fixed to ensure code quality and catch potential bugs.
Affected Files
MSFT_UpdateServicesCleanup.Tests.ps1
- Line 107-108: Get-TargetResource when server is not configured (Absent scenario)
- Line 145-146: Get-TargetResource when server is configured unexpectedly
MSFT_UpdateServicesServer.Tests.ps1
- Line 89-90: Get-TargetResource -
$ProxyCredentialUserName is not initialized
- Line 126-127: Get-TargetResource (Absent) - variables are not initialized
- Line 183-184: Get-TargetResource (Absent) -
$ProxyCredentialUserName is not initialized
- Line 220-221: Get-TargetResource (Present) - variables are not initialized
- Line 276-277: Get-TargetResource (Present with wildcard products) - variables are not initialized
Required Actions
- Update the DSC resource implementations (MSFT_UpdateServicesCleanup.psm1 and MSFT_UpdateServicesServer.psm1) to properly initialize all variables before use
- Ensure all variables are declared and assigned default values
- Avoid reliance on pipeline-bound parameters or automatic variable population
- Uncomment Set-StrictMode in all affected test blocks
- Verify all tests pass with strict mode enabled
References
Additional Context
These issues were identified during the Pester 5 migration. Enabling strict mode helps catch uninitialized variables and other potential bugs at test time.
Requested by: @dan-hughes
Description
Multiple unit tests have Set-StrictMode commented out due to uninitialized variable issues. These should be fixed to ensure code quality and catch potential bugs.
Affected Files
MSFT_UpdateServicesCleanup.Tests.ps1
MSFT_UpdateServicesServer.Tests.ps1
$ProxyCredentialUserNameis not initialized$ProxyCredentialUserNameis not initializedRequired Actions
References
Additional Context
These issues were identified during the Pester 5 migration. Enabling strict mode helps catch uninitialized variables and other potential bugs at test time.
Requested by: @dan-hughes