Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mthalman committed Jun 29, 2024
1 parent c5224a2 commit 1e32ff2
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions container/tests/check-image.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@ Describe 'Get result' {
$result | ConvertTo-Json
} -ParameterFilter { $Command -eq "dredge image compare layers --output json $baseImage $targetImage --os linux --arch $architecture" } `
-ModuleName common
& $targetScript -TargetImage $targetImage -BaseImage $baseImage -Architecture $architecture | Should -Be "false"

Mock Invoke-Expression {
"base-digest"
} -ParameterFilter { $Command -eq "dredge manifest resolve $baseImage --os linux --arch $architecture" } `
-ModuleName common

Mock Invoke-Expression {
"target-digest"
} -ParameterFilter { $Command -eq "dredge manifest resolve $targetImage --os linux --arch $architecture" } `
-ModuleName common
$result = & $targetScript -TargetImage $targetImage -BaseImage $baseImage -Architecture $architecture

$expected = @{
sendDispatch = "false"
updates = @()
} | ConvertTo-Json

$result | Should -Be $expected
}

It 'Given a target image that is not up-to-date with the base image, it returns true' {
Expand All @@ -35,8 +52,32 @@ Describe 'Get result' {
$result | ConvertTo-Json
} -ParameterFilter { $Command -eq "dredge image compare layers --output json $baseImage $targetImage --os linux --arch $architecture" } `
-ModuleName common

Mock Invoke-Expression {
"base-digest"
} -ParameterFilter { $Command -eq "dredge manifest resolve $baseImage --os linux --arch $architecture" } `
-ModuleName common

Mock Invoke-Expression {
"target-digest"
} -ParameterFilter { $Command -eq "dredge manifest resolve $targetImage --os linux --arch $architecture" } `
-ModuleName common
$result = & $targetScript -TargetImage $targetImage -BaseImage $baseImage -Architecture $architecture

$expected = @{
sendDispatch = "true"
updates = @(
@{
targetImageName = $targetImage
targetImageDigest = "target-digest"
dockerfile = ""
baseImageName = $baseImage
baseImageDigest = "base-digest"
}
)
} | ConvertTo-Json

& $targetScript -TargetImage $targetImage -BaseImage $baseImage -Architecture $architecture | Should -Be "true"
$result | Should -Be $expected
}

It 'Given a failed dredge command, it throws an error' {
Expand Down

0 comments on commit 1e32ff2

Please sign in to comment.