Skip to content

TimeZone.Tests can break due to timezone aliases #27502

@ChrisTX

Description

@ChrisTX

Prerequisites

Steps to reproduce

Affected version: All up to 7.6.2

The test Call Get-TimeZone using Name param and singe item found here has a logic error that can cause it break: Timezones can have aliases.

Specifically, the issue is that on my Linux machine with current tzdata 2026b, that the first time zone in the list is American Samoa Standard Time. This however exists in two forms, Pacific/Midway and Pacific/Pago_Pago - display names are (UTC-11:00) American Samoa Standard Time (Midway Atoll) and (UTC-11:00) American Samoa Standard Time (Pago Pago), but their standard name is just American Samoa Standard Time for both. Therefore, the selection here can return an array instead of a single entry, breaking the test.

P.S. Yes, single is also misspelled as singe in the test here. That would need a correction as well.

Expected behavior

No error.

Actual behavior

[-] Call Get-TimeZone using Name param and singe item 396ms
      Expected 'American Samoa Standard Time', but got @('American Samoa Standard Time', 'American Samoa Standard Time').
      104:         $observed.StandardName | Should -Be $timezoneName
      at <ScriptBlock>, /home/aurutils/.cache/aurutils/sync/powershell/src/PowerShell/test/powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1: line 104

Error details

Environment data

Name                           Value
----                           -----
PSVersion                      7.6.2
PSEdition                      Core
GitCommitId                    7.6.2-0-g0d3c290a8737d4252ee75c052d16190ffcdb7d19
OS                             Arch Linux
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.4
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions