5
5
Import-Module " $PSScriptRoot \PSGetTestUtils.psm1" - WarningAction SilentlyContinue
6
6
7
7
$RepositoryName = ' PSGallery'
8
- $SourceLocation = ' https://www.poshtestgallery.com/api/v2/'
9
- $PublishLocation = ' https://www.poshtestgallery.com/api/v2/package/'
10
- $ScriptSourceLocation = ' https://www.poshtestgallery.com/api/v2/items/psscript/'
11
- $ScriptPublishLocation = ' https://www.poshtestgallery.com/api/v2/package/'
8
+ $SourceLocation = ' https://www.poshtestgallery.com/api/v2'
9
+ $SourceLocation2 = ' https://www.poshtestgallery.com/api/v2/'
10
+ $PublishLocation = ' https://www.poshtestgallery.com/api/v2/package'
11
+ $ScriptSourceLocation = ' https://www.poshtestgallery.com/api/v2/items/psscript'
12
+ $ScriptPublishLocation = ' https://www.poshtestgallery.com/api/v2/package'
12
13
$TestRepositoryName = ' PSTestGallery'
13
14
14
15
Describe ' Test Register-PSRepository and Register-PackageSource for PSGallery repository' - tags ' BVT' , ' InnerLoop' {
15
16
16
17
BeforeAll {
17
18
Install-NuGetBinaries
19
+ Get-PSRepository |
20
+ Where-Object - Property SourceLocation -eq $SourceLocation2 |
21
+ Unregister-PSRepository
22
+
23
+ $nugetCmd = Microsoft.PowerShell.Core\Get-Command - Name ' NuGet.exe' `
24
+ - ErrorAction SilentlyContinue - WarningAction SilentlyContinue
18
25
}
19
26
20
27
AfterAll {
@@ -30,6 +37,16 @@ Describe 'Test Register-PSRepository and Register-PackageSource for PSGallery re
30
37
Unregister-PSRepository - Name $RepositoryName - ErrorAction SilentlyContinue
31
38
}
32
39
40
+ It ' Should add and remove nuget source when -PackageMangementProvider is set to Nuget' {
41
+ Register-PSRepository - Name $TestRepositoryName - SourceLocation $SourceLocation - PackageManagementProvider Nuget
42
+ $nugetSourceExists = nuget sources list | where-object { $_.Trim () -in $SourceLocation }
43
+ $nugetSourceExists | should be $true
44
+
45
+ unregister-PSRepository - Name $TestRepositoryName
46
+ $nugetSourceExists = nuget sources list | where-object { $_.Trim () -in $SourceLocation }
47
+ $nugetSourceExists | should be $null
48
+ } - Skip:$ (! $nugetCmd )
49
+
33
50
It ' Should pipe from Get-PSRepository to Set' {
34
51
Register-PSRepository - Default
35
52
@@ -72,10 +89,12 @@ Describe 'Test Register-PSRepository and Register-PackageSource for PSGallery re
72
89
$repo = Get-PSRepository - Name ' Test Repo'
73
90
$repo.Name | should be ' Test Repo'
74
91
$repo.SourceLocation | should be $tmpdir
75
- } finally {
92
+ }
93
+ finally {
76
94
Unregister-PSRepository - Name ' Test Repo' - ErrorAction SilentlyContinue
77
95
}
78
- } finally {
96
+ }
97
+ finally {
79
98
Remove-Item - LiteralPath $tmpdir - Force - Recurse
80
99
}
81
100
}
@@ -99,7 +118,7 @@ Describe 'Test Register-PSRepository and Register-PackageSource for PSGallery re
99
118
}
100
119
101
120
It ' Register-PSRepository -Name PSGallery -SourceLocation $SourceLocation -PublishLocation $PublishLocation : Should fail' {
102
- { Register-PSRepository $RepositoryName $SourceLocation - PublishLocation $PublishLocation - ErrorVariable ev - ErrorAction SilentlyContinue } | Should Throw
121
+ { Register-PSRepository $RepositoryName $SourceLocation - PublishLocation $PublishLocation - ErrorVariable ev - ErrorAction SilentlyContinue } | Should Throw
103
122
}
104
123
105
124
It ' Register-PSRepository -Name PSGallery -SourceLocation $SourceLocation -ScriptPublishLocation $ScriptPublishLocation : Should fail' {
@@ -256,8 +275,8 @@ Describe 'Test Register-PSRepository for PSTestGallery repository' -tags 'BVT',
256
275
BeforeAll {
257
276
Install-NuGetBinaries
258
277
Get-PSRepository |
259
- Where-Object - Property SourceLocation -eq $SourceLocation |
260
- Unregister-PSRepository
278
+ Where-Object - Property SourceLocation -eq $SourceLocation |
279
+ Unregister-PSRepository
261
280
}
262
281
263
282
BeforeEach {
@@ -272,17 +291,17 @@ Describe 'Test Register-PSRepository for PSTestGallery repository' -tags 'BVT',
272
291
$paramRegisterPSRepository = @ {
273
292
Name = $TestRepositoryName
274
293
SourceLocation = $SourceLocation
275
- PublishLocation = $SourceLocation
276
- ScriptSourceLocation = $SourceLocation
277
- ScriptPublishLocation = $SourceLocation
294
+ PublishLocation = $PublishLocation
295
+ ScriptSourceLocation = $ScriptSourceLocation
296
+ ScriptPublishLocation = $ScriptPublishLocation
278
297
}
279
298
280
299
{ Register-PSRepository @paramRegisterPSRepository } | Should not Throw
281
300
$repo = Get-PSRepository - Name $TestRepositoryName
282
301
$repo.SourceLocation | Should be $SourceLocation
283
- $repo.ScriptSourceLocation | Should be $SourceLocation
284
- $repo.PublishLocation | Should be $SourceLocation
285
- $repo.ScriptPublishLocation | Should be $SourceLocation
302
+ $repo.ScriptSourceLocation | Should be $ScriptSourceLocation
303
+ $repo.PublishLocation | Should be $PublishLocation
304
+ $repo.ScriptPublishLocation | Should be $ScriptPublishLocation
286
305
}
287
306
}
288
307
@@ -291,8 +310,8 @@ Describe 'Test Set-PSRepository for PSTestGallery repository' -tags 'BVT', 'Inne
291
310
BeforeAll {
292
311
Install-NuGetBinaries
293
312
Get-PSRepository |
294
- Where-Object - Property SourceLocation -eq $SourceLocation |
295
- Unregister-PSRepository
313
+ Where-Object - Property SourceLocation -eq $SourceLocation |
314
+ Unregister-PSRepository
296
315
}
297
316
298
317
BeforeEach {
@@ -312,22 +331,22 @@ Describe 'Test Set-PSRepository for PSTestGallery repository' -tags 'BVT', 'Inne
312
331
ScriptPublishLocation = $ScriptPublishLocation
313
332
}
314
333
315
- Register-PSRepository @paramRegisterPSRepository
334
+ Register-PSRepository @paramRegisterPSRepository - ErrorAction SilentlyContinue
316
335
317
336
$paramSetPSRepository = @ {
318
337
Name = $TestRepositoryName
319
338
SourceLocation = $SourceLocation
320
- PublishLocation = $SourceLocation
321
- ScriptSourceLocation = $SourceLocation
322
- ScriptPublishLocation = $SourceLocation
339
+ PublishLocation = $PublishLocation
340
+ ScriptSourceLocation = $ScriptSourceLocation
341
+ ScriptPublishLocation = $ScriptPublishLocation
323
342
}
324
343
325
344
{ Set-PSRepository @paramSetPSRepository } | Should not Throw
326
345
327
346
$repo = Get-PSRepository - Name $TestRepositoryName
328
347
$repo.SourceLocation | Should be $SourceLocation
329
- $repo.ScriptSourceLocation | Should be $SourceLocation
330
- $repo.PublishLocation | Should be $SourceLocation
331
- $repo.ScriptPublishLocation | Should be $SourceLocation
348
+ $repo.ScriptSourceLocation | Should be $ScriptSourceLocation
349
+ $repo.PublishLocation | Should be $PublishLocation
350
+ $repo.ScriptPublishLocation | Should be $ScriptPublishLocation
332
351
}
333
352
}
0 commit comments