diff --git a/test/SavePSResourceTests/SavePSResourceLocalTests.ps1 b/test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1 similarity index 96% rename from test/SavePSResourceTests/SavePSResourceLocalTests.ps1 rename to test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1 index 36eb5330c..60b574975 100644 --- a/test/SavePSResourceTests/SavePSResourceLocalTests.ps1 +++ b/test/SavePSResourceTests/SavePSResourceLocal.Tests.ps1 @@ -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 @@ -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" { @@ -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 @@ -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 @@ -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" { diff --git a/test/SavePSResourceTests/SavePSResourceV2Tests.ps1 b/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 similarity index 93% rename from test/SavePSResourceTests/SavePSResourceV2Tests.ps1 rename to test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 index f00656b06..ee350f91e 100644 --- a/test/SavePSResourceTests/SavePSResourceV2Tests.ps1 +++ b/test/SavePSResourceTests/SavePSResourceV2.Tests.ps1 @@ -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' @@ -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 @@ -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" } } diff --git a/test/SavePSResourceTests/SavePSResourceV3Tests.ps1 b/test/SavePSResourceTests/SavePSResourceV3.Tests.ps1 similarity index 93% rename from test/SavePSResourceTests/SavePSResourceV3Tests.ps1 rename to test/SavePSResourceTests/SavePSResourceV3.Tests.ps1 index 11dbb9688..8078d28ca 100644 --- a/test/SavePSResourceTests/SavePSResourceV3Tests.ps1 +++ b/test/SavePSResourceTests/SavePSResourceV3.Tests.ps1 @@ -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 diff --git a/test/UpdatePSResourceTests/UpdatePSResourceLocalTests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceLocal.Tests.ps1 similarity index 100% rename from test/UpdatePSResourceTests/UpdatePSResourceLocalTests.ps1 rename to test/UpdatePSResourceTests/UpdatePSResourceLocal.Tests.ps1 diff --git a/test/UpdatePSResourceTests/UpdatePSResourceV2Tests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 similarity index 96% rename from test/UpdatePSResourceTests/UpdatePSResourceV2Tests.ps1 rename to test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 index 0141e3e30..07db15035 100644 --- a/test/UpdatePSResourceTests/UpdatePSResourceV2Tests.ps1 +++ b/test/UpdatePSResourceTests/UpdatePSResourceV2.Tests.ps1 @@ -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 @@ -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 } @@ -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 @@ -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" } } diff --git a/test/UpdatePSResourceTests/UpdatePSResourceV3Tests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceV3.Tests.ps1 similarity index 100% rename from test/UpdatePSResourceTests/UpdatePSResourceV3Tests.ps1 rename to test/UpdatePSResourceTests/UpdatePSResourceV3.Tests.ps1