forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontainer.tests.ps1
More file actions
105 lines (89 loc) · 3.19 KB
/
container.tests.ps1
File metadata and controls
105 lines (89 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
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.2'
}
}
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.2'
}
}