Skip to content

Commit 87375d6

Browse files
Re enable save and update tests with fixes (#1867)
1 parent 55edbea commit 87375d6

File tree

6 files changed

+27
-24
lines changed

6 files changed

+27
-24
lines changed

test/SavePSResourceTests/SavePSResourceLocalTests.ps1 renamed to test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
9696
$pkgDirVersion = Get-ChildItem $pkgDir.FullName
9797
$pkgDirVersion.Name | Should -Be "1.0.0"
9898
}
99-
99+
100100
It "Should save resource given name and version '3.*'" {
101101
Save-PSResource -Name $moduleName -Version "3.*" -Repository $localRepo -Path $SaveDir -TrustRepository
102102
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $moduleName
@@ -147,7 +147,7 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
147147
Find-PSResource -Name $moduleName -Version "5.0.0" -Repository $localRepo | Save-PSResource -Path $SaveDir -TrustRepository
148148
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $moduleName
149149
$pkgDir | Should -Not -BeNullOrEmpty
150-
(Get-ChildItem -Path $pkgDir.FullName) | Should -HaveCount 1
150+
(Get-ChildItem -Path $pkgDir.FullName) | Should -HaveCount 1
151151
}
152152

153153
It "Save module as a nupkg" {
@@ -157,7 +157,7 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
157157
}
158158

159159
It "Save module, should search through all repositories and only install from the first repo containing the package" {
160-
Save-PSResource -Name $moduleName3 -Version "0.0.93" -Path $SaveDir -TrustRepository -ErrorVariable ev
160+
Save-PSResource -Name $moduleName3 -Version "0.0.93" -Path $SaveDir -TrustRepository -ErrorVariable ev
161161
$ev | Should -BeNullOrEmpty
162162
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq "$moduleName3"
163163
$pkgDir | Should -Not -BeNullOrEmpty
@@ -180,11 +180,11 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
180180
}
181181

182182
It "Save module via InputObject by piping from Find-PSResource" {
183-
$modules = Find-PSResource -Name "*" -Repository $localRepo
183+
$modules = Find-PSResource -Name "*" -Repository $localRepo
184184
$modules.Count | Should -BeGreaterThan 1
185185

186186
Save-PSResource -Path $SaveDir -TrustRepository -InputObject $modules
187-
187+
188188
$pkgDir = Get-ChildItem -Path $SaveDir
189189
$pkgDir | Should -Not -BeNullOrEmpty
190190
$pkgDir.Count | Should -BeGreaterThan 1
@@ -196,7 +196,8 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
196196
$res = Save-PSResource -Name $moduleName -Version "5.0.0" -AuthenticodeCheck -Repository $localRepo -TrustRepository -Path $SaveDir -ErrorAction SilentlyContinue -ErrorVariable err -PassThru
197197
$res | Should -BeNullOrEmpty
198198
$err.Count | Should -Not -BeNullOrEmpty
199-
$err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
199+
$err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
200+
$err[1].FullyQualifiedErrorId | Should -Contain "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
200201
}
201202

202203
It "Save module using -Quiet" {

test/SavePSResourceTests/SavePSResourceV2Tests.ps1 renamed to test/SavePSResourceTests/SavePSResourceV2.Tests.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Describe 'Test HTTP Save-PSResource for V2 Server Protocol' -tags 'CI' {
1313
$testScriptName = "test_script"
1414
$testModuleName2 = "testmodule99"
1515
$PackageManagement = "PackageManagement"
16+
$testModuleNameWithLicense = "ModuleRequireLicenseAcceptance"
1617
Get-NewPSResourceRepositoryFile
1718

1819
$SaveDir = Join-Path $TestDrive 'SavedResources'
@@ -174,7 +175,7 @@ Describe 'Test HTTP Save-PSResource for V2 Server Protocol' -tags 'CI' {
174175
}
175176

176177
It "Save script without using -IncludeXML" {
177-
Save-PSResource -Name $testScriptName -Repository $PSGalleryName -Path $SaveDir -TrustRepository | Should -Not -Throw
178+
{ Save-PSResource -Name $testScriptName -Repository $PSGalleryName -Path $SaveDir -TrustRepository } | Should -Not -Throw
178179

179180
$SavedScriptFile = Join-Path -Path $SaveDir -ChildPath "$testScriptName.ps1"
180181
Test-Path -Path $SavedScriptFile -PathType 'Leaf' | Should -BeTrue
@@ -197,15 +198,14 @@ Describe 'Test HTTP Save-PSResource for V2 Server Protocol' -tags 'CI' {
197198
It "Save module that is not authenticode signed" -Skip:(!(Get-IsWindows)) {
198199
Save-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue
199200
$err.Count | Should -BeGreaterThan 0
200-
$err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
201+
$err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
202+
$err[1].FullyQualifiedErrorId | Should -Contain "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
201203
}
202204

203205
# Save resource that requires license
204206
It "Save resource that requires accept license with -AcceptLicense flag" {
205-
Save-PSResource -Repository $TestGalleryName -TrustRepository -Path $SaveDir `
206-
-Name $testModuleName2 -AcceptLicense
207-
$pkg = Get-InstalledPSResource -Path $SaveDir -Name $testModuleName2
208-
$pkg.Name | Should -Be $testModuleName2
209-
$pkg.Version | Should -Be "0.0.1.0"
207+
$pkg = Save-PSResource -Repository $PSGalleryName -TrustRepository -Path $SaveDir -Name $testModuleNameWithLicense -AcceptLicense -PassThru
208+
$pkg.Name | Should -Be $testModuleNameWithLicense
209+
$pkg.Version | Should -Be "2.0"
210210
}
211211
}

test/SavePSResourceTests/SavePSResourceV3Tests.ps1 renamed to test/SavePSResourceTests/SavePSResourceV3.Tests.ps1

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,17 @@ Describe 'Test HTTP Save-PSResource for V3 Server Protocol' -tags 'CI' {
144144
It 'Save module that is not authenticode signed' -Skip:(!(Get-IsWindows)) {
145145
Save-PSResource -Name $testModuleName -Version '5.0.0' -AuthenticodeCheck -Repository $NuGetGalleryName -TrustRepository -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue
146146
$err.Count | Should -BeGreaterThan 0
147-
$err[0].FullyQualifiedErrorId | Should -BeExactly 'GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource'
147+
$err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
148+
$err[1].FullyQualifiedErrorId | Should -Contain "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
148149
}
149150

150151
# Save resource that requires license
151-
It 'Install resource that requires accept license with -AcceptLicense flag' {
152-
Save-PSResource -Repository $NuGetGalleryName -TrustRepository -Path $SaveDir `
153-
-Name 'test_module_withlicense' -AcceptLicense
154-
$pkg = Get-InstalledPSResource -Path $SaveDir 'test_module_withlicense'
152+
It 'Save resource that requires accept license with -AcceptLicense flag' {
153+
$pkg = Save-PSResource -Repository $NuGetGalleryName -TrustRepository -Path $SaveDir -Name 'test_module_withlicense' -AcceptLicense -PassThru
155154
$pkg.Name | Should -Be 'test_module_withlicense'
156155
$pkg.Version | Should -Be '1.0.0'
157156
}
158-
157+
159158
It "Save module and its dependencies" {
160159
$res = Save-PSResource 'TestModuleWithDependencyE' -Repository $NuGetGalleryName -TrustRepository -PassThru
161160
$res.Length | Should -Be 4
File renamed without changes.

test/UpdatePSResourceTests/UpdatePSResourceV2Tests.ps1 renamed to test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
7474
}
7575

7676
It "Update resource installed given Name and Version (specific) parameters" {
77-
Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
77+
$v1000 = Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository -Reinstall -PassThru
78+
$v1000.Version | Should -Be "1.0.0.0"
7879

79-
Update-PSResource -Name $testModuleName -Version "5.0.0.0" -Repository $PSGalleryName -TrustRepository
80+
$v5000 = Update-PSResource -Name $testModuleName -Version "5.0.0.0" -Repository $PSGalleryName -TrustRepository -PassThru -Force
81+
$v5000.Version | Should -Contain "5.0.0.0"
8082
$res = Get-InstalledPSResource -Name $testModuleName
8183
$res | Should -Not -BeNullOrEmpty
8284
$isPkgUpdated = $false
@@ -145,7 +147,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
145147
$isPkgUpdated = $false
146148
foreach ($pkg in $res)
147149
{
148-
if ([System.Version]$pkg.Version -eq [System.Version]"3.0.0")
150+
if ([System.Version]$pkg.Version -eq [System.Version]"3.0.0.0")
149151
{
150152
$isPkgUpdated = $true
151153
}
@@ -174,7 +176,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
174176

175177
It "Update resource to explicit prerelease version using NuGet syntax" {
176178
Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
177-
Update-PSResource -Name $testModuleName -Version "[5.2.5-alpha001]" -Prerelease -Repository $PSGalleryName -TrustRepository
179+
Update-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Prerelease -Repository $PSGalleryName -TrustRepository
178180
$res = Get-InstalledPSResource -Name $testModuleName
179181
$res | Should -Not -BeNullOrEmpty
180182
$isPkgUpdated = $false
@@ -427,6 +429,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
427429
Install-PSResource -Name "TestTestScript" -Version "1.0" -Repository $PSGalleryName -TrustRepository
428430
Update-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorVariable err -ErrorAction SilentlyContinue
429431
$err.Count | Should -Not -Be 0
430-
$err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource"
432+
$err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource"
433+
$err[1].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource"
431434
}
432435
}
File renamed without changes.

0 commit comments

Comments
 (0)