Skip to content

Commit ee67416

Browse files
committed
run as runspace
1 parent 06d99cd commit ee67416

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

tests/deploy.ps1.Tests.ps1

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,26 @@ Describe "deploy.ps1 integration tests" -Tag $commandName, IntegrationTests {
125125
$testResults.EndTime | Should -Not -BeNullOrEmpty
126126
$testResults.EndTime | Should -BeGreaterOrEqual $testResults.StartTime
127127
}
128-
$job = Start-Job -ScriptBlock $scriptBlock -ArgumentList $workFolder, $script:mssqlInstance, $script:mssqlCredential, $newDbName
129-
$job | Wait-Job | Receive-Job -ErrorAction Stop
128+
# Get modules
129+
$modules = Get-Module dbops, PSFramework, Pester | Select-Object -ExpandProperty Path
130+
$sessionstate = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
131+
foreach ($modulePath in $modules) {
132+
$sessionstate.ImportPSModule($modulePath)
133+
}
134+
#Create runspace pool
135+
$runspacepool = [runspacefactory]::CreateRunspacePool(1, 5, $sessionstate, $Host)
136+
$runspacepool.Open()
137+
$script:runspaces = New-Object System.Collections.ArrayList
138+
$powershell = [powershell]::Create()
139+
$params = @{
140+
Path = $workFolder
141+
Instance = $script:mssqlInstance
142+
Credential = $script:mssqlCredential
143+
Database = $newDbName
144+
}
145+
[void]$powershell.AddScript($scriptBlock).AddParameters($params)
146+
$powershell.RunspacePool = $runspacepool
147+
$powershell.Invoke()
130148
}
131149
}
132150
Context "$commandName whatif tests" {

0 commit comments

Comments
 (0)