PowerShell/docker/tests/container.tests.ps1
Travis Plunk e49a81fe00 tests: fix function to test for docker OS due to change to use linuxkit for mac (#5843)
* Also, fix syntax issues to allow to work with released Pester
2018-01-23 16:10:45 -08:00

103 lines
3.1 KiB
PowerShell

Import-module -Name "$PSScriptRoot\containerTestCommon.psm1" -Force
$script:linuxContainerTests = Get-LinuxContainer
$script:windowsContainerTests = Get-WindowsContainer
$script:skipLinux = Test-SkipLinux
$script:skipWindows = Test-SkipWindows
Describe "Build Linux Containers" -Tags 'Build', 'Linux' {
BeforeAll {
Set-RepoName 'pscontainertest'
}
it "$(Get-RepoName):<Name> builds from '<path>'" -TestCases $script:linuxContainerTests -Skip:$script:skipLinux {
param(
[Parameter(Mandatory=$true)]
[string]
$name,
[Parameter(Mandatory=$true)]
[string]
$path
)
{ Invoke-Docker -Command build -Params '--pull', '--quiet', '-t', "$(Get-RepoName):${Name}", $path -SuppressHostOutput} | should not throw
}
}
Describe "Build Windows Containers" -Tags 'Build', 'Windows' {
BeforeAll {
Set-RepoName 'pscontainertest'
}
it "$(Get-RepoName):<Name> builds from '<path>'" -TestCases $script:windowsContainerTests -skip:$script:skipWindows {
param(
[Parameter(Mandatory=$true)]
[string]
$name,
[Parameter(Mandatory=$true)]
[string]
$path
)
{ Invoke-Docker -Command build -Params @(
'--pull'
'--quiet'
'-t'
"$(Get-RepoName):${Name}"
$path
) -SuppressHostOutput} | should not throw
}
}
Describe "Linux Containers run PowerShell" -Tags 'Behavior', 'Linux' {
BeforeAll{
$testContext = Get-TestContext -type Linux
}
AfterAll{
# prune unused volumes
$null=Invoke-Docker -Command 'volume', 'prune' -Params '--force' -SuppressHostOutput
}
BeforeEach {
Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue
Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue
}
it "Get PSVersion table from $(Get-RepoName):<Name>" -TestCases $script:linuxContainerTests -Skip:$script:skipLinux {
param(
[Parameter(Mandatory=$true)]
[string]
$name,
[Parameter(Mandatory=$true)]
[string]
$path
)
Get-ContainerPowerShellVersion -TestContext $testContext -Name $Name -RepoName (Get-RepoName) | should be '6.0.1'
}
}
Describe "Windows Containers run PowerShell" -Tags 'Behavior', 'Windows' {
BeforeAll{
$testContext = Get-TestContext -type Windows
}
BeforeEach {
Remove-Item $testContext.resolvedXmlPath -ErrorAction SilentlyContinue
Remove-Item $testContext.resolvedLogPath -ErrorAction SilentlyContinue
}
it "Get PSVersion table from $(Get-RepoName):<Name>" -TestCases $script:windowsContainerTests -skip:$script:skipWindows {
param(
[Parameter(Mandatory=$true)]
[string]
$name,
[Parameter(Mandatory=$true)]
[string]
$path
)
Get-ContainerPowerShellVersion -TestContext $testContext -Name $Name -RepoName (Get-RepoName) | should be '6.0.1'
}
}