Skip to content

Commit 4e0086b

Browse files
committed
Wrote tests for both Start-Job and Start-ThreadJob
1 parent 4c1e05c commit 4e0086b

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Tests/Rules/UseUsingScopeModifierInNewRunspaces.tests.ps1

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ Describe "UseUsingScopeModifierInNewRunspaces" {
146146
}
147147

148148
Context "Should not detect anything" {
149-
150149
It "should not emit anything for: <Description>" {
151150
[System.Array] $warnings = Invoke-ScriptAnalyzer -ScriptDefinition $ScriptBlock -Settings $settings
152151
$warnings.Count | Should -Be 0
@@ -293,11 +292,25 @@ Describe "UseUsingScopeModifierInNewRunspaces" {
293292
}
294293
}'
295294
}
296-
# Script block with variables in params(), issue #1504: https://github.com/PowerShell/PSScriptAnalyzer/issues/1504
295+
# ScriptBlock with variables in params(), issue #1504: https://github.com/PowerShell/PSScriptAnalyzer/issues/1504
296+
## Microsoft.PowerShell.Core \ Start-Job
297297
@{
298-
Description = 'Does not throw when variable is defined inside params()'
298+
Description = 'Does not throw when variable is defined inside params() - Start-Job'
299299
ScriptBlock = '{
300-
300+
Start-Job -ScriptBlock {
301+
Param($Foo)
302+
$Foo
303+
} -ArgumentList "Bar" | Receive-Job -Wait -AutoRemoveJob
304+
}'
305+
}
306+
## Microsoft.PowerShell.ThreadJob \ Start-ThreadJob
307+
@{
308+
Description = 'Does not throw when variable is defined inside params() - Start-Job'
309+
ScriptBlock = '{
310+
Start-ThreadJob -ScriptBlock {
311+
Param($Foo)
312+
$Foo
313+
} -ArgumentList "Bar" | Receive-Job -Wait -AutoRemoveJob
301314
}'
302315
}
303316
)

0 commit comments

Comments
 (0)