Skip to content

Commit

Permalink
Update version mismatch error expectations to match changed error
Browse files Browse the repository at this point in the history
  • Loading branch information
jpalermo committed Jul 7, 2022
1 parent e2f860d commit 803ae5c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions stemcell-automation/AutomationHelpers.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -590,19 +590,19 @@ Describe "Validate-OSVersion" {
It "fails gracefully when the OS major version doesn't match" {
Mock Get-OSVersionString { "$($major2019 + 1).$minor2019.$build2019.$revision2019" }

{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 as the OS on your targeted VM"
{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 or 2022 as the OS on your targeted VM"

Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 as the OS on your targeted VM" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 or 2022 as the OS on your targeted VM" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "Failed to validate the OS version. See 'c:\provision\log.log' for more info." }
Assert-MockCalled Get-OSVersionString -Times 1 -Scope It
}

It "fails gracefully when the OS minor version doesn't match" {
Mock Get-OSVersionString { "$major2019.$($minor2019 + 1).$build2019.$revision2019" }

{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 as the OS on your targeted VM"
{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 or 2022 as the OS on your targeted VM"

Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 as the OS on your targeted VM" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 or 2022 as the OS on your targeted VM" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "Failed to validate the OS version. See 'c:\provision\log.log' for more info." }
Assert-MockCalled Get-OSVersionString -Times 1 -Scope It

Expand All @@ -611,9 +611,9 @@ Describe "Validate-OSVersion" {
It "fails gracefully when the OS build version doesn't match" {
Mock Get-OSVersionString { "$major2019.$minor2019.$($build2019 + 1).$revision2019" }

{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 as the OS on your targeted VM"
{ Validate-OSVersion } | Should -Throw "OS Version Mismatch: Please use Windows Server 2019 or 2022 as the OS on your targeted VM"

Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 as the OS on your targeted VM" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "OS Version Mismatch: Please use Windows Server 2019 or 2022 as the OS on your targeted VM" }
Assert-MockCalled Write-Log -Times 1 -Scope It -ParameterFilter { $Message -eq "Failed to validate the OS version. See 'c:\provision\log.log' for more info." }
Assert-MockCalled Get-OSVersionString -Times 1 -Scope It
}
Expand Down

0 comments on commit 803ae5c

Please sign in to comment.