Skip to content

Fix TimeZone test with duplicate names#27525

Open
KirtiRamchandani wants to merge 2 commits into
PowerShell:masterfrom
KirtiRamchandani:fix/timezone-name-alias-test
Open

Fix TimeZone test with duplicate names#27525
KirtiRamchandani wants to merge 2 commits into
PowerShell:masterfrom
KirtiRamchandani:fix/timezone-name-alias-test

Conversation

@KirtiRamchandani
Copy link
Copy Markdown

PR Summary

Make the Get-TimeZone -Name single-item test choose a timezone with a unique StandardName.

PR Context

The previous test used the first available timezone's StandardName. On tzdata sets where that name has aliases, Get-TimeZone -Name can validly return more than one timezone and the scalar assertion fails. This updates the test to pick a StandardName that appears exactly once in the available timezone list, then asserts both the returned ID and standard name.

Fixes #27502

PR Checklist

Tests

  • Start-PSPester -Path ./test/powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1 -UseNuGetOrg -SkipTestToolBuild -ThrowOnFailure (14 passed)
  • git diff --check

Copilot AI review requested due to automatic review settings May 25, 2026 01:17
@KirtiRamchandani KirtiRamchandani requested a review from a team as a code owner May 25, 2026 01:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -Name test to pick a time zone whose StandardName maps to exactly one entry.
  • Strengthens assertions by validating both Id and StandardName.

Group-Object -Property StandardName |
Where-Object Count -EQ 1 |
Select-Object -First 1 -ExpandProperty Group

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TimeZone.Tests can break due to timezone aliases

2 participants