Skip to content

Commit de6db36

Browse files
authored
Install-DbaMaintenanceSolution.Tests: make the additional backup parameters tests run (#10145)
1 parent 1cdc5d2 commit de6db36

1 file changed

Lines changed: 39 additions & 14 deletions

File tree

tests/Install-DbaMaintenanceSolution.Tests.ps1

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,17 @@ Describe $CommandName -Tag IntegrationTests {
127127

128128
# Clean up any leftover Hallengren procedures in tempdb from the first Context
129129
$cleanupTempdb = "
130-
IF OBJECT_ID('tempdb.dbo.CommandExecute', 'P') IS NOT NULL DROP PROCEDURE tempdb.dbo.CommandExecute;
131-
IF OBJECT_ID('tempdb.dbo.DatabaseBackup', 'P') IS NOT NULL DROP PROCEDURE tempdb.dbo.DatabaseBackup;
132-
IF OBJECT_ID('tempdb.dbo.DatabaseIntegrityCheck', 'P') IS NOT NULL DROP PROCEDURE tempdb.dbo.DatabaseIntegrityCheck;
133-
IF OBJECT_ID('tempdb.dbo.IndexOptimize', 'P') IS NOT NULL DROP PROCEDURE tempdb.dbo.IndexOptimize;
134-
IF OBJECT_ID('tempdb.dbo.CommandLog', 'U') IS NOT NULL DROP TABLE tempdb.dbo.CommandLog;
135-
IF OBJECT_ID('tempdb.dbo.Queue', 'U') IS NOT NULL DROP TABLE tempdb.dbo.Queue;
136-
IF OBJECT_ID('tempdb.dbo.QueueDatabase', 'U') IS NOT NULL DROP TABLE tempdb.dbo.QueueDatabase;
130+
IF OBJECT_ID('dbo.CommandExecute', 'P') IS NOT NULL DROP PROCEDURE dbo.CommandExecute;
131+
IF OBJECT_ID('dbo.DatabaseBackup', 'P') IS NOT NULL DROP PROCEDURE dbo.DatabaseBackup;
132+
IF OBJECT_ID('dbo.DatabaseIntegrityCheck', 'P') IS NOT NULL DROP PROCEDURE dbo.DatabaseIntegrityCheck;
133+
IF OBJECT_ID('dbo.IndexOptimize', 'P') IS NOT NULL DROP PROCEDURE dbo.IndexOptimize;
134+
IF OBJECT_ID('dbo.CommandLog', 'U') IS NOT NULL DROP TABLE dbo.CommandLog;
135+
IF OBJECT_ID('dbo.Queue', 'U') IS NOT NULL DROP TABLE dbo.Queue;
136+
IF OBJECT_ID('dbo.QueueDatabase', 'U') IS NOT NULL DROP TABLE dbo.QueueDatabase;
137137
"
138138
$splatCleanupTempdb = @{
139139
SqlInstance = $TestConfig.InstanceMulti2
140+
Database = "tempdb"
140141
Query = $cleanupTempdb
141142
}
142143
Invoke-DbaQuery @splatCleanupTempdb
@@ -185,7 +186,11 @@ Describe $CommandName -Tag IntegrationTests {
185186
$PSDefaultParameterValues.Remove("*-Dba*:EnableException")
186187
}
187188

188-
It "Should add ChangeBackupType parameter to DIFF backup job" -Skip:(-not $script:installationSucceeded) {
189+
It "Should add ChangeBackupType parameter to DIFF backup job" {
190+
if (-not $script:installationSucceeded) {
191+
Set-ItResult -Skipped -Because "Installation failed"
192+
return
193+
}
189194
$splatJobStep = @{
190195
SqlInstance = $TestConfig.InstanceMulti2
191196
Job = "DatabaseBackup - USER_DATABASES - DIFF"
@@ -194,7 +199,11 @@ Describe $CommandName -Tag IntegrationTests {
194199
$jobStep.Command | Should -Match "@ChangeBackupType = 'Y'"
195200
}
196201

197-
It "Should add ChangeBackupType parameter to LOG backup job" -Skip:(-not $script:installationSucceeded) {
202+
It "Should add ChangeBackupType parameter to LOG backup job" {
203+
if (-not $script:installationSucceeded) {
204+
Set-ItResult -Skipped -Because "Installation failed"
205+
return
206+
}
198207
$splatJobStep = @{
199208
SqlInstance = $TestConfig.InstanceMulti2
200209
Job = "DatabaseBackup - USER_DATABASES - LOG"
@@ -203,7 +212,11 @@ Describe $CommandName -Tag IntegrationTests {
203212
$jobStep.Command | Should -Match "@ChangeBackupType = 'Y'"
204213
}
205214

206-
It "Should NOT add ChangeBackupType parameter to FULL backup job" -Skip:(-not $script:installationSucceeded) {
215+
It "Should NOT add ChangeBackupType parameter to FULL backup job" {
216+
if (-not $script:installationSucceeded) {
217+
Set-ItResult -Skipped -Because "Installation failed"
218+
return
219+
}
207220
$splatJobStep = @{
208221
SqlInstance = $TestConfig.InstanceMulti2
209222
Job = "DatabaseBackup - USER_DATABASES - FULL"
@@ -212,7 +225,11 @@ Describe $CommandName -Tag IntegrationTests {
212225
$jobStep.Command | Should -Not -Match "@ChangeBackupType = 'Y'"
213226
}
214227

215-
It "Should add Compress parameter to all backup jobs" -Skip:(-not $script:installationSucceeded) {
228+
It "Should add Compress parameter to all backup jobs" {
229+
if (-not $script:installationSucceeded) {
230+
Set-ItResult -Skipped -Because "Installation failed"
231+
return
232+
}
216233
$splatJobStep = @{
217234
SqlInstance = $TestConfig.InstanceMulti2
218235
Job = "DatabaseBackup - USER_DATABASES - FULL"
@@ -221,7 +238,11 @@ Describe $CommandName -Tag IntegrationTests {
221238
$jobStep.Command | Should -Match "@Compress = 'Y'"
222239
}
223240

224-
It "Should have Verify parameter set to Y in backup jobs" -Skip:(-not $script:installationSucceeded) {
241+
It "Should have Verify parameter set to Y in backup jobs" {
242+
if (-not $script:installationSucceeded) {
243+
Set-ItResult -Skipped -Because "Installation failed"
244+
return
245+
}
225246
$splatJobStep = @{
226247
SqlInstance = $TestConfig.InstanceMulti2
227248
Job = "DatabaseBackup - USER_DATABASES - FULL"
@@ -230,7 +251,11 @@ Describe $CommandName -Tag IntegrationTests {
230251
$jobStep.Command | Should -Match "@Verify = 'Y'"
231252
}
232253

233-
It "Should have CheckSum parameter set to Y in backup jobs" -Skip:(-not $script:installationSucceeded) {
254+
It "Should have CheckSum parameter set to Y in backup jobs" {
255+
if (-not $script:installationSucceeded) {
256+
Set-ItResult -Skipped -Because "Installation failed"
257+
return
258+
}
234259
$splatJobStep = @{
235260
SqlInstance = $TestConfig.InstanceMulti2
236261
Job = "DatabaseBackup - USER_DATABASES - FULL"
@@ -239,4 +264,4 @@ Describe $CommandName -Tag IntegrationTests {
239264
$jobStep.Command | Should -Match "@CheckSum = 'Y'"
240265
}
241266
}
242-
}
267+
}

0 commit comments

Comments
 (0)