@@ -6,6 +6,7 @@ BeforeAll {
66 . $PSScriptRoot \..\..\..\DevSetup\Private\Utils\Get-DevSetupPath.ps1
77 . $PSScriptRoot \..\..\..\DevSetup\Private\Utils\Test-OperatingSystem.ps1
88 . $PSScriptRoot \..\..\..\DevSetup\Private\Utils\Format-PrettyTable.ps1
9+ . $PSScriptRoot \..\..\..\DevSetup\Private\Utils\Write-StatusMessage.ps1
910 Mock Get-DevSetupPath { " C:\DevSetup" }
1011 Mock Optimize-DevSetupEnvs { }
1112 Mock Write-Host { }
@@ -15,13 +16,14 @@ BeforeAll {
1516 Mock Get-Content { ' [{"name":"EnvWin","version":"1.0","platform":"windows","file":"envwin.yaml"},{"name":"EnvLinux","version":"2.0","platform":"linux","file":"envlinux.yaml"},{"name":"EnvMac","version":"3.0","platform":"macos","file":"envmac.yaml"},{"name":"EnvCross","version":"4.0","platform":"cross-platform","file":"envcross.yaml"},{"name":"EnvUnspec","version":"5.0","file":"envunspec.yaml"}]' }
1617 Mock ConvertFrom-Json {
1718 @ (
18- @ { name = " EnvWin" ; version = " 1.0" ; platform = " windows" ; file = " envwin.yaml" },
19- @ { name = " EnvLinux" ; version = " 2.0" ; platform = " linux" ; file = " envlinux.yaml" },
20- @ { name = " EnvMac" ; version = " 3.0" ; platform = " macos" ; file = " envmac.yaml" },
21- @ { name = " EnvCross" ; version = " 4.0" ; platform = " cross-platform" ; file = " envcross.yaml" },
22- @ { name = " EnvUnspec" ; version = " 5.0" ; file = " envunspec.yaml" }
19+ @ { name = " EnvWin" ; version = " 1.0" ; platform = " windows" ; provider = " local " ; file = " envwin.yaml" },
20+ @ { name = " EnvLinux" ; version = " 2.0" ; platform = " linux" ; provider = " community " ; file = " envlinux.yaml" },
21+ @ { name = " EnvMac" ; version = " 3.0" ; platform = " macos" ; provider = " other " ; file = " envmac.yaml" },
22+ @ { name = " EnvCross" ; version = " 4.0" ; platform = " cross-platform" ; provider = " local " ; file = " envcross.yaml" },
23+ @ { name = " EnvUnspec" ; version = " 5.0" ; provider = " other2 " ; file = " envunspec.yaml" }
2324 )
2425 }
26+ Mock Write-StatusMessage { Param ($Message ) }
2527}
2628
2729Describe " Show-DevSetupEnvList" {
@@ -49,8 +51,8 @@ Describe "Show-DevSetupEnvList" {
4951 Mock Format-PrettyTable { }
5052 Mock Test-OperatingSystem { param ($Windows , $Linux , $MacOS ) if ($Windows ) { $true } else { $false } }
5153 Show-DevSetupEnvList - Platform " current"
52- Assert-MockCalled Write-Host - Scope It - ParameterFilter { $Object -match " Filtering for current platform: windows" }
53- Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It
54+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter { $Message -match " Filtering for platform: windows" }
55+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows .Count -eq 1 }
5456 }
5557 }
5658
@@ -59,8 +61,8 @@ Describe "Show-DevSetupEnvList" {
5961 Mock Format-PrettyTable { }
6062 Mock Test-OperatingSystem { param ($Windows , $Linux , $MacOS ) if ($Linux ) { $true } else { $false } }
6163 Show-DevSetupEnvList - Platform " current"
62- Assert-MockCalled Write-Host - Scope It - ParameterFilter { $Object -match " Filtering for current platform: linux" }
63- Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It
64+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter { $Message -match " Filtering for platform: linux" }
65+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows .Count -eq 1 }
6466 }
6567 }
6668
@@ -69,28 +71,98 @@ Describe "Show-DevSetupEnvList" {
6971 Mock Format-PrettyTable { }
7072 Mock Test-OperatingSystem { param ($Windows , $Linux , $MacOS ) if ($MacOS ) { $true } else { $false } }
7173 Show-DevSetupEnvList - Platform " current"
72- Assert-MockCalled Write-Host - Scope It - ParameterFilter { $Object -match " Filtering for current platform: macos" }
73- Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It
74+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter { $Message -match " Filtering for platform: macos" }
75+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows .Count -eq 1 }
7476 }
7577 }
7678
7779 Context " When filtering for all platforms" {
7880 It " Should show all environments without filtering" {
7981 Mock Format-PrettyTable { }
8082 Show-DevSetupEnvList - Platform " all"
81- Assert-MockCalled Write-Host - Scope It - ParameterFilter { $Object -match " Showing all environments regardless of platform" }
82- Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It
83+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter { $Message -match " Filtering for platform: all " }
84+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows .Count -eq 5 }
8385 }
8486 }
8587
8688 Context " When filtering for specific platform (windows)" {
8789 It " Should filter and display only windows-compatible environments" {
8890 Mock Format-PrettyTable { }
8991 Show-DevSetupEnvList - Platform " windows"
90- Assert-MockCalled Write-Host - Scope It - ParameterFilter { $Object -match " Filtering for platform: windows" }
91- Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It
92+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter { $Message -match " Filtering for platform: windows" }
93+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows.Count -eq 1 }
94+ }
95+ }
96+
97+ Context " When filtering for specific platform (windows) and provider (local)" {
98+ It " Should filter and display only windows-compatible environments from local provider" {
99+ Mock Format-PrettyTable { }
100+ Show-DevSetupEnvList - Platform " windows" - Provider " local"
101+ $script :count = 0 ;
102+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter {
103+ if ($script :count -eq 0 ) { $Message -match " Filtering for platform: windows" }
104+ if ($script :count -eq 1 ) { $Message -match " , provider: local" }
105+ $script :count ++ ;
106+ } - Times 2
107+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows.Count -eq 1 }
92108 }
93109 }
110+
111+ Context " When filtering for specific platform (windows) and provider (community)" {
112+ It " Should filter and display only windows-compatible environments from community provider" {
113+ Mock Format-PrettyTable { }
114+ Show-DevSetupEnvList - Platform " windows" - Provider " community"
115+ $script :count = 0 ;
116+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter {
117+ if ($script :count -eq 0 ) { $Message -match " Filtering for platform: windows" }
118+ if ($script :count -eq 1 ) { $Message -match " , provider: community" }
119+ $script :count ++ ;
120+ } - Times 2
121+ Assert-MockCalled Format-PrettyTable - Exactly 0 - Scope It - ParameterFilter { $Rows.Count -eq 0 }
122+ }
123+ }
124+
125+ Context " When filtering for specific platform (linux) and provider (community)" {
126+ It " Should filter and display only linux-compatible environments from community provider" {
127+ Mock Format-PrettyTable { }
128+ Show-DevSetupEnvList - Platform " linux" - Provider " community"
129+ $script :count = 0 ;
130+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter {
131+ if ($script :count -eq 0 ) { $Message -match " Filtering for platform: linux" }
132+ if ($script :count -eq 1 ) { $Message -match " , provider: community" }
133+ $script :count ++ ;
134+ } - Times 2
135+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows.Count -eq 1 }
136+ }
137+ }
138+
139+ Context " When filtering for specific platform (macos) and provider (other)" {
140+ It " Should filter and display only macos-compatible environments from other provider" {
141+ Mock Format-PrettyTable { }
142+ Show-DevSetupEnvList - Platform " macos" - Provider " other"
143+ $script :count = 0 ;
144+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter {
145+ if ($script :count -eq 0 ) { $Message -match " Filtering for platform: macos" }
146+ if ($script :count -eq 1 ) { $Message -match " , provider: other" }
147+ $script :count ++ ;
148+ } - Times 2
149+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows.Count -eq 1 }
150+ }
151+ }
152+
153+ Context " When filtering for specific platform (all) and provider (local)" {
154+ It " Should filter and display all environment from local provider" {
155+ Mock Format-PrettyTable { }
156+ Show-DevSetupEnvList - Platform " all" - Provider " local"
157+ $script :count = 0 ;
158+ Assert-MockCalled Write-StatusMessage - Scope It - ParameterFilter {
159+ if ($script :count -eq 0 ) { $Message -match " Filtering for platform: all" }
160+ if ($script :count -eq 1 ) { $Message -match " , provider: local" }
161+ $script :count ++ ;
162+ } - Times 2
163+ Assert-MockCalled Format-PrettyTable - Exactly 1 - Scope It - ParameterFilter { $Rows.Count -eq 2 }
164+ }
165+ }
94166
95167 Context " When no environments are found for a platform" {
96168 It " Should display guidance message" {
0 commit comments