You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor tests to suppress exceptions on command execution
- Updated multiple test files to assign command results to `$null` instead of using a block with `Should -Not -Throw` to improve readability and maintainability.
- This change applies to integration tests for `DSC_SqlTraceFlag` and `DSC_SqlWindowsFirewall`, as well as unit tests for `SqlDatabasePermission`, `SqlPermission`, `Remove-SqlDscRole`, `Set-SqlDscDatabasePermission`, `Set-SqlDscServerPermission`, and `SqlServerDsc.Common`.
Context 'When executing a query using ServerObject parameter set' {
80
80
Context 'When executing a query without returning results' {
81
81
It 'Should execute the query without throwing (using Force parameter)' {
82
-
{
83
-
Invoke-SqlDscQuery-ServerObject $script:serverObject-DatabaseName $script:testDatabaseName-Query 'UPDATE TestTable SET Value = 500 WHERE ID = 1'-Force -ErrorAction 'Stop'
84
-
} | Should -Not-Throw
82
+
$null=Invoke-SqlDscQuery-ServerObject $script:serverObject-DatabaseName $script:testDatabaseName-Query 'UPDATE TestTable SET Value = 500 WHERE ID = 1'-Force -ErrorAction 'Stop'
85
83
}
86
84
87
85
It 'Should execute the query without throwing (using Confirm:$false parameter)' {
88
-
{
89
-
Invoke-SqlDscQuery-ServerObject $script:serverObject-DatabaseName $script:testDatabaseName-Query 'UPDATE TestTable SET Value = 600 WHERE ID = 2'-Confirm:$false-ErrorAction 'Stop'
90
-
} | Should -Not-Throw
86
+
$null=Invoke-SqlDscQuery-ServerObject $script:serverObject-DatabaseName $script:testDatabaseName-Query 'UPDATE TestTable SET Value = 600 WHERE ID = 2'-Confirm:$false-ErrorAction 'Stop'
Context 'When executing a query using ByServerName parameter set' {
139
131
Context 'When executing a query without returning results' {
140
132
It 'Should execute the query without throwing' {
141
-
{
142
-
Invoke-SqlDscQuery-ServerName $script:mockComputerName-InstanceName $script:mockInstanceName-Credential $script:mockSqlAdminCredential-DatabaseName $script:testDatabaseName-Query 'UPDATE TestTable SET Value = 700 WHERE ID = 3'-Force -ErrorAction 'Stop'
143
-
} | Should -Not-Throw
133
+
$null=Invoke-SqlDscQuery-ServerName $script:mockComputerName-InstanceName $script:mockInstanceName-Credential $script:mockSqlAdminCredential-DatabaseName $script:testDatabaseName-Query 'UPDATE TestTable SET Value = 700 WHERE ID = 3'-Force -ErrorAction 'Stop'
0 commit comments