11# Copyright (c) Microsoft Corporation. All rights reserved.
22# Licensed under the MIT License.
33
4- Describe " Get-Module" - Tags " CI" {
4+ Describe " Get-Module -ListAvailable " - Tags " CI" {
55
66 BeforeAll {
77 $originalPSModulePath = $env: PSModulePath
@@ -13,8 +13,8 @@ Describe "Get-Module" -Tags "CI" {
1313
1414 New-ModuleManifest - Path " $testdrive \Modules\Foo\1.1\Foo.psd1" - ModuleVersion 1.1
1515 New-ModuleManifest - Path " $testdrive \Modules\Foo\2.0\Foo.psd1" - ModuleVersion 2.0
16- New-ModuleManifest - Path " $testdrive \Modules\Bar\Bar.psd1" - CompatiblePSEditions Desktop
17- New-ModuleManifest - Path " $testdrive \Modules\Zoo\Zoo.psd1" - CompatiblePSEditions Core
16+ New-ModuleManifest - Path " $testdrive \Modules\Bar\Bar.psd1"
17+ New-ModuleManifest - Path " $testdrive \Modules\Zoo\Zoo.psd1"
1818
1919 New-Item - ItemType File - Path " $testdrive \Modules\Foo\1.1\Foo.psm1" > $null
2020 New-Item - ItemType File - Path " $testdrive \Modules\Foo\2.0\Foo.psm1" > $null
@@ -108,27 +108,44 @@ Describe "Get-Module" -Tags "CI" {
108108 $modules.Version | Should - Be " 2.0"
109109 }
110110
111- It " Get-Module -PSEdition <PSEdition> -ListAvailable" {
112- $modules = Get-Module - PSEdition ' Desktop' - ListAvailable
113- $modules | Should - HaveCount 1
114- $modules.Name | Should - BeExactly " Bar"
115-
116- $modules = Get-Module - PSEdition ' Core' - ListAvailable
117- $modules | Should - HaveCount 1
118- $modules.Name | Should - BeExactly " Zoo"
119- }
120-
121111 It " Get-Module <Name> -Refresh -ListAvailable" {
122112 $modules = Get-Module - Name ' Zoo' - ListAvailable
123113 $modules | Should - HaveCount 1
124114 $modules.Name | Should - BeExactly " Zoo"
125115 $modules.ExportedFunctions.Count | Should - Be 0 - Because ' No exports were defined'
126116
127- New-ModuleManifest - Path " $testdrive \Modules\Zoo\Zoo.psd1" - CompatiblePSEditions Core - FunctionsToExport ' Test-ZooFunction'
117+ New-ModuleManifest - Path " $testdrive \Modules\Zoo\Zoo.psd1" - FunctionsToExport ' Test-ZooFunction'
128118
129119 $modules = Get-Module - Name ' Zoo' - ListAvailable - Refresh
130120 $modules | Should - HaveCount 1
131121 $modules.Name | Should - BeExactly " Zoo"
132122 $modules.ExportedFunctions.Count | Should - Be 1 - Because ' We added a new function to export'
133123 }
124+
125+ Context " PSEdition" {
126+
127+ BeforeAll {
128+ New-Item - ItemType Directory - Path " $testdrive \Modules\DesktopOnlyModule" - Force > $null
129+ New-Item - ItemType Directory - Path " $testdrive \Modules\CoreOnlyModule" - Force > $null
130+ New-Item - ItemType Directory - Path " $testdrive \Modules\CoreAndDesktopModule" - Force > $null
131+
132+ New-ModuleManifest - Path " $testdrive \Modules\DesktopOnlyModule\DesktopOnlyModule.psd1" - CompatiblePSEditions Desktop
133+ New-ModuleManifest - Path " $testdrive \Modules\CoreOnlyModule\CoreOnlyModule.psd1" - CompatiblePSEditions Core
134+ New-ModuleManifest - Path " $testdrive \Modules\CoreAndDesktopModule\CoreAndDesktopModule.psd1" - CompatiblePSEditions Core, Desktop
135+
136+ New-Item - ItemType File - Path " $testdrive \Modules\DesktopOnlyModule\DesktopOnlyModule.psm1" > $null
137+ New-Item - ItemType File - Path " $testdrive \Modules\CoreOnlyModule\CoreOnlyModule.psm1" > $null
138+ New-Item - ItemType File - Path " $testdrive \Modules\CoreAndDesktopModule\CoreAndDesktopModule.psm1" > $null
139+ }
140+
141+ It " Get-Module -PSEdition <CompatiblePSEditions> -ListAvailable" - TestCases @ (
142+ @ { CompatiblePSEditions = ' Desktop' ; ExpectedModule = ' CoreAndDesktopModule' , ' DesktopOnlyModule' },
143+ @ { CompatiblePSEditions = ' Core' ; ExpectedModule = ' CoreAndDesktopModule' , ' CoreOnlyModule' }
144+ ) {
145+ param ($CompatiblePSEditions , $ExpectedModule )
146+ $modules = Get-Module - PSEdition $CompatiblePSEditions - ListAvailable
147+ $modules | Should - HaveCount $ExpectedModule.Count
148+ $modules.Name | Sort-Object | Should - Be $ExpectedModule
149+ }
150+ }
134151}
0 commit comments