Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions test/packaging/packaging.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,15 @@ Describe "Packaging Module Functions" {
$result.PackageIdentifier | Should -Be "com.microsoft.powershell"
}

It "Should NOT use package name for preview detection (bug fix verification)" {
It "Should NOT use package name for preview detection (bug fix verification) - <Name>" -TestCases @(
@{ Version = "7.6.0-preview.6"; Name = "Preview" }
@{ Version = "7.6.0-rc.1"; Name = "RC" }
) {
# This test verifies the fix for issue #26673
# The bug was using ($Name -like '*-preview') which always returned false
# because preview builds use Name="powershell" not "powershell-preview"
Comment on lines +49 to 55
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

The test name/comment says it verifies that preview detection does not use the package name, but the updated test cases use Name = "Preview"/"RC" only as a label and no longer demonstrate the failing package-name-based logic described in the comments. Either update the test description/comments to match what is actually being asserted (preview detection from version string), or reintroduce an assertion that shows the package-name check would fail (using a realistic package name like "powershell").

Suggested change
It "Should NOT use package name for preview detection (bug fix verification) - <Name>" -TestCases @(
@{ Version = "7.6.0-preview.6"; Name = "Preview" }
@{ Version = "7.6.0-rc.1"; Name = "RC" }
) {
# This test verifies the fix for issue #26673
# The bug was using ($Name -like '*-preview') which always returned false
# because preview builds use Name="powershell" not "powershell-preview"
It "Should detect preview builds based on version string (bug fix verification) - <Name>" -TestCases @(
@{ Version = "7.6.0-preview.6"; Name = "Preview" }
@{ Version = "7.6.0-rc.1"; Name = "RC" }
) {
# This test verifies the fix for issue #26673.
# The fix ensures preview detection relies on the version string (e.g. '-preview', '-rc')
# rather than any package name convention.

Copilot uses AI. Check for mistakes.

$Version = "7.6.0-preview.6"
$Name = "powershell" # Preview builds use "powershell" not "powershell-preview"

# The INCORRECT logic (the bug): $Name -like '*-preview'
$incorrectCheck = $Name -like '*-preview'
$incorrectCheck | Should -Be $false -Because "Package name is 'powershell' not 'powershell-preview'"

param($Version)
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

This It block defines param($Version) but the -TestCases hashtables also include a Name key. Pester passes test-case keys as named arguments to the scriptblock, so the extra Name entry will cause a parameter binding error. Add $Name to the param block (even if unused) or remove the Name key from the test cases / title placeholder.

Suggested change
param($Version)
param($Version, $Name)

Copilot uses AI. Check for mistakes.

# The CORRECT logic (the fix): uses version string
$result = Get-MacOSPackageIdentifierInfo -Version $Version -LTS:$false
$result.IsPreview | Should -Be $true -Because "Version string correctly identifies preview"
Expand Down
Loading