Skip to content
This repository was archived by the owner on Jul 19, 2024. It is now read-only.

Commit 81d475c

Browse files
Feature/improved docker tests (#74)
* Make sure the Ubuntu image is available before running tests (dependency) * Check that the test report dir exists before exporting it.
1 parent 20ca5e8 commit 81d475c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Source/Public/Invoke-DockerTests.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ function Invoke-DockerTests {
5050
}
5151

5252
$testReportPath = Join-Path $absoluteTestReportDir $TestReportName
53+
$testReportExists = Test-Path -Path $testReportPath -PathType Leaf
54+
if ($testReportExists) {
55+
$testResult = $(ConvertFrom-Json $(Get-Content $testReportPath))
56+
}
5357

5458
$result = [PSCustomObject]@{
5559
# Todo: Need to check if the test report folder is missing.
5660
# It should not crash when folder is not there, but should simply return nothing
57-
'TestResult' = $(ConvertFrom-Json $(Get-Content $testReportPath))
61+
'TestResult' = $testResult
5862
'TestReportPath' = $testReportPath
5963
'CommandResult' = $commandResult
6064
'ImageName' = $ImageName

Test-Source/Invoke-DockerTests.Tests.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Describe 'Run docker tests using Google Structure' {
99

1010
Context 'Running structure tests' {
1111

12+
BeforeAll {
13+
Invoke-DockerPull -ImageName 'ubuntu' -Tag 'latest'
14+
}
15+
1216
BeforeEach {
1317
$script:backupLocation = Get-Location
1418
Set-Location $Global:TestDataDir
@@ -141,6 +145,7 @@ Describe 'Run docker tests using Google Structure' {
141145
$testResult.Fail | Should -Be 0
142146
$testResult.Results.Length | Should -Be 2
143147
}
148+
144149
}
145150

146151
Context 'Pipeline execution' {

0 commit comments

Comments
 (0)