MegaBites-AI/Windows-powershell
0372
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3 4Describe "Packaging Module Functions" {5 BeforeAll {6 Import-Module $PSScriptRoot/../../build.psm1 -Force7 Import-Module $PSScriptRoot/../../tools/packaging/packaging.psm1 -Force8 }9 10 Context "Test-IsPreview function" {11 It "Should return True for preview versions" {12 Test-IsPreview -Version "7.6.0-preview.6" | Should -Be $true13 Test-IsPreview -Version "7.5.0-rc.1" | Should -Be $true14 }15 16 It "Should return False for stable versions" {17 Test-IsPreview -Version "7.6.0" | Should -Be $false18 Test-IsPreview -Version "7.5.0" | Should -Be $false19 }20 21 It "Should return False for LTS builds regardless of version string" {22 Test-IsPreview -Version "7.6.0-preview.6" -IsLTS | Should -Be $false23 Test-IsPreview -Version "7.5.0" -IsLTS | Should -Be $false24 }25 }26 27 Context "Get-MacOSPackageIdentifierInfo function (New-MacOSPackage logic)" {28 It "Should detect preview builds and return preview identifier" {29 $result = Get-MacOSPackageIdentifierInfo -Version "7.6.0-preview.6" -LTS:$false30 31 $result.IsPreview | Should -Be $true32 $result.PackageIdentifier | Should -Be "com.microsoft.powershell-preview"33 }34 35 It "Should detect stable builds and return stable identifier" {36 $result = Get-MacOSPackageIdentifierInfo -Version "7.6.0" -LTS:$false37 38 $result.IsPreview | Should -Be $false39 $result.PackageIdentifier | Should -Be "com.microsoft.powershell"40 }41 42 It "Should treat LTS builds as stable even with preview version string" {43 $result = Get-MacOSPackageIdentifierInfo -Version "7.4.0-preview.1" -LTS:$true44 45 $result.IsPreview | Should -Be $false46 $result.PackageIdentifier | Should -Be "com.microsoft.powershell"47 }48 49 It "Should NOT use package name for preview detection (bug fix verification) - <Name>" -TestCases @(50 @{ Version = "7.6.0-preview.6"; Name = "Preview" }51 @{ Version = "7.6.0-rc.1"; Name = "RC" }52 ) {53 # This test verifies the fix for issue #2667354 # The bug was using ($Name -like '*-preview') which always returned false55 # because preview builds use Name="powershell" not "powershell-preview"56 param($Version)57 58 # The CORRECT logic (the fix): uses version string59 $result = Get-MacOSPackageIdentifierInfo -Version $Version -LTS:$false60 $result.IsPreview | Should -Be $true -Because "Version string correctly identifies preview"61 $result.PackageIdentifier | Should -Be "com.microsoft.powershell-preview"62 }63 }64}65 