Skip to content

Commit 05ed031

Browse files
authored
tests: fix function to test for docker OS due to change to use linuxkit for mac (PowerShell#5843)
* Also, fix syntax issues to allow to work with released Pester
1 parent bb6823d commit 05ed031

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

docker/tests/container.tests.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ Describe "Linux Containers run PowerShell" -Tags 'Behavior', 'Linux' {
5757
# prune unused volumes
5858
$null=Invoke-Docker -Command 'volume', 'prune' -Params '--force' -SuppressHostOutput
5959
}
60-
BeforeEach
61-
{
60+
BeforeEach {
6261
Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue
6362
Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue
6463
}
@@ -82,8 +81,7 @@ Describe "Windows Containers run PowerShell" -Tags 'Behavior', 'Windows' {
8281
BeforeAll{
8382
$testContext = Get-TestContext -type Windows
8483
}
85-
BeforeEach
86-
{
84+
BeforeEach {
8785
Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue
8886
Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue
8987
}

docker/tests/containerTestCommon.psm1

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,27 @@ function Test-SkipWindows
110110

111111
function Test-SkipLinux
112112
{
113-
return !((Get-DockerEngineOs) -like 'Alpine Linux*')
113+
$os = Get-DockerEngineOs
114+
115+
switch -wildcard ($os)
116+
{
117+
'*Linux*' {
118+
return $false
119+
}
120+
'*Mac' {
121+
return $false
122+
}
123+
# Docker for Windows means we are running the linux kernel
124+
'Docker for Windows' {
125+
return $false
126+
}
127+
'Windows*' {
128+
return $true
129+
}
130+
default {
131+
throw "Unknow docker os '$os'"
132+
}
133+
}
114134
}
115135

116136
function Get-TestContext

0 commit comments

Comments
 (0)