Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
$pkgDirVersion = Get-ChildItem $pkgDir.FullName
$pkgDirVersion.Name | Should -Be "1.0.0"
}

It "Should save resource given name and version '3.*'" {
Save-PSResource -Name $moduleName -Version "3.*" -Repository $localRepo -Path $SaveDir -TrustRepository
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $moduleName
Expand Down Expand Up @@ -147,7 +147,7 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
Find-PSResource -Name $moduleName -Version "5.0.0" -Repository $localRepo | Save-PSResource -Path $SaveDir -TrustRepository
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $moduleName
$pkgDir | Should -Not -BeNullOrEmpty
(Get-ChildItem -Path $pkgDir.FullName) | Should -HaveCount 1
(Get-ChildItem -Path $pkgDir.FullName) | Should -HaveCount 1
}

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

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

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

Save-PSResource -Path $SaveDir -TrustRepository -InputObject $modules

$pkgDir = Get-ChildItem -Path $SaveDir
$pkgDir | Should -Not -BeNullOrEmpty
$pkgDir.Count | Should -BeGreaterThan 1
Expand All @@ -196,7 +196,8 @@ Describe 'Test Save-PSResource for local repositories' -tags 'CI' {
$res = Save-PSResource -Name $moduleName -Version "5.0.0" -AuthenticodeCheck -Repository $localRepo -TrustRepository -Path $SaveDir -ErrorAction SilentlyContinue -ErrorVariable err -PassThru
$res | Should -BeNullOrEmpty
$err.Count | Should -Not -BeNullOrEmpty
$err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
$err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
$err[1].FullyQualifiedErrorId | Should -Contain "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
}

It "Save module using -Quiet" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Describe 'Test HTTP Save-PSResource for V2 Server Protocol' -tags 'CI' {
$testScriptName = "test_script"
$testModuleName2 = "testmodule99"
$PackageManagement = "PackageManagement"
$testModuleNameWithLicense = "ModuleRequireLicenseAcceptance"
Get-NewPSResourceRepositoryFile

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

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

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

# Save resource that requires license
It "Save resource that requires accept license with -AcceptLicense flag" {
Save-PSResource -Repository $TestGalleryName -TrustRepository -Path $SaveDir `
-Name $testModuleName2 -AcceptLicense
$pkg = Get-InstalledPSResource -Path $SaveDir -Name $testModuleName2
$pkg.Name | Should -Be $testModuleName2
$pkg.Version | Should -Be "0.0.1.0"
$pkg = Save-PSResource -Repository $PSGalleryName -TrustRepository -Path $SaveDir -Name $testModuleNameWithLicense -AcceptLicense -PassThru
$pkg.Name | Should -Be $testModuleNameWithLicense
$pkg.Version | Should -Be "2.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,17 @@ Describe 'Test HTTP Save-PSResource for V3 Server Protocol' -tags 'CI' {
It 'Save module that is not authenticode signed' -Skip:(!(Get-IsWindows)) {
Save-PSResource -Name $testModuleName -Version '5.0.0' -AuthenticodeCheck -Repository $NuGetGalleryName -TrustRepository -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue
$err.Count | Should -BeGreaterThan 0
$err[0].FullyQualifiedErrorId | Should -BeExactly 'GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource'
$err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
$err[1].FullyQualifiedErrorId | Should -Contain "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource"
}

# Save resource that requires license
It 'Install resource that requires accept license with -AcceptLicense flag' {
Save-PSResource -Repository $NuGetGalleryName -TrustRepository -Path $SaveDir `
-Name 'test_module_withlicense' -AcceptLicense
$pkg = Get-InstalledPSResource -Path $SaveDir 'test_module_withlicense'
It 'Save resource that requires accept license with -AcceptLicense flag' {
$pkg = Save-PSResource -Repository $NuGetGalleryName -TrustRepository -Path $SaveDir -Name 'test_module_withlicense' -AcceptLicense -PassThru
$pkg.Name | Should -Be 'test_module_withlicense'
$pkg.Version | Should -Be '1.0.0'
}

It "Save module and its dependencies" {
$res = Save-PSResource 'TestModuleWithDependencyE' -Repository $NuGetGalleryName -TrustRepository -PassThru
$res.Length | Should -Be 4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
}

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

Update-PSResource -Name $testModuleName -Version "5.0.0.0" -Repository $PSGalleryName -TrustRepository
$v5000 = Update-PSResource -Name $testModuleName -Version "5.0.0.0" -Repository $PSGalleryName -TrustRepository -PassThru -Force
$v5000.Version | Should -Contain "5.0.0.0"
$res = Get-InstalledPSResource -Name $testModuleName
$res | Should -Not -BeNullOrEmpty
$isPkgUpdated = $false
Expand Down Expand Up @@ -145,7 +147,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
$isPkgUpdated = $false
foreach ($pkg in $res)
{
if ([System.Version]$pkg.Version -eq [System.Version]"3.0.0")
if ([System.Version]$pkg.Version -eq [System.Version]"3.0.0.0")
{
$isPkgUpdated = $true
}
Expand Down Expand Up @@ -174,7 +176,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {

It "Update resource to explicit prerelease version using NuGet syntax" {
Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository
Update-PSResource -Name $testModuleName -Version "[5.2.5-alpha001]" -Prerelease -Repository $PSGalleryName -TrustRepository
Update-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Prerelease -Repository $PSGalleryName -TrustRepository
$res = Get-InstalledPSResource -Name $testModuleName
$res | Should -Not -BeNullOrEmpty
$isPkgUpdated = $false
Expand Down Expand Up @@ -427,6 +429,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' {
Install-PSResource -Name "TestTestScript" -Version "1.0" -Repository $PSGalleryName -TrustRepository
Update-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorVariable err -ErrorAction SilentlyContinue
$err.Count | Should -Not -Be 0
$err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource"
$err[0].FullyQualifiedErrorId | Should -Contain "GetAuthenticodeSignatureError,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource"
$err[1].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.UpdatePSResource"
}
}
Loading