@@ -103,6 +103,66 @@ Describe "deploy.ps1 integration tests" -Tag $commandName, IntegrationTests {
103103 ' c' | Should Not BeIn $testResults.name
104104 ' d' | Should Not BeIn $testResults.name
105105 }
106+ It " should deploy with no components loaded" {
107+ $scriptBlock = {
108+ param (
109+ $Path ,
110+ $DotSource ,
111+ $Database
112+ )
113+ . $DotSource
114+ $testResults = & $Path \deploy.ps1 - SqlInstance $script :mssqlInstance - Credential $script :mssqlCredential - Database $Database - Silent
115+ $testResults.Successful | Should - Be $true
116+ $testResults.Scripts.Name | Should -Not - BeNullOrEmpty
117+ $testResults.SqlInstance | Should - Be $script :mssqlInstance
118+ $testResults.Database | Should Be $Database
119+ $testResults.SourcePath | Should Be $Path
120+ $testResults.ConnectionType | Should Be ' SQLServer'
121+ $testResults.Configuration.SchemaVersionTable | Should Be ' SchemaVersions'
122+ $testResults.Error | Should BeNullOrEmpty
123+ $testResults.Duration.TotalMilliseconds | Should - BeGreaterOrEqual 0
124+ $testResults.StartTime | Should -Not - BeNullOrEmpty
125+ $testResults.EndTime | Should -Not - BeNullOrEmpty
126+ $testResults.EndTime | Should - BeGreaterOrEqual $testResults.StartTime
127+ Get-ChildItem function:\ | Where-Object Name -eq Invoke-DBODeployment | Should - BeNullOrEmpty
128+ }
129+ $job = Start-Job - ScriptBlock $scriptBlock - ArgumentList $workFolder , " $here \constants.ps1" , $newDbName
130+ $job | Wait-Job | Receive-Job - ErrorAction Stop
131+ # # Get modules
132+ # $modules = Get-Module Pester | Select-Object -ExpandProperty Path
133+ # $sessionstate = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
134+ # foreach ($modulePath in $modules) {
135+ # $sessionstate.ImportPSModule($modulePath)
136+ # }
137+ # # Create runspace pool
138+ # $runspacepool = [runspacefactory]::CreateRunspacePool(1, 5, $sessionstate, $Host)
139+ # $runspacepool.Open()
140+ # $powershell = [powershell]::Create()
141+ # $params = @{
142+ # Path = $workFolder
143+ # Instance = $script:mssqlInstance
144+ # Credential = $script:mssqlCredential
145+ # Database = $newDbName
146+ # }
147+ # [void]$powershell.AddScript($scriptBlock).AddParameters($params)
148+ # $powershell.RunspacePool = $runspacepool
149+ # try {
150+ # $handle = $powershell.BeginInvoke()
151+ # $cycles = 0
152+ # do { Start-Sleep 1; $cycles++ } while (-not $handle.IsCompleted -and $cycles -lt 5)
153+ # if ($powershell.Streams.Error.Count -gt 0) {
154+ # throw $powershell.Streams.Error[0]
155+ # }
156+ # $powershell.EndInvoke($handle)
157+ # }
158+ # catch {
159+ # throw $_
160+ # }
161+ # finally {
162+ # $powershell.Dispose()
163+ # $runspacepool.Close()
164+ # }
165+ }
106166 }
107167 Context " $commandName whatif tests" {
108168 BeforeAll {
0 commit comments