Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 5a51ee6

Browse files
edyoungalerickson
authored andcommitted
Added basic test case to demonstrate repository / problem
1 parent c3c8a45 commit 5a51ee6

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

Tests/PSGetUpdateModule.Tests.ps1

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,48 @@ function SuiteCleanup {
7777
}
7878
}
7979

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 situation" {
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+
117+
(Get-InstalledModule ContosoServer).Version | Should Be 2.0
118+
119+
}
120+
}
121+
80122
Describe PowerShell.PSGet.UpdateModuleTests -Tags 'BVT','InnerLoop' {
81123

82124
BeforeAll {
@@ -350,7 +392,7 @@ Describe PowerShell.PSGet.UpdateModuleTests -Tags 'BVT','InnerLoop' {
350392
}
351393

352394
Describe PowerShell.PSGet.UpdateModuleTests.P1 -Tags 'P1','OuterLoop' {
353-
# Not executing these tests on MacOS as
395+
# Not executing these tests on MacOS as
354396
# the total execution time is exceeding allowed 50 min in TravisCI daily builds.
355397
if($IsMacOS) {
356398
return
@@ -376,13 +418,13 @@ Describe PowerShell.PSGet.UpdateModuleTests.P1 -Tags 'P1','OuterLoop' {
376418
# Expected Result: both modules should be refreshed
377419
#
378420
It "UpdateMultipleModulesWithWildcard" {
379-
421+
380422
Install-Module ContosoClient -RequiredVersion 1.0
381-
423+
382424
$contosoClientDetails = Get-InstalledModule -Name ContosoClient
383425

384426
Install-Module ContosoServer -RequiredVersion 1.0
385-
427+
386428
$MyError = $null
387429
$DateTimeBeforeUpdate = Get-Date
388430

@@ -391,7 +433,7 @@ Describe PowerShell.PSGet.UpdateModuleTests.P1 -Tags 'P1','OuterLoop' {
391433
Assert ($MyError.Count -eq 0) "There should not be any error when updating multiple modules with wildcard in name, $MyError"
392434
$res = Get-InstalledModule -Name ContosoServer -MinimumVersion "1.1"
393435
Assert ($res -and ($res.Name -eq "ContosoServer") -and ($res.Version -gt [Version]"1.0")) "Update-Module should update when wildcard specified in name"
394-
436+
395437
$res = Get-InstalledModule -Name ContosoClient -MinimumVersion "1.1"
396438
Assert ($res -and ($res.Name -eq "ContosoClient") -and ($res.Version -gt [Version]"1.0")) "Update-Module should update when wildcard specified in name"
397439

@@ -457,7 +499,7 @@ Describe PowerShell.PSGet.UpdateModuleTests.P1 -Tags 'P1','OuterLoop' {
457499

458500
Describe PowerShell.PSGet.UpdateModuleTests.P2 -Tags 'P2','OuterLoop' {
459501

460-
# Not executing these tests on MacOS as
502+
# Not executing these tests on MacOS as
461503
# the total execution time is exceeding allowed 50 min in TravisCI daily builds.
462504
if($IsMacOS) {
463505
return

0 commit comments

Comments
 (0)