Enable more tests to be run in a container. (#17294)

This commit is contained in:
James Truher [MSFT]
2022-05-11 12:30:22 -07:00
committed by GitHub
parent 514d6f62e0
commit 1a24540e31
7 changed files with 50 additions and 64 deletions
@@ -42,6 +42,7 @@ Describe 'Online help tests for PowerShell Cmdlets' -Tags "Feature" {
# TopicTitle - is the cmdlet name in the csv file
# HelpURI - is the expected help URI in the csv file
# If this is correct, then launching the cmdlet should open the expected help URI.
It "Validate 'get-help $($cmdlet.TopicTitle) -Online'" -Skip:$skipTest {
$actualURI = Get-Help $cmdlet.TopicTitle -Online
@@ -52,48 +53,6 @@ Describe 'Online help tests for PowerShell Cmdlets' -Tags "Feature" {
}
}
Describe 'Get-Help -Online opens the default web browser and navigates to the cmdlet help content' -Tags "Feature" {
$skipTest = [System.Management.Automation.Platform]::IsIoT -or
[System.Management.Automation.Platform]::IsNanoServer -or
$env:__INCONTAINER -eq 1
# this code is a workaround for issue: https://github.com/PowerShell/PowerShell/issues/3079
if((-not ($skipTest)) -and $IsWindows)
{
$skipTest = $true
$regKey = "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice"
try
{
$progId = (Get-ItemProperty $regKey).ProgId
if($progId)
{
if (-not (Test-Path 'HKCR:\'))
{
New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT -Name HKCR | Should -Not -BeNullOrEmpty
}
$browserExe = ((Get-ItemProperty "HKCR:\$progId\shell\open\command")."(default)" -replace '"', '') -split " "
if ($browserExe.count -ge 1)
{
if($browserExe[0] -match '.exe')
{
$skipTest = $false
}
}
}
}
catch
{
# We are not able to access Registry, skipping test.
}
}
It "Get-Help get-process -online" -Skip:$skipTest {
{ Get-Help get-process -Online } | Should -Not -Throw
}
}
Describe 'Get-Help -Online is not supported on Nano Server and IoT' -Tags "CI" {
$skipTest = -not ([System.Management.Automation.Platform]::IsIoT -or [System.Management.Automation.Platform]::IsNanoServer)
@@ -578,7 +578,7 @@ Describe "Help failure cases" -Tags Feature {
# under some conditions this does not throw, so include what we actually got
$helpTopic = [guid]::NewGuid().ToString("N")
{ & $command $helpTopic -ErrorAction Stop } | Should -Throw -ErrorId "HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand" -Because "$(& $command $helpTopic -ea Ignore)"
{ & $command $helpTopic -ErrorAction Stop } | Should -Throw -ErrorId "HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand" -Because "A help topic was unexpectantly found for $helpTopic"
}
}