18
18
function SuiteSetup {
19
19
Import-Module " $PSScriptRoot \PSGetTestUtils.psm1" - WarningAction SilentlyContinue
20
20
Import-Module " $PSScriptRoot \Asserts.psm1" - WarningAction SilentlyContinue
21
-
21
+
22
22
$script :ProgramFilesModulesPath = Get-AllUsersModulesPath
23
23
$script :MyDocumentsModulesPath = Get-CurrentUserModulesPath
24
24
$script :PSGetLocalAppDataPath = Get-PSGetLocalAppDataPath
@@ -84,7 +84,7 @@ function SuiteCleanup {
84
84
RemoveItem $script :TempModulesPath
85
85
}
86
86
87
- Describe PowerShell.PSGet.ModuleSourceTests - Tags ' BVT' , ' InnerLoop' {
87
+ Describe PowerShell.PSGet.ModuleSourceTests - Tags ' BVT' , ' InnerLoop' {
88
88
89
89
BeforeAll {
90
90
SuiteSetup
@@ -103,11 +103,11 @@ Describe PowerShell.PSGet.ModuleSourceTests -Tags 'BVT','InnerLoop' {
103
103
#>
104
104
It RegisterAngGetModuleSource {
105
105
106
- $Name = ' MyTestModSourceForRegisterAngGet'
107
- $Location = ' https://www.nuget.org/api/v2/'
106
+ $Name = ' MyTestModSourceForRegisterAngGet'
107
+ $Location = ' https://www.nuget.org/api/v2/'
108
108
109
109
Register-PSRepository - Default - ErrorAction SilentlyContinue
110
-
110
+
111
111
try {
112
112
Register-PSRepository - Name $Name - SourceLocation $Location
113
113
$moduleSource = Get-PSRepository - Name $Name
@@ -137,19 +137,17 @@ Describe PowerShell.PSGet.ModuleSourceTests -Tags 'BVT','InnerLoop' {
137
137
#>
138
138
It RegisterSMBShareRepository {
139
139
140
- $Name = ' MyTestModSource'
141
- $Location = $script :TempModulesPath
142
- try
143
- {
140
+ $Name = ' MyTestModSource'
141
+ $Location = $script :TempModulesPath
142
+ try {
144
143
Register-PSRepository - Name $Name - SourceLocation $Location - PublishLocation $Location
145
144
$repo = Get-PSRepository - Name $Name
146
145
147
146
AssertEquals $repo.Name $Name " The repository name is not same as the registered name. Actual: $ ( $repo.Name ) , Expected: $Name "
148
147
AssertEquals $repo.SourceLocation $Location " The SourceLocation is not same as the registered SourceLocation. Actual: $ ( $repo.SourceLocation ) , Expected: $Location "
149
148
AssertEquals $repo.PublishLocation $Location " The PublishLocation is not same as the registered PublishLocation. Actual: $ ( $repo.PublishLocation ) , Expected: $Location "
150
149
}
151
- finally
152
- {
150
+ finally {
153
151
Get-PSRepository - Name $Name | Unregister-PSRepository
154
152
}
155
153
}
@@ -163,10 +161,9 @@ Describe PowerShell.PSGet.ModuleSourceTests -Tags 'BVT','InnerLoop' {
163
161
#>
164
162
It SetPSRepositoryWithSMBSharePath {
165
163
166
- $Name = ' MyTestModSource'
167
- $Location = $script :TempModulesPath
168
- try
169
- {
164
+ $Name = ' MyTestModSource'
165
+ $Location = $script :TempModulesPath
166
+ try {
170
167
Register-PSRepository - Name $Name - SourceLocation $Location
171
168
Set-PSRepository - Name $Name - SourceLocation $Location - PublishLocation $Location
172
169
$repo = Get-PSRepository - Name $Name
@@ -175,8 +172,7 @@ Describe PowerShell.PSGet.ModuleSourceTests -Tags 'BVT','InnerLoop' {
175
172
AssertEquals $repo.SourceLocation $Location " The SourceLocation is not same as the registered SourceLocation. Actual: $ ( $repo.SourceLocation ) , Expected: $Location "
176
173
AssertEquals $repo.PublishLocation $Location " The PublishLocation is not same as the registered PublishLocation. Actual: $ ( $repo.PublishLocation ) , Expected: $Location "
177
174
}
178
- finally
179
- {
175
+ finally {
180
176
Get-PSRepository - Name $Name | Unregister-PSRepository
181
177
}
182
178
}
@@ -190,200 +186,18 @@ Describe PowerShell.PSGet.ModuleSourceTests -Tags 'BVT','InnerLoop' {
190
186
#>
191
187
It UnregisterModuleSource {
192
188
193
- $Name = ' MyTestModSource'
194
- $Location = ' https://www.nuget.org/api/v2/'
189
+ $Name = ' MyTestModSource'
190
+ $Location = ' https://www.nuget.org/api/v2/'
195
191
196
192
Register-PSRepository - Name $Name - SourceLocation $Location
197
193
Unregister-PSRepository - Name $Name
198
194
199
195
$expectedFullyQualifiedErrorId = ' SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource'
200
196
201
197
AssertFullyQualifiedErrorIdEquals - scriptblock {Get-PSRepository - Name $Name } `
202
- - expectedFullyQualifiedErrorId $expectedFullyQualifiedErrorId
203
- }
204
-
205
- <#
206
- Purpose: Test Check-PSGalleryApiAvailability and Get-PSGalleryApiAvailability cmdlet for Stage 1 of PSGallery V2/V3 Transition.
207
-
208
- Action: Check-PSGalleryApiAvailability -PSGalleryV2ApiUri $Uri200Ok -PSGalleryV3ApiUri $Uri404NotFound
209
- Get-PSGalleryApiAvailability -Repository PSGallery
210
-
211
- Expected Result: Should show and do nothing.
212
- #>
213
- It CheckGetPSGalleryApiAvailabilityStage1 {
214
-
215
- $result = & $script :PowerShellGetModuleInfo Check- PSGalleryApiAvailability - PSGalleryV2ApiUri $script :Uri200Ok - PSGalleryV3ApiUri $script :Uri404NotFound
216
- AssertNull $result " Check-PSGalleryApiAvailability Stage 1 should not return anything."
217
-
218
- $err = $null
219
- try
220
- {
221
- $result = & $script :PowerShellGetModuleInfo Get-PSGalleryApiAvailability - Repository " PSGallery" - WarningVariable w
222
- }
223
- catch
224
- {
225
- $err = $_
226
- }
227
-
228
- AssertNull $result " Get-PSGalleryApiAvailability Stage 1 should not return anything."
229
- AssertEquals 0 $w.Count " Get-PSGalleryApiAvailability Stage 1 should not write a warning."
230
- AssertNull $err " Get-PSGalleryApiAvailability Stage 1 should not throw an error message."
231
- }
232
-
233
- <#
234
- Purpose: Test Check-PSGalleryApiAvailability and Get-PSGalleryApiAvailability cmdlet for Stage 2 of PSGallery V2/V3 Transition.
235
-
236
- Action: Check-PSGalleryApiAvailability -PSGalleryV2ApiUri $Uri200Ok -PSGalleryV3ApiUri $Uri200Ok
237
- Get-PSGalleryApiAvailability -Repository PSGallery
238
-
239
- Expected Result: Should display a warning.
240
- #>
241
- It CheckGetPSGalleryApiAvailabilityStage2 {
242
-
243
- try {
244
- $result = & $script :PowerShellGetModuleInfo Check- PSGalleryApiAvailability - PSGalleryV2ApiUri $script :Uri200Ok - PSGalleryV3ApiUri $script :Uri200Ok
245
- AssertNull $result " Check-PSGalleryApiAvailability Stage 2 should not return anything."
246
-
247
- $err = $null
248
- try
249
- {
250
- $result = & $script :PowerShellGetModuleInfo Get-PSGalleryApiAvailability - Repository " PSGallery" - WarningVariable w - WarningAction SilentlyContinue
251
- }
252
- catch
253
- {
254
- $err = $_
255
- }
256
-
257
- AssertNull $result " Get-PSGalleryApiAvailability Stage 2 should not return anything."
258
- AssertNotEquals 0 $w.Count " Get-PSGalleryApiAvailability Stage 2 should write a warning."
259
- # AssertEqualsCaseInsensitive $script:LocalizedData.PSGalleryApiV2Deprecated $w[0].Message "Get-PSGalleryApiAvailability Stage 2 wrote the wrong warning message."
260
- AssertNull $err " Get-PSGalleryApiAvailability Stage 2 should not throw an error message."
261
- }
262
- finally {
263
- # Set API availability for v2 back to true (no warnings or errors thrown)
264
- $result = & $script :PowerShellGetModuleInfo Check- PSGalleryApiAvailability - PSGalleryV2ApiUri $script :Uri200Ok - PSGalleryV3ApiUri $script :URI404NotFound
265
- }
266
- }
267
-
268
- <#
269
- Purpose: Test Check-PSGalleryApiAvailability and Get-PSGalleryApiAvailability cmdlet for Stage 3 of PSGallery V2/V3 Transition.
270
-
271
- Action: Check-PSGalleryApiAvailability -PSGalleryV2ApiUri $Uri404NotFound -PSGalleryV3ApiUri $Uri200Ok
272
- Get-PSGalleryApiAvailability -Repository PSGallery
273
-
274
- Expected Result: Should throw an error.
275
- #>
276
- It CheckGetPSGalleryApiAvailabilityStage3 {
277
- try {
278
- $result = & $script :PowerShellGetModuleInfo Check- PSGalleryApiAvailability - PSGalleryV2ApiUri $script :Uri404NotFound - PSGalleryV3ApiUri $script :Uri200Ok
279
- AssertNull $result " Check-PSGalleryApiAvailability Stage 3 should not return anything."
280
-
281
- $err = $null
282
- try
283
- {
284
- $result = & $script :PowerShellGetModuleInfo Get-PSGalleryApiAvailability - Repository " PSGallery" - WarningVariable w
285
- }
286
- catch
287
- {
288
- $err = $_
289
- }
290
-
291
- AssertNull $result " Get-PSGalleryApiAvailability Stage 3 should not return anything."
292
- AssertEquals 0 $w.Count " Get-PSGalleryApiAvailability Stage 3 should not write a warning."
293
- AssertNotNull $err " Get-PSGalleryApiAvailability Stage 3 should throw an error message."
294
- AssertEqualsCaseInsensitive " PSGalleryApiV2Discontinued,Get-PSGalleryApiAvailability" $err.FullyQualifiedErrorId " Get-PSGalleryApiAvailability Stage 3 threw a different error: $err "
295
- }
296
- finally {
297
- # Set API availability for v2 back to true (no warnings or errors thrown)
298
- $result = & $script :PowerShellGetModuleInfo Check- PSGalleryApiAvailability - PSGalleryV2ApiUri $script :Uri200Ok - PSGalleryV3ApiUri $script :URI404NotFound
299
- }
300
- }
301
-
302
- <#
303
- Purpose: Test Check-PSGalleryApiAvailability and Get-PSGalleryApiAvailability cmdlet when no API is available.
304
- This indicates that the site is down.
305
-
306
- Action: Check-PSGalleryApiAvailability -PSGalleryV2ApiUri $Uri404NotFound -PSGalleryV3ApiUri $Uri404NotFound
307
- Get-PSGalleryApiAvailability -Repository PSGallery
308
-
309
- Expected Result: Should throw an error.
310
- #>
311
- It CheckGetPSGalleryUnavailable {
312
- try {
313
- $result = & $script :PowerShellGetModuleInfo Check- PSGalleryApiAvailability - PSGalleryV2ApiUri $script :Uri404NotFound - PSGalleryV3ApiUri $script :Uri404NotFound
314
- AssertNull $result " Check-PSGalleryApiAvailability should not return anything."
315
-
316
- $err = $null
317
- try
318
- {
319
- $result = & $script :PowerShellGetModuleInfo Get-PSGalleryApiAvailability - Repository " PSGallery" - WarningVariable w
320
- }
321
- catch
322
- {
323
- $err = $_
324
- }
325
-
326
- AssertNull $result " Get-PSGalleryApiAvailability should not return anything."
327
- AssertEquals 0 $w.Count " Get-PSGalleryApiAvailability should not write a warning."
328
- AssertNotNull $err " Get-PSGalleryApiAvailability Stage 3 should throw an error message."
329
- AssertEqualsCaseInsensitive " PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability" $err.FullyQualifiedErrorId " Get-PSGalleryApiAvailability Stage 3 threw a different error: $err "
330
- }
331
- finally {
332
- # Set API availability for v2 back to true (no warnings or errors thrown)
333
- $result = & $script :PowerShellGetModuleInfo Check- PSGalleryApiAvailability - PSGalleryV2ApiUri $script :Uri200Ok - PSGalleryV3ApiUri $script :URI404NotFound
334
- }
335
- }
336
-
337
- <#
338
- Purpose: Test Get-PSGalleryApiAvailability cmdlet when no repository specified.
339
-
340
- Action: Get-PSGalleryApiAvailability
341
-
342
- Expected Result: Should show and do nothing.
343
- #>
344
- It GetPSGalleryApiAvailabilityNoRepositorySpecified {
345
-
346
- $err = $null
347
- try
348
- {
349
- $result = & $script :PowerShellGetModuleInfo Get-PSGalleryApiAvailability - WarningVariable w
350
- }
351
- catch
352
- {
353
- $err = $_
354
- }
355
-
356
- AssertNull $result " Get-PSGalleryApiAvailability should not return anything."
357
- AssertEquals 0 $w.Count " Get-PSGalleryApiAvailability should not write a warning."
358
- AssertNull $err " Get-PSGalleryApiAvailability should not throw an error message."
359
- }
360
-
361
-
362
- <#
363
- Purpose: Test Get-PSGalleryApiAvailability cmdlet when no repository specified.
364
-
365
- Action: Get-PSGalleryApiAvailability
366
-
367
- Expected Result: Should show and do nothing.
368
- #>
369
- It GetPSGalleryApiAvailabilityDifferentRepositorySpecified {
370
-
371
- $err = $null
372
- try
373
- {
374
- $result = & $script :PowerShellGetModuleInfo Get-PSGalleryApiAvailability - Repository " MSPSGallery" - WarningVariable w
375
- }
376
- catch
377
- {
378
- $err = $_
379
- }
380
-
381
- AssertNull $result " Get-PSGalleryApiAvailability should not return anything."
382
- AssertEquals 0 $w.Count " Get-PSGalleryApiAvailability should not write a warning."
383
- AssertNull $err " Get-PSGalleryApiAvailability should not throw an error message."
198
+ - expectedFullyQualifiedErrorId $expectedFullyQualifiedErrorId
384
199
}
385
200
}
386
-
387
201
Describe PowerShell.PSGet.ModuleSourceTests.P1 - Tags ' P1' , ' OuterLoop' {
388
202
389
203
BeforeAll {
@@ -591,7 +405,7 @@ Describe PowerShell.PSGet.ModuleSourceTests.P1 -Tags 'P1','OuterLoop' {
591
405
AssertFullyQualifiedErrorIdEquals - scriptblock {Register-PSRepository - Name myNuGetSource1 - SourceLocation myget.org/ F/ powershellgetdemo} `
592
406
- expectedFullyQualifiedErrorId $expectedFullyQualifiedErrorId
593
407
}
594
-
408
+
595
409
<#
596
410
Purpose: Validate Register-PSRepository functionality with wildcard in source name
597
411
@@ -697,7 +511,7 @@ Describe PowerShell.PSGet.ModuleSourceTests.P1 -Tags 'P1','OuterLoop' {
697
511
- expectedFullyQualifiedErrorId $expectedFullyQualifiedErrorId
698
512
}
699
513
700
- It RegisterPSRepositoryShouldFailWithPSModuleAsPMProviderName {
514
+ It RegisterPSRepositoryShouldFailWithPSModuleAsPMProviderName {
701
515
AssertFullyQualifiedErrorIdEquals - scriptblock {Register-PSRepository - Name Foo - SourceLocation $script :TempPath - PackageManagementProvider PowerShellGet} `
702
516
- expectedFullyQualifiedErrorId " InvalidPackageManagementProviderValue,Register-PSRepository"
703
517
}
@@ -707,15 +521,15 @@ Describe PowerShell.PSGet.ModuleSourceTests.P1 -Tags 'P1','OuterLoop' {
707
521
- expectedFullyQualifiedErrorId " InvalidPackageManagementProviderValue,Set-PSRepository"
708
522
}
709
523
710
- It RegisterPackageSourceShouldFailWithPSModuleAsPMProviderName {
524
+ It RegisterPackageSourceShouldFailWithPSModuleAsPMProviderName {
711
525
AssertFullyQualifiedErrorIdEquals - scriptblock {Register-PackageSource - ProviderName PowerShellGet - Name Foo - Location $script :TempPath - PackageManagementProvider PowerShellGet} `
712
526
- expectedFullyQualifiedErrorId " InvalidPackageManagementProviderValue,Add-PackageSource,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource"
713
527
}
714
528
}
715
529
716
530
Describe PowerShell.PSGet.FindModule.ModuleSourceTests.P1 - Tags ' P1' , ' OuterLoop' {
717
531
718
- # Not executing these tests on MacOS as
532
+ # Not executing these tests on MacOS as
719
533
# the total execution time is exceeding allowed 50 min in TravisCI daily builds.
720
534
if ($IsMacOS ) {
721
535
return
@@ -789,7 +603,7 @@ Describe PowerShell.PSGet.FindModule.ModuleSourceTests.P1 -Tags 'P1','OuterLoop'
789
603
790
604
Describe PowerShell.PSGet.InstallModule.ModuleSourceTests.P1 - Tags ' P1' , ' OuterLoop' {
791
605
792
- # Not executing these tests on MacOS as
606
+ # Not executing these tests on MacOS as
793
607
# the total execution time is exceeding allowed 50 min in TravisCI daily builds.
794
608
if ($IsMacOS ) {
795
609
return
0 commit comments