Continued improvement to tests for release automation (#20182)

This commit is contained in:
James Truher [MSFT]
2023-09-06 10:36:48 -07:00
committed by GitHub
parent 65ec2dd4ed
commit 3f3d79d475
2 changed files with 33 additions and 3 deletions
@@ -83,7 +83,7 @@ try
$result = Get-Command NestedFn1 2> $null;
return ($result -ne $null)
'@
$isCommandAccessible = powershell.exe -noprofile -nologo -c $command
$isCommandAccessible = pwsh.exe -noprofile -nologo -c $command
}
finally
{
@@ -104,7 +104,24 @@ function Initialize
function Remove-InstalledModules
{
Get-InstalledModule -Name $TestModule -AllVersions -ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module -Force
try {
$mod = Get-InstalledModule -Name $TestModule -AllVersions -ErrorAction SilentlyContinue
if ($null -eq $mod) {
return
}
if (Get-Module -Name $TestModule -ErrorAction Ignore) {
Remove-Module -Force -Name $TestModule
}
$installedPath = $mod.InstalledLocation
if (Test-Path $installedPath) {
Remove-Item -Force -Recurse $installedPath -ErrorAction Ignore
}
}
catch {
Write-Warning "Remove-InstalledModules: $_"
}
}
Describe "PowerShellGet - Module tests" -tags "Feature" {
@@ -172,7 +189,20 @@ Describe "PowerShellGet - Module tests (Admin)" -Tags @('Feature', 'RequireAdmin
function Remove-InstalledScripts
{
Get-InstalledScript -Name $TestScript -ErrorAction SilentlyContinue | Uninstall-Script -Force
$installedScript = Get-InstalledScript -Name $TestScript -ErrorAction SilentlyContinue
if ($null -eq $installedScript) {
return
}
$scriptPath = Join-Path ${installedScript}.InstalledLocation "${TestScript}.ps1"
if (test-Path -Type Leaf -Path $scriptPath) {
Remove-Item -Force -Path $scriptPath -ErrorAction Ignore
}
$xmlPath = Join-Path ${installedScript}.InstalledLocation InstalledScriptInfos "${TestScript}_InstalledScriptInfo.xml"
if (test-Path -Type Leaf -Path $xmlPath) {
Remove-Item -Force -Path $xmlPath -ErrorAction Ignore
}
}
Describe "PowerShellGet - Script tests" -tags "Feature" {