Skip to content

Commit

Permalink
fix BeforeAll (do Get-DbaEstimatedCompletionTime)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasjordan committed Oct 20, 2024
1 parent 036e817 commit 9ecffea
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/Get-DbaEstimatedCompletionTime.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Describe "$commandname Integration Tests" -Tags "IntegrationTests" {

BeforeAll {
$skip = $true
if ($script:bigDatabaseBackup) {
if (-not (Test-Path -Path $script:bigDatabaseBackup) -and $script:bigDatabaseBackupSourceUrl) {
Write-Host 'Starting Download'
Invoke-WebRequest -Uri $script:bigDatabaseBackupSourceUrl -OutFile $script:bigDatabaseBackup
try {
if (-not (Test-Path -Path $script:bigDatabaseBackup) -and $script:bigDatabaseBackupSourceUrl) {
Write-Host 'Starting Download'
Invoke-WebRequest -Uri $script:bigDatabaseBackupSourceUrl -OutFile $script:bigDatabaseBackup
}
$null = Restore-DbaDatabase -SqlInstance $script:instance2 -Path $script:bigDatabaseBackup -DatabaseName checkdbTestDatabase -WithReplace -ReplaceDbNameInFile -EnableException
$null = New-DbaAgentJob -SqlInstance $script:instance2 -Job checkdbTestJob -EnableException
$null = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job checkdbTestJob -StepName checkdb -Subsystem TransactSql -Command "DBCC CHECKDB('checkdbTestDatabase')" -EnableException
$skip = $false
} catch {
Write-Warning -Message "Test for $commandname failed in BeforeAll because: $_"
}
$null = Restore-DbaDatabase -SqlInstance $script:instance2 -Path $script:bigDatabaseBackup -DatabaseName checkdbTestDatabase -WithReplace -ReplaceDbNameInFile -EnableException
$null = New-DbaAgentJob -SqlInstance $script:instance2 -Job checkdbTestJob -EnableException
$null = New-DbaAgentJobStep -SqlInstance $script:instance2 -Job checkdbTestJob -StepName checkdb -Subsystem TransactSql -Command "DBCC CHECKDB('checkdbTestDatabase')" -EnableException
$skip = $false
} else {
$skip = $true
}
}

Expand Down

0 comments on commit 9ecffea

Please sign in to comment.