Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions InvokeHelperTest/public/Start-MyJob.test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@ function InvokeHelperTest_JobInternal_Start{

function InvokeHelperTest_JobInternal_Start_WhatIf{
$jobs = @()
$jobs += Start-MyJob -Command "command to be called1" -WhatIf @InfoParameters
Assert-Contains -Expected "command to be called1" -Presented $infoVar
$jobs += Start-MyJob -Command "return 1" -WhatIf @InfoParameters
Assert-Contains -Expected "return 1" -Presented $infoVar

$jobs += Start-MyJob -Command "command to be called2" -WhatIf @InfoParameters
Assert-Contains -Expected "command to be called2" -Presented $infoVar
$jobs += Start-MyJob -Command "return 2" -WhatIf @InfoParameters
Assert-Contains -Expected "return 2" -Presented $infoVar

$waited = Wait-Job -Job $jobs

$result = Receive-Job -Job $waited

Assert-Count -Expected 2 -Presented $result
Assert-IsNull -Object $result[0]
Assert-IsNull -Object $result[1]
Assert-isnull -Object $result
}

function InvokeHelperTest_JobInternal_Start_MultiCall{
Expand Down
4 changes: 2 additions & 2 deletions public/Invoke-MyCommandAsync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ function Invoke-MyCommandAsync {
$scriptBlock = New-ScriptBlock -Command $cmd

if ($PSCmdlet.ShouldProcess("Target", "Operation")) {
$job = Start-Job -ScriptBlock $scriptBlock
$job = Start-ThreadJob -ScriptBlock $scriptBlock
} else {
Write-Information $scriptBlock
$job = Start-Job -ScriptBlock {$null}
$job = Start-ThreadJob -ScriptBlock {$null}
}

$jobs += $job
Expand Down
4 changes: 2 additions & 2 deletions public/Start-MyJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ function Start-MyJob{
$scriptBlock = New-ScriptBlock -Command $cmd

if ($PSCmdlet.ShouldProcess("Target", "Operation")) {
$job = Start-Job -ScriptBlock $scriptBlock
$job = Start-ThreadJob -ScriptBlock $scriptBlock
} else {
Write-Information $scriptBlock
$job = Start-Job -ScriptBlock {$null}
$job = Start-ThreadJob -ScriptBlock {$null}
}

return $job
Expand Down
Loading