mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Re-enable PowerShellGet tests targeting PowerShell gallery (#17062)
Re-enable `PowerShellGet` tests targeting PowerShell gallery (#17062) # Conflicts: # test/powershell/Modules/PackageManagement/PackageManagement.Tests.ps1
This commit is contained in:
@@ -13,14 +13,22 @@
|
||||
#
|
||||
# ------------------ PackageManagement Test -----------------------------------
|
||||
|
||||
$InternalGallery = "https://www.poshtestgallery.com/api/v2/"
|
||||
$InternalSource = 'OneGetTestSource'
|
||||
$gallery = "https://www.powershellgallery.com/api/v2"
|
||||
$source = 'OneGetTestSource'
|
||||
|
||||
Describe "PackageManagement Acceptance Test" -Tags "Feature" {
|
||||
|
||||
BeforeAll{
|
||||
Register-PackageSource -Name Nugettest -provider NuGet -Location https://www.nuget.org/api/v2 -Force
|
||||
Register-PackageSource -Name $InternalSource -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue
|
||||
|
||||
$packageSource = Get-PackageSource -Location $gallery -ErrorAction SilentlyContinue
|
||||
if ($packageSource) {
|
||||
$source = $packageSource.Name
|
||||
Set-PackageSource -Name $source -Trusted
|
||||
} else {
|
||||
Register-PackageSource -Name $source -Location $gallery -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
$SavedProgressPreference = $ProgressPreference
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
}
|
||||
@@ -41,9 +49,9 @@ Describe "PackageManagement Acceptance Test" -Tags "Feature" {
|
||||
$fpp | Should -Contain "PowerShellGet"
|
||||
}
|
||||
|
||||
It "install-packageprovider, Expect succeed" {
|
||||
$ipp = (Install-PackageProvider -Name gistprovider -Force -Source $InternalSource -Scope CurrentUser).name
|
||||
$ipp | Should -Contain "gistprovider"
|
||||
It "install-packageprovider, Expect succeed" {
|
||||
$ipp = (Install-PackageProvider -Name NanoServerPackage -Force -Source $source -Scope CurrentUser).name
|
||||
$ipp | Should -Contain "NanoServerPackage"
|
||||
}
|
||||
|
||||
It "Find-package" {
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
# no progress output during these tests
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
|
||||
$RepositoryName = 'INTGallery'
|
||||
$SourceLocation = 'https://www.poshtestgallery.com'
|
||||
$RegisteredINTRepo = $false
|
||||
$ContosoServer = 'ContosoServer'
|
||||
$FabrikamServerScript = 'Fabrikam-ServerScript'
|
||||
$RepositoryName = 'PSGallery'
|
||||
$SourceLocation = 'https://www.powershellgallery.com'
|
||||
$TestModule = 'newTestModule'
|
||||
$TestScript = 'TestTestScript'
|
||||
$Initialized = $false
|
||||
|
||||
#region Utility functions
|
||||
@@ -93,11 +92,11 @@ function Initialize
|
||||
if($repo)
|
||||
{
|
||||
$script:RepositoryName = $repo.Name
|
||||
Set-PackageSource -Name $repo.Name -Trusted
|
||||
}
|
||||
else
|
||||
{
|
||||
Register-PSRepository -Name $RepositoryName -SourceLocation $SourceLocation -InstallationPolicy Trusted
|
||||
$script:RegisteredINTRepo = $true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +104,7 @@ function Initialize
|
||||
|
||||
function Remove-InstalledModules
|
||||
{
|
||||
Get-InstalledModule -Name $ContosoServer -AllVersions -ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module -Force
|
||||
Get-InstalledModule -Name $TestModule -AllVersions -ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module -Force
|
||||
}
|
||||
|
||||
Describe "PowerShellGet - Module tests" -tags "Feature" {
|
||||
@@ -122,21 +121,21 @@ Describe "PowerShellGet - Module tests" -tags "Feature" {
|
||||
}
|
||||
|
||||
It "Should find a module correctly" {
|
||||
$psgetModuleInfo = Find-Module -Name $ContosoServer -Repository $RepositoryName
|
||||
$psgetModuleInfo.Name | Should -Be $ContosoServer
|
||||
$psgetModuleInfo = Find-Module -Name $TestModule -Repository $RepositoryName
|
||||
$psgetModuleInfo.Name | Should -Be $TestModule
|
||||
$psgetModuleInfo.Repository | Should -Be $RepositoryName
|
||||
}
|
||||
|
||||
It "Should install a module correctly to the required location with default CurrentUser scope" {
|
||||
Install-Module -Name $ContosoServer -Repository $RepositoryName
|
||||
$installedModuleInfo = Get-InstalledModule -Name $ContosoServer
|
||||
Install-Module -Name $TestModule -Repository $RepositoryName
|
||||
$installedModuleInfo = Get-InstalledModule -Name $TestModule
|
||||
|
||||
$installedModuleInfo | Should -Not -BeNullOrEmpty
|
||||
$installedModuleInfo.Name | Should -Be $ContosoServer
|
||||
$installedModuleInfo.Name | Should -Be $TestModule
|
||||
$installedModuleInfo.InstalledLocation.StartsWith($script:MyDocumentsModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
||||
|
||||
$module = Get-Module $ContosoServer -ListAvailable
|
||||
$module.Name | Should -Be $ContosoServer
|
||||
$module = Get-Module $TestModule -ListAvailable
|
||||
$module.Name | Should -Be $TestModule
|
||||
$module.ModuleBase | Should -Be $installedModuleInfo.InstalledLocation
|
||||
}
|
||||
|
||||
@@ -159,15 +158,15 @@ Describe "PowerShellGet - Module tests (Admin)" -Tags @('Feature', 'RequireAdmin
|
||||
}
|
||||
|
||||
It "Should install a module correctly to the required location with AllUsers scope" {
|
||||
Install-Module -Name $ContosoServer -Repository $RepositoryName -Scope AllUsers
|
||||
$installedModuleInfo = Get-InstalledModule -Name $ContosoServer
|
||||
Install-Module -Name $TestModule -Repository $RepositoryName -Scope AllUsers
|
||||
$installedModuleInfo = Get-InstalledModule -Name $TestModule
|
||||
|
||||
$installedModuleInfo | Should -Not -BeNullOrEmpty
|
||||
$installedModuleInfo.Name | Should -Be $ContosoServer
|
||||
$installedModuleInfo.Name | Should -Be $TestModule
|
||||
$installedModuleInfo.InstalledLocation.StartsWith($script:programFilesModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
||||
|
||||
$module = Get-Module $ContosoServer -ListAvailable
|
||||
$module.Name | Should -Be $ContosoServer
|
||||
$module = Get-Module $TestModule -ListAvailable
|
||||
$module.Name | Should -Be $TestModule
|
||||
$module.ModuleBase | Should -Be $installedModuleInfo.InstalledLocation
|
||||
}
|
||||
|
||||
@@ -178,7 +177,7 @@ Describe "PowerShellGet - Module tests (Admin)" -Tags @('Feature', 'RequireAdmin
|
||||
|
||||
function Remove-InstalledScripts
|
||||
{
|
||||
Get-InstalledScript -Name $FabrikamServerScript -ErrorAction SilentlyContinue | Uninstall-Script -Force
|
||||
Get-InstalledScript -Name $TestScript -ErrorAction SilentlyContinue | Uninstall-Script -Force
|
||||
}
|
||||
|
||||
Describe "PowerShellGet - Script tests" -tags "Feature" {
|
||||
@@ -195,17 +194,17 @@ Describe "PowerShellGet - Script tests" -tags "Feature" {
|
||||
}
|
||||
|
||||
It "Should find a script correctly" {
|
||||
$psgetScriptInfo = Find-Script -Name $FabrikamServerScript -Repository $RepositoryName
|
||||
$psgetScriptInfo.Name | Should -Be $FabrikamServerScript
|
||||
$psgetScriptInfo = Find-Script -Name $TestScript -Repository $RepositoryName
|
||||
$psgetScriptInfo.Name | Should -Be $TestScript
|
||||
$psgetScriptInfo.Repository | Should -Be $RepositoryName
|
||||
}
|
||||
|
||||
It "Should install a script correctly to the required location with default CurrentUser scope" {
|
||||
Install-Script -Name $FabrikamServerScript -Repository $RepositoryName -NoPathUpdate
|
||||
$installedScriptInfo = Get-InstalledScript -Name $FabrikamServerScript
|
||||
Install-Script -Name $TestScript -Repository $RepositoryName -NoPathUpdate
|
||||
$installedScriptInfo = Get-InstalledScript -Name $TestScript
|
||||
|
||||
$installedScriptInfo | Should -Not -BeNullOrEmpty
|
||||
$installedScriptInfo.Name | Should -Be $FabrikamServerScript
|
||||
$installedScriptInfo.Name | Should -Be $TestScript
|
||||
$installedScriptInfo.InstalledLocation.StartsWith($script:MyDocumentsScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
||||
}
|
||||
|
||||
@@ -228,11 +227,11 @@ Describe "PowerShellGet - Script tests (Admin)" -Tags @('Feature', 'RequireAdmin
|
||||
}
|
||||
|
||||
It "Should install a script correctly to the required location with AllUsers scope" {
|
||||
Install-Script -Name $FabrikamServerScript -Repository $RepositoryName -NoPathUpdate -Scope AllUsers
|
||||
$installedScriptInfo = Get-InstalledScript -Name $FabrikamServerScript
|
||||
Install-Script -Name $TestScript -Repository $RepositoryName -NoPathUpdate -Scope AllUsers
|
||||
$installedScriptInfo = Get-InstalledScript -Name $TestScript
|
||||
|
||||
$installedScriptInfo | Should -Not -BeNullOrEmpty
|
||||
$installedScriptInfo.Name | Should -Be $FabrikamServerScript
|
||||
$installedScriptInfo.Name | Should -Be $TestScript
|
||||
$installedScriptInfo.InstalledLocation.StartsWith($script:ProgramFilesScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
||||
}
|
||||
|
||||
@@ -272,8 +271,3 @@ Describe 'PowerShellGet Type tests' -tags @('CI') {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($RegisteredINTRepo)
|
||||
{
|
||||
Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue | Unregister-PSRepository
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user