Fix TimeZone test with duplicate names#27525
Open
KirtiRamchandani wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the Get-TimeZone tests to ensure -Name returns a single, deterministic match by selecting a time zone with a unique StandardName.
Changes:
- Fixes a typo in the test description (“singe” → “single”).
- Updates the
-Nametest to pick a time zone whoseStandardNamemaps to exactly one entry. - Strengthens assertions by validating both
IdandStandardName.
| Group-Object -Property StandardName | | ||
| Where-Object Count -EQ 1 | | ||
| Select-Object -First 1 -ExpandProperty Group | ||
|
|
Author
There was a problem hiding this comment.
Addressed in a9956a440: the test now skips with a clear reason if the local platform has no available time zone with a unique StandardName, instead of dereferencing $null. Checks run: Start-PSBuild -Configuration Debug -Runtime win7-x64; Start-PSPester -Path test\powershell\Modules\Microsoft.PowerShell.Management\TimeZone.Tests.ps1 (14 passed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Make the
Get-TimeZone -Namesingle-item test choose a timezone with a uniqueStandardName.PR Context
The previous test used the first available timezone's
StandardName. On tzdata sets where that name has aliases,Get-TimeZone -Namecan validly return more than one timezone and the scalar assertion fails. This updates the test to pick aStandardNamethat appears exactly once in the available timezone list, then asserts both the returned ID and standard name.Fixes #27502
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerTests
Start-PSPester -Path ./test/powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1 -UseNuGetOrg -SkipTestToolBuild -ThrowOnFailure(14 passed)git diff --check