44# no progress output during these tests
55$ProgressPreference = " SilentlyContinue"
66
7- $RepositoryName = ' INTGallery'
8- $SourceLocation = ' https://www.poshtestgallery.com'
9- $RegisteredINTRepo = $false
10- $ContosoServer = ' ContosoServer'
11- $FabrikamServerScript = ' Fabrikam-ServerScript'
7+ $RepositoryName = ' PSGallery'
8+ $SourceLocation = ' https://www.powershellgallery.com'
9+ $TestModule = ' newTestModule'
10+ $TestScript = ' TestTestScript'
1211$Initialized = $false
1312
1413# region Utility functions
@@ -93,30 +92,24 @@ function Initialize
9392 if ($repo )
9493 {
9594 $script :RepositoryName = $repo.Name
95+ Set-PackageSource - Name $repo.Name - Trusted
9696 }
9797 else
9898 {
9999 Register-PSRepository - Name $RepositoryName - SourceLocation $SourceLocation - InstallationPolicy Trusted
100- $script :RegisteredINTRepo = $true
101100 }
102101}
103102
104103# endregion
105104
106105function Remove-InstalledModules
107106{
108- Get-InstalledModule - Name $ContosoServer - AllVersions - ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module - Force
107+ Get-InstalledModule - Name $TestModule - AllVersions - ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module - Force
109108}
110109
111110Describe " PowerShellGet - Module tests" - tags " Feature" {
112111
113112 BeforeAll {
114- # Setting all It block to pending as the test fail due to https://github.com/PowerShell/PowerShell/issues/17019
115- # These should be re-enabled when the issue is fixed
116- $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
117- $PSDefaultParameterValues [" it:pending" ] = $true
118- return
119-
120113 if ($script :Initialized -eq $false ) {
121114 Initialize
122115 $script :Initialized = $true
@@ -128,39 +121,32 @@ Describe "PowerShellGet - Module tests" -tags "Feature" {
128121 }
129122
130123 It " Should find a module correctly" {
131- $psgetModuleInfo = Find-Module - Name $ContosoServer - Repository $RepositoryName
132- $psgetModuleInfo.Name | Should - Be $ContosoServer
124+ $psgetModuleInfo = Find-Module - Name $TestModule - Repository $RepositoryName
125+ $psgetModuleInfo.Name | Should - Be $TestModule
133126 $psgetModuleInfo.Repository | Should - Be $RepositoryName
134127 }
135128
136129 It " Should install a module correctly to the required location with default CurrentUser scope" {
137- Install-Module - Name $ContosoServer - Repository $RepositoryName
138- $installedModuleInfo = Get-InstalledModule - Name $ContosoServer
130+ Install-Module - Name $TestModule - Repository $RepositoryName
131+ $installedModuleInfo = Get-InstalledModule - Name $TestModule
139132
140133 $installedModuleInfo | Should -Not - BeNullOrEmpty
141- $installedModuleInfo.Name | Should - Be $ContosoServer
134+ $installedModuleInfo.Name | Should - Be $TestModule
142135 $installedModuleInfo.InstalledLocation.StartsWith ($script :MyDocumentsModulesPath , [System.StringComparison ]::OrdinalIgnoreCase) | Should - BeTrue
143136
144- $module = Get-Module $ContosoServer - ListAvailable
145- $module.Name | Should - Be $ContosoServer
137+ $module = Get-Module $TestModule - ListAvailable
138+ $module.Name | Should - Be $TestModule
146139 $module.ModuleBase | Should - Be $installedModuleInfo.InstalledLocation
147140 }
148141
149142 AfterAll {
150- $global :PSDefaultParameterValues = $originalDefaultParameterValues
151143 Remove-InstalledModules
152144 }
153145}
154146
155147Describe " PowerShellGet - Module tests (Admin)" - Tags @ (' Feature' , ' RequireAdminOnWindows' , ' RequireSudoOnUnix' ) {
156148
157149 BeforeAll {
158- # Setting all It block to pending as the test fail due to https://github.com/PowerShell/PowerShell/issues/17019
159- # These should be re-enabled when the issue is fixed
160- $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
161- $PSDefaultParameterValues [" it:pending" ] = $true
162- return
163-
164150 if ($script :Initialized -eq $false ) {
165151 Initialize
166152 $script :Initialized = $true
@@ -172,38 +158,31 @@ Describe "PowerShellGet - Module tests (Admin)" -Tags @('Feature', 'RequireAdmin
172158 }
173159
174160 It " Should install a module correctly to the required location with AllUsers scope" {
175- Install-Module - Name $ContosoServer - Repository $RepositoryName - Scope AllUsers
176- $installedModuleInfo = Get-InstalledModule - Name $ContosoServer
161+ Install-Module - Name $TestModule - Repository $RepositoryName - Scope AllUsers
162+ $installedModuleInfo = Get-InstalledModule - Name $TestModule
177163
178164 $installedModuleInfo | Should -Not - BeNullOrEmpty
179- $installedModuleInfo.Name | Should - Be $ContosoServer
165+ $installedModuleInfo.Name | Should - Be $TestModule
180166 $installedModuleInfo.InstalledLocation.StartsWith ($script :programFilesModulesPath , [System.StringComparison ]::OrdinalIgnoreCase) | Should - BeTrue
181167
182- $module = Get-Module $ContosoServer - ListAvailable
183- $module.Name | Should - Be $ContosoServer
168+ $module = Get-Module $TestModule - ListAvailable
169+ $module.Name | Should - Be $TestModule
184170 $module.ModuleBase | Should - Be $installedModuleInfo.InstalledLocation
185171 }
186172
187173 AfterAll {
188- $global :PSDefaultParameterValues = $originalDefaultParameterValues
189174 Remove-InstalledModules
190175 }
191176}
192177
193178function Remove-InstalledScripts
194179{
195- Get-InstalledScript - Name $FabrikamServerScript - ErrorAction SilentlyContinue | Uninstall-Script - Force
180+ Get-InstalledScript - Name $TestScript - ErrorAction SilentlyContinue | Uninstall-Script - Force
196181}
197182
198183Describe " PowerShellGet - Script tests" - tags " Feature" {
199184
200185 BeforeAll {
201- # Setting all It block to pending as the test fail due to https://github.com/PowerShell/PowerShell/issues/17019
202- # These should be re-enabled when the issue is fixed
203- $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
204- $PSDefaultParameterValues [" it:pending" ] = $true
205- return
206-
207186 if ($script :Initialized -eq $false ) {
208187 Initialize
209188 $script :Initialized = $true
@@ -215,35 +194,28 @@ Describe "PowerShellGet - Script tests" -tags "Feature" {
215194 }
216195
217196 It " Should find a script correctly" {
218- $psgetScriptInfo = Find-Script - Name $FabrikamServerScript - Repository $RepositoryName
219- $psgetScriptInfo.Name | Should - Be $FabrikamServerScript
197+ $psgetScriptInfo = Find-Script - Name $TestScript - Repository $RepositoryName
198+ $psgetScriptInfo.Name | Should - Be $TestScript
220199 $psgetScriptInfo.Repository | Should - Be $RepositoryName
221200 }
222201
223202 It " Should install a script correctly to the required location with default CurrentUser scope" {
224- Install-Script - Name $FabrikamServerScript - Repository $RepositoryName - NoPathUpdate
225- $installedScriptInfo = Get-InstalledScript - Name $FabrikamServerScript
203+ Install-Script - Name $TestScript - Repository $RepositoryName - NoPathUpdate
204+ $installedScriptInfo = Get-InstalledScript - Name $TestScript
226205
227206 $installedScriptInfo | Should -Not - BeNullOrEmpty
228- $installedScriptInfo.Name | Should - Be $FabrikamServerScript
207+ $installedScriptInfo.Name | Should - Be $TestScript
229208 $installedScriptInfo.InstalledLocation.StartsWith ($script :MyDocumentsScriptsPath , [System.StringComparison ]::OrdinalIgnoreCase) | Should - BeTrue
230209 }
231210
232211 AfterAll {
233- $global :PSDefaultParameterValues = $originalDefaultParameterValues
234212 Remove-InstalledScripts
235213 }
236214}
237215
238216Describe " PowerShellGet - Script tests (Admin)" - Tags @ (' Feature' , ' RequireAdminOnWindows' , ' RequireSudoOnUnix' ) {
239217
240218 BeforeAll {
241- # Setting all It block to pending as the test fail due to https://github.com/PowerShell/PowerShell/issues/17019
242- # These should be re-enabled when the issue is fixed
243- $originalDefaultParameterValues = $PSDefaultParameterValues.Clone ()
244- $PSDefaultParameterValues [" it:pending" ] = $true
245- return
246-
247219 if ($script :Initialized -eq $false ) {
248220 Initialize
249221 $script :Initialized = $true
@@ -255,16 +227,15 @@ Describe "PowerShellGet - Script tests (Admin)" -Tags @('Feature', 'RequireAdmin
255227 }
256228
257229 It " Should install a script correctly to the required location with AllUsers scope" {
258- Install-Script - Name $FabrikamServerScript - Repository $RepositoryName - NoPathUpdate - Scope AllUsers
259- $installedScriptInfo = Get-InstalledScript - Name $FabrikamServerScript
230+ Install-Script - Name $TestScript - Repository $RepositoryName - NoPathUpdate - Scope AllUsers
231+ $installedScriptInfo = Get-InstalledScript - Name $TestScript
260232
261233 $installedScriptInfo | Should -Not - BeNullOrEmpty
262- $installedScriptInfo.Name | Should - Be $FabrikamServerScript
234+ $installedScriptInfo.Name | Should - Be $TestScript
263235 $installedScriptInfo.InstalledLocation.StartsWith ($script :ProgramFilesScriptsPath , [System.StringComparison ]::OrdinalIgnoreCase) | Should - BeTrue
264236 }
265237
266238 AfterAll {
267- $global :PSDefaultParameterValues = $originalDefaultParameterValues
268239 Remove-InstalledScripts
269240 }
270241}
@@ -300,8 +271,3 @@ Describe 'PowerShellGet Type tests' -tags @('CI') {
300271 }
301272 }
302273}
303-
304- if ($RegisteredINTRepo )
305- {
306- Get-PSRepository - Name $RepositoryName - ErrorAction SilentlyContinue | Unregister-PSRepository
307- }
0 commit comments