-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
enhancementThe issue is an enhancement request.The issue is an enhancement request.help wantedThe issue is up for grabs for anyone in the community.The issue is up for grabs for anyone in the community.testsThe issue or pull request is about tests only.The issue or pull request is about tests only.
Description
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 -
$ProxyCredentialUserNameis not initialized - Line 126-127: Get-TargetResource (Absent) - variables are not initialized
- Line 183-184: Get-TargetResource (Absent) -
$ProxyCredentialUserNameis 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
- Related PR: Update tests to Pester 5 #86
- Original comment: Update tests to Pester 5 #86 (comment)
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
Metadata
Metadata
Assignees
Labels
enhancementThe issue is an enhancement request.The issue is an enhancement request.help wantedThe issue is up for grabs for anyone in the community.The issue is up for grabs for anyone in the community.testsThe issue or pull request is about tests only.The issue or pull request is about tests only.