Skip to content

Commit 64cf9e3

Browse files
committed
Backup-SqlDscDatabase.Integration.Tests: Update tests to suppress unnecessary throw checks for backup commands
1 parent 1930433 commit 64cf9e3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/Integration/Commands/Backup-SqlDscDatabase.Integration.Tests.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
8585
}
8686

8787
It 'Should perform a full backup successfully' {
88-
{ Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:fullBackupFile -Force } | Should -Not -Throw
88+
$null = Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:fullBackupFile -Force
8989

9090
# Verify the backup file was created
9191
Test-Path -Path $script:fullBackupFile | Should -BeTrue
@@ -108,7 +108,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
108108
}
109109

110110
It 'Should perform a full backup successfully using database object' {
111-
{ $script:testDatabase | Backup-SqlDscDatabase -BackupFile $script:fullBackupFileFromObject -Force } | Should -Not -Throw
111+
$null = $script:testDatabase | Backup-SqlDscDatabase -BackupFile $script:fullBackupFileFromObject -Force
112112

113113
# Verify the backup file was created
114114
Test-Path -Path $script:fullBackupFileFromObject | Should -BeTrue
@@ -128,7 +128,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
128128
}
129129

130130
It 'Should perform a copy-only backup successfully' {
131-
{ Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:copyOnlyBackupFile -CopyOnly -Force } | Should -Not -Throw
131+
$null = Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:copyOnlyBackupFile -CopyOnly -Force
132132

133133
# Verify the backup file was created
134134
Test-Path -Path $script:copyOnlyBackupFile | Should -BeTrue
@@ -141,7 +141,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
141141
$script:baseFullBackupFile = Join-Path -Path $script:backupDirectory -ChildPath ($script:testDatabaseName + '_BaseFull.bak')
142142
$script:diffBackupFile = Join-Path -Path $script:backupDirectory -ChildPath ($script:testDatabaseName + '_Diff.bak')
143143

144-
Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:baseFullBackupFile -Force
144+
$null = Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:baseFullBackupFile -Force
145145
}
146146

147147
AfterAll {
@@ -157,7 +157,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
157157
}
158158

159159
It 'Should perform a differential backup successfully' {
160-
{ Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:diffBackupFile -BackupType 'Differential' -Force } | Should -Not -Throw
160+
$null = Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:diffBackupFile -BackupType 'Differential' -Force
161161

162162
# Verify the backup file was created
163163
Test-Path -Path $script:diffBackupFile | Should -BeTrue
@@ -170,7 +170,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
170170
$script:baseFullBackupForLog = Join-Path -Path $script:backupDirectory -ChildPath ($script:testDatabaseName + '_BaseFullForLog.bak')
171171
$script:logBackupFile = Join-Path -Path $script:backupDirectory -ChildPath ($script:testDatabaseName + '_Log.trn')
172172

173-
Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:baseFullBackupForLog -Force
173+
$null = Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:baseFullBackupForLog -Force
174174
}
175175

176176
AfterAll {
@@ -186,7 +186,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
186186
}
187187

188188
It 'Should perform a transaction log backup successfully' {
189-
{ Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:logBackupFile -BackupType 'Log' -Force } | Should -Not -Throw
189+
$null = Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:logBackupFile -BackupType 'Log' -Force
190190

191191
# Verify the backup file was created
192192
Test-Path -Path $script:logBackupFile | Should -BeTrue
@@ -206,7 +206,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
206206
}
207207

208208
It 'Should perform a compressed backup with checksum successfully' {
209-
{ Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:compressedBackupFile -Compress -Checksum -Force } | Should -Not -Throw
209+
$null = Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:compressedBackupFile -Compress -Checksum -Force
210210

211211
# Verify the backup file was created
212212
Test-Path -Path $script:compressedBackupFile | Should -BeTrue
@@ -226,7 +226,7 @@ Describe 'Backup-SqlDscDatabase' -Tag @('Integration_SQL2017', 'Integration_SQL2
226226
}
227227

228228
It 'Should perform a backup with description and retention days successfully' {
229-
{ Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:backupWithDescFile -Description 'Integration test backup' -RetainDays 7 -Force } | Should -Not -Throw
229+
$null = Backup-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -BackupFile $script:backupWithDescFile -Description 'Integration test backup' -RetainDays 7 -Force
230230

231231
# Verify the backup file was created
232232
Test-Path -Path $script:backupWithDescFile | Should -BeTrue

0 commit comments

Comments
 (0)