Fix macOS preview package identifier detection to use version string (#26690)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
This commit is contained in:
Copilot
2026-01-15 10:40:58 -05:00
committed by GitHub
co-authored by TravisEz13
parent bd33c2d987
commit 5fdc2a023f
2 changed files with 119 additions and 17 deletions
+67
View File
@@ -0,0 +1,67 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe "Packaging Module Functions" {
BeforeAll {
Import-Module $PSScriptRoot/../../build.psm1 -Force
Import-Module $PSScriptRoot/../../tools/packaging/packaging.psm1 -Force
}
Context "Test-IsPreview function" {
It "Should return True for preview versions" {
Test-IsPreview -Version "7.6.0-preview.6" | Should -Be $true
Test-IsPreview -Version "7.5.0-rc.1" | Should -Be $true
}
It "Should return False for stable versions" {
Test-IsPreview -Version "7.6.0" | Should -Be $false
Test-IsPreview -Version "7.5.0" | Should -Be $false
}
It "Should return False for LTS builds regardless of version string" {
Test-IsPreview -Version "7.6.0-preview.6" -IsLTS | Should -Be $false
Test-IsPreview -Version "7.5.0" -IsLTS | Should -Be $false
}
}
Context "Get-MacOSPackageIdentifierInfo function (New-MacOSPackage logic)" {
It "Should detect preview builds and return preview identifier" {
$result = Get-MacOSPackageIdentifierInfo -Version "7.6.0-preview.6" -LTS:$false
$result.IsPreview | Should -Be $true
$result.PackageIdentifier | Should -Be "com.microsoft.powershell-preview"
}
It "Should detect stable builds and return stable identifier" {
$result = Get-MacOSPackageIdentifierInfo -Version "7.6.0" -LTS:$false
$result.IsPreview | Should -Be $false
$result.PackageIdentifier | Should -Be "com.microsoft.powershell"
}
It "Should treat LTS builds as stable even with preview version string" {
$result = Get-MacOSPackageIdentifierInfo -Version "7.4.0-preview.1" -LTS:$true
$result.IsPreview | Should -Be $false
$result.PackageIdentifier | Should -Be "com.microsoft.powershell"
}
It "Should NOT use package name for preview detection (bug fix verification)" {
# 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"
$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'"
# 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"
$result.PackageIdentifier | Should -Be "com.microsoft.powershell-preview"
}
}
}