26 lines
988 B
PowerShell
26 lines
988 B
PowerShell
|
. $PSScriptRoot\..\..\Load-PesterModules.ps1
|
|||
|
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|||
|
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.'
|
|||
|
$functionPath = Join-Path -Path $here -ChildPath $sut
|
|||
|
Write-Host "Overriding SUT: $functionPath"
|
|||
|
Import-Module $functionPath -Force
|
|||
|
$moduleForMock = ""
|
|||
|
|
|||
|
Describe "Invoke-SCExe" {
|
|||
|
Context "returns `$LASTEXITCODE -1" {
|
|||
|
Mock -ModuleName $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -MockWith { $global:LASTEXITCODE = -1; return "This is output" }
|
|||
|
|
|||
|
It "throws as expected" {
|
|||
|
{ Invoke-SCExe @("ignore") } | Should -Throw
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
Context "returns `$LASTEXITCODE 0" {
|
|||
|
Mock -ModuleName $moduleForMock -CommandName Invoke-CallOperatorWithPathAndParameters -MockWith { $global:LASTEXITCODE = 0; return "This is output" }
|
|||
|
|
|||
|
It "throws as expected" {
|
|||
|
{ Invoke-SCExe @("ignore") } | Should -Not -Throw
|
|||
|
}
|
|||
|
}
|
|||
|
}
|