@@ -77,6 +77,74 @@ function SuiteCleanup {
77
77
}
78
78
}
79
79
80
+ Describe UpdateModuleFromAlternateRepo - Tags ' BVT' {
81
+ BeforeAll {
82
+ SuiteSetup
83
+ }
84
+
85
+ AfterAll {
86
+ SuiteCleanup
87
+ }
88
+
89
+ AfterEach {
90
+ PSGetTestUtils\Uninstall-Module ContosoServer
91
+ PSGetTestUtils\Uninstall-Module ContosoClient
92
+ }
93
+
94
+ It " Check that removing a slash from a repo doesn't break update" {
95
+ $withSlash = " https://www.poshtestgallery.com/api/v2/"
96
+ $noSlash = " https://www.poshtestgallery.com/api/v2"
97
+ # Write-Host (Get-PSRepository | Out-String)
98
+ (Get-PSRepository PSGallery).SourceLocation | Should Be $withSlash
99
+
100
+ Install-Module ContosoServer - RequiredVersion 1.0
101
+ (Get-InstalledModule ContosoServer).RepositorySourceLocation | Should Be $withSlash
102
+ # Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)
103
+
104
+ # now update where PSGallery Source Location is
105
+ Set-PSGallerySourceLocation - Location $noSlash
106
+ # Write-Host (Get-PSRepository | Out-String)
107
+ (Get-PSRepository PSGallery).SourceLocation | Should Be $noSlash
108
+
109
+ # reload powershellget to force-update cached repository info
110
+ Import-Module PowerShellGet - Force
111
+
112
+ # now try and update module isntalled using other SourceLocation
113
+ Update-Module ContosoServer - RequiredVersion 2.0 - ErrorAction Stop
114
+ # Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)
115
+ (Get-InstalledModule ContosoServer).RepositorySourceLocation | Should Be $noSlash
116
+ (Get-InstalledModule ContosoServer).Version | Should Be 2.0
117
+ }
118
+
119
+ It " Check that adding a slash to a repo doesn't break update" {
120
+ $withSlash = " https://www.poshtestgallery.com/api/v2/"
121
+ $noSlash = " https://www.poshtestgallery.com/api/v2"
122
+ # Write-Host (Get-PSRepository | Out-String)
123
+
124
+ Set-PSGallerySourceLocation - Location $noSlash
125
+
126
+ (Get-PSRepository PSGallery).SourceLocation | Should Be $noSlash
127
+
128
+ Install-Module ContosoServer - RequiredVersion 1.0
129
+ (Get-InstalledModule ContosoServer).RepositorySourceLocation | Should Be $noSlash
130
+ # Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)
131
+
132
+ # now update where PSGallery Source Location is
133
+ Set-PSGallerySourceLocation - Location $withSlash
134
+ # Write-Host (Get-PSRepository | Out-String)
135
+ (Get-PSRepository PSGallery).SourceLocation | Should Be $withSlash
136
+
137
+ # reload powershellget to force-update cached repository info
138
+ Import-Module PowerShellGet - Force
139
+
140
+ # now try and update module isntalled using other SourceLocation
141
+ Update-Module ContosoServer - RequiredVersion 2.0 - ErrorAction Stop
142
+ # Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)
143
+ (Get-InstalledModule ContosoServer).RepositorySourceLocation | Should Be $withSlash
144
+ (Get-InstalledModule ContosoServer).Version | Should Be 2.0
145
+ }
146
+ }
147
+
80
148
Describe PowerShell.PSGet.UpdateModuleTests - Tags ' BVT' , ' InnerLoop' {
81
149
82
150
BeforeAll {
@@ -350,7 +418,7 @@ Describe PowerShell.PSGet.UpdateModuleTests -Tags 'BVT','InnerLoop' {
350
418
}
351
419
352
420
Describe PowerShell.PSGet.UpdateModuleTests.P1 - Tags ' P1' , ' OuterLoop' {
353
- # Not executing these tests on MacOS as
421
+ # Not executing these tests on MacOS as
354
422
# the total execution time is exceeding allowed 50 min in TravisCI daily builds.
355
423
if ($IsMacOS ) {
356
424
return
@@ -376,13 +444,13 @@ Describe PowerShell.PSGet.UpdateModuleTests.P1 -Tags 'P1','OuterLoop' {
376
444
# Expected Result: both modules should be refreshed
377
445
#
378
446
It " UpdateMultipleModulesWithWildcard" {
379
-
447
+
380
448
Install-Module ContosoClient - RequiredVersion 1.0
381
-
449
+
382
450
$contosoClientDetails = Get-InstalledModule - Name ContosoClient
383
451
384
452
Install-Module ContosoServer - RequiredVersion 1.0
385
-
453
+
386
454
$MyError = $null
387
455
$DateTimeBeforeUpdate = Get-Date
388
456
@@ -391,7 +459,7 @@ Describe PowerShell.PSGet.UpdateModuleTests.P1 -Tags 'P1','OuterLoop' {
391
459
Assert ($MyError.Count -eq 0 ) " There should not be any error when updating multiple modules with wildcard in name, $MyError "
392
460
$res = Get-InstalledModule - Name ContosoServer - MinimumVersion " 1.1"
393
461
Assert ($res -and ($res.Name -eq " ContosoServer" ) -and ($res.Version -gt [Version ]" 1.0" )) " Update-Module should update when wildcard specified in name"
394
-
462
+
395
463
$res = Get-InstalledModule - Name ContosoClient - MinimumVersion " 1.1"
396
464
Assert ($res -and ($res.Name -eq " ContosoClient" ) -and ($res.Version -gt [Version ]" 1.0" )) " Update-Module should update when wildcard specified in name"
397
465
@@ -457,7 +525,7 @@ Describe PowerShell.PSGet.UpdateModuleTests.P1 -Tags 'P1','OuterLoop' {
457
525
458
526
Describe PowerShell.PSGet.UpdateModuleTests.P2 - Tags ' P2' , ' OuterLoop' {
459
527
460
- # Not executing these tests on MacOS as
528
+ # Not executing these tests on MacOS as
461
529
# the total execution time is exceeding allowed 50 min in TravisCI daily builds.
462
530
if ($IsMacOS ) {
463
531
return
0 commit comments