-
Notifications
You must be signed in to change notification settings - Fork 227
Remove Should -Not -Throw
#2302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ults to $null
- Updated multiple test files to replace the pattern of using `{ command } | Should -Not -Throw` with `$null = command` for better readability and to suppress unnecessary error output.
- This change was applied across various test files including DSC_SqlRS.Tests.ps1, DSC_SqlScript.Tests.ps1, DSC_SqlSecureConnection.Tests.ps1, and others.
- 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`.
- Simplified the structure of the integration tests by removing redundant script blocks that encapsulated the configuration parameters and DSC configuration calls. - Ensured that the tests still compile and apply the MOF without throwing exceptions. - Updated the tests across multiple files: DSC_SqlRS_Default, DSC_SqlServiceAccount, DSC_SqlSetup, DSC_SqlWindowsFirewall to maintain consistency and improve readability.
WalkthroughReplaces many test occurrences of Pester’s Changes
Sequence Diagram(s)(No sequence diagram provided — changes are test-style refactors without new runtime control flow to diagram.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 14
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
tests/Unit/DSC_SqlScript.Tests.ps1 (2)
194-200: LGTM! Direct invocation pattern correctly applied.The change from
Should -Not -Throwto direct invocation with$nullassignment aligns with the project test guidelines. However, the test description "Should return the expected results" is misleading sinceSet-TargetResourceis void and returns nothing.Consider revising the test description to accurately reflect the test's purpose:
- It 'Should return the expected results' { + It 'Should complete without error' {Based on learnings
210-219: LGTM! Direct invocation pattern correctly applied.The change from
Should -Not -Throwto direct invocation with$nullassignment aligns with the project test guidelines. However, the test description "Should return the expected results" is misleading sinceSet-TargetResourceis void and returns nothing.Consider revising the test description to accurately reflect the test's purpose:
- It 'Should return the expected results' { + It 'Should complete without error with query timeout' {Based on learnings
tests/Unit/DSC_SqlAgentOperator.Tests.ps1 (1)
538-549: Correct the It block description.The description "Should return the state as true" is incorrect. Based on learnings,
Set-TargetResourcemust not return anything (void). Consider updating the description to reflect what the test actually verifies, such as "Should create the sql agent operator with email address".Apply this diff:
- It 'Should return the state as true' { + It 'Should create the sql agent operator with email address' {tests/Unit/SqlServerDsc.Common.Tests.ps1 (1)
507-514: Remove leftover braces from the refactored test.The inner braces on lines 507 and 514 are artifacts from the original
Should -Not -Throwpattern and should be removed. This test block should match the pattern used in similar tests at lines 433-438 and 470-475.Apply this diff to remove the unnecessary braces:
It 'Should call the correct mocks' { - { - $invokeInstallationMediaCopyParameters = @{ - SourcePath = $mockSourcePathUNC - SourceCredential = $mockShareCredential - } - - $null = Invoke-InstallationMediaCopy @invokeInstallationMediaCopyParameters -ErrorAction 'Stop' - } + $invokeInstallationMediaCopyParameters = @{ + SourcePath = $mockSourcePathUNC + SourceCredential = $mockShareCredential + } + + $null = Invoke-InstallationMediaCopy @invokeInstallationMediaCopyParameters -ErrorAction 'Stop'
🧹 Nitpick comments (3)
tests/Unit/DSC_SqlAgentOperator.Tests.ps1 (3)
505-515: Update the It block description.The description "Should not throw" is now misleading since the
Should -Not -Throwassertion was removed. Consider updating it to describe what the test actually verifies, such as "Should create the sql agent operator" or "Should call Set-TargetResource successfully".Apply this diff:
- It 'Should not throw' { + It 'Should create the sql agent operator' {
555-566: Update the It block description.The description "Should not throw" is now misleading since the
Should -Not -Throwassertion was removed. Consider updating it to describe what the test actually verifies, such as "Should update the email address".Apply this diff:
- It 'Should not throw' { + It 'Should update the email address' {
578-588: Update the It block description.The description "Should not throw" is now misleading since the
Should -Not -Throwassertion was removed. Consider updating it to describe what the test actually verifies, such as "Should drop the sql agent operator".Apply this diff:
- It 'Should not throw' { + It 'Should drop the sql agent operator' {
tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2302 +/- ##
====================================
Coverage 94% 94%
====================================
Files 150 150
Lines 9239 9239
====================================
Hits 8751 8751
Misses 488 488
🚀 New features to boost your workflow:
|
…handling consistency
…er 6 syntax for error handling
…operator creation, email update, and deletion scenarios
…to $null in Modify() context
…oved error handling
… results to $null
…iterals for ErrorAction parameter - Updated multiple test files to replace `-ErrorAction Stop` with `-ErrorAction 'Stop'` for consistency. - Ensured that all instances of the ErrorAction parameter across various test scripts are uniformly formatted. - This change enhances readability and maintains a consistent coding style throughout the test suite.
… for command results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1 (1)
38-38: Update cleanup commands per PR objectives.Lines 38 and 59 still use
-ErrorAction 'SilentlyContinue'for cleanup operations. According to Issue #2276 objectives, cleanup commands should be changed to use-ErrorAction 'Stop'with$null =assignment instead.Apply these changes:
- Remove-Item -Path 'Env:\SqlServerDscCI' -ErrorAction 'SilentlyContinue' + $null = Remove-Item -Path 'Env:\SqlServerDscCI' -ErrorAction 'Stop'- $script:sqlServerObject | Remove-SqlDscAgentOperator -Name 'IntegrationTest_AssertOperator' -Force -ErrorAction 'SilentlyContinue' + $null = $script:sqlServerObject | Remove-SqlDscAgentOperator -Name 'IntegrationTest_AssertOperator' -Force -ErrorAction 'Stop'Also applies to: 59-59
tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1 (1)
110-110: Add missing-ErrorAction 'Stop'for consistency.The cleanup at line 59 uses
-ErrorAction 'Stop'onRemove-SqlDscDatabase, but line 110 omits this parameter. For consistent error handling and to ensure cleanup failures surface immediately, add-ErrorAction 'Stop'here as well.Apply this diff to add the missing parameter:
- $null = Remove-SqlDscDatabase -DatabaseObject $dbToRemove -Force + $null = Remove-SqlDscDatabase -DatabaseObject $dbToRemove -Force -ErrorAction 'Stop'Based on learnings.
♻️ Duplicate comments (6)
tests/Unit/Classes/SqlDatabasePermission.Tests.ps1 (4)
1181-1196: Past review comment addressed.The
Modify()call now correctly assigns the result to$null, addressing the previous review feedback and following the PR objective to replaceShould -Not -Throwpatterns with direct invocation.Based on learnings.
1269-1284: Past review comment addressed.The
Modify()call now correctly assigns the result to$null, addressing the previous review feedback and maintaining consistency with the pattern established throughout the file.Based on learnings.
1369-1384: Past review comment addressed.The
Modify()call now correctly assigns the result to$null, addressing the previous review feedback for PermissionToInclude scenario and aligning with the PR objectives.Based on learnings.
1459-1474: Past review comment addressed.The
Modify()call now correctly assigns the result to$null, addressing the previous review feedback for PermissionToExclude scenario and completing the pattern across all permission property variations.Based on learnings.
tests/Integration/Commands/Install-SqlDscServer.Integration.Tests.ps1 (2)
74-148: Remove commented-out code.This large commented-out block violates the coding guideline "No commented-out code." The historical implementation attempt and error messages should be removed to improve maintainability.
Based on coding guidelines.
214-290: Remove commented-out code.This large commented-out block violates the coding guideline "No commented-out code." The historical implementation attempt should be removed to improve maintainability.
Based on coding guidelines.
🧹 Nitpick comments (6)
tests/Unit/DSC_SqlAGListener.Tests.ps1 (1)
157-157: Consider adding-ErrorAction 'Stop'for consistency.While the direct invocation correctly follows the guideline to remove
Should -Not -Throw, consider adding-ErrorAction 'Stop'to theseGet-TargetResourcecalls for consistency with theSet-TargetResourceinvocations throughout this file (lines 747, 794, 871, etc.). This ensures failures surface immediately and error handling is uniform across all test commands.Based on learnings
Apply this pattern:
-$null = Get-TargetResource @mockGetTargetResourceParameters +$null = Get-TargetResource @mockGetTargetResourceParameters -ErrorAction 'Stop'Also applies to: 244-244, 318-318, 392-392
tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1 (1)
59-67: Simplify redundant error handling.The
try-catchblock wrappingRemove-SqlDscAuditwith-ErrorAction 'SilentlyContinue'is redundant. SinceSilentlyContinuealready suppresses errors, thetry-catchserves no purpose.Apply this diff to simplify:
- foreach ($audit in $testAudits) - { - try - { - Remove-SqlDscAudit -AuditObject $audit -Force -ErrorAction 'SilentlyContinue' - } - catch - { - # Ignore cleanup errors - } - } + foreach ($audit in $testAudits) + { + Remove-SqlDscAudit -AuditObject $audit -Force -ErrorAction 'SilentlyContinue' + }tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1 (4)
46-46: Approve style consistency change; consider assigning output to$null.The change from unquoted
Stopto quoted'Stop'aligns with the consistent error handling pattern across integration tests.Additionally,
New-SqlDscAgentAlertlikely returns the created alert object. Since the return value is unused, assign it to$nullto follow best practices.Apply this diff:
- $script:sqlServerObject | New-SqlDscAgentAlert -Name 'IntegrationTest_UpdateAlert' -Severity 14 -ErrorAction 'Stop' + $null = $script:sqlServerObject | New-SqlDscAgentAlert -Name 'IntegrationTest_UpdateAlert' -Severity 14 -ErrorAction 'Stop'
50-50: Consider using-ErrorAction 'Stop'in cleanup per PR objectives.Issue #2276 recommends changing cleanup commands to use
-ErrorAction 'Stop'instead of'SilentlyContinue'to ensure failures surface immediately. This helps catch unexpected cleanup failures.If the alert might not exist (e.g., if BeforeAll fails), consider using a conditional check or accepting that the cleanup will throw an error in that scenario.
Based on PR objectives.
Apply this diff if the alert is expected to exist:
- $null = $script:sqlServerObject | Remove-SqlDscAgentAlert -Name 'IntegrationTest_UpdateAlert' -Force -ErrorAction 'SilentlyContinue' + $null = $script:sqlServerObject | Remove-SqlDscAgentAlert -Name 'IntegrationTest_UpdateAlert' -Force -ErrorAction 'Stop'
75-75: Assign unused query output to$null.Inside It blocks, assign unused return objects to
$nullunless they're part of a pipeline.Invoke-SqlDscQuerylikely returns query results that are not used here.As per coding guidelines.
Apply this diff:
- $script:sqlServerObject | Invoke-SqlDscQuery -DatabaseName 'master' -Query $addMessageQuery -Verbose -Force -ErrorAction 'Stop' + $null = $script:sqlServerObject | Invoke-SqlDscQuery -DatabaseName 'master' -Query $addMessageQuery -Verbose -Force -ErrorAction 'Stop'
87-87: Assign unused command output to$null.Inside It blocks, assign unused return objects to
$nullunless they're part of a pipeline.Set-SqlDscAgentAlertmay return an object that is not used here.As per coding guidelines.
Apply this diff:
- $script:sqlServerObject | Set-SqlDscAgentAlert -Name 'IntegrationTest_UpdateAlert' -Severity 14 -ErrorAction 'Stop' -Force + $null = $script:sqlServerObject | Set-SqlDscAgentAlert -Name 'IntegrationTest_UpdateAlert' -Severity 14 -ErrorAction 'Stop' -Force
…calls by assigning command results to $null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1 (1)
55-55: Consider suppressing output for consistency.While not strictly required by the PR objectives (which focus on test assertions and cleanup), assigning the result to
$nullwould maintain consistency with the cleanup patterns being applied throughout this PR and prevent unwanted output.Apply this diff if you'd like to maintain consistency:
- $script:sqlServerObject | New-SqlDscAgentOperator -Name 'IntegrationTest_AssertOperator' -EmailAddress '[email protected]' -ErrorAction 'Stop' + $null = $script:sqlServerObject | New-SqlDscAgentOperator -Name 'IntegrationTest_AssertOperator' -EmailAddress '[email protected]' -ErrorAction 'Stop'
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1(2 hunks)tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1(9 hunks)tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1(3 hunks)tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1(3 hunks)tests/Unit/DSC_SqlAGListener.Tests.ps1(14 hunks)tests/Unit/DSC_SqlEndpointPermission.Tests.ps1(4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/Unit/DSC_SqlAGListener.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (10)
**/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)
**/*.[Tt]ests.ps1: All public commands, private functions, and classes must have unit tests
All public commands and class-based resources must have integration tests
Use Pester v5 syntax only
Test code only inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages, or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of a pipeline)
Call the tested entity from within the It blocks
Keep results and assertions in the same It block
Avoid try/catch/finally for cleanup; use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should' and must not contain 'when'
Mock variables must be prefixed with 'mock'
Public commands: never use InModuleScope (except for retrieving localized strings)
Private functions and class resources: always use InModuleScope
Each class method gets a separate Context block
Each scenario gets a separate Context block
Use nested Context blocks for complex scenarios
Perform mocking in BeforeAll (use BeforeEach only when required)
Place setup/teardown (BeforeAll/BeforeEach/AfterAll/AfterEach) close to usage
Use PascalCase for Pester keywords: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse; never use -Be $true/-Be $false
Never use Assert-MockCalled; use Should -Invoke instead
Do not use Should -Not -Throw; invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, and InModuleScope:ModuleName
Omit the -ModuleName parameter on Pester commands
Never use Mock inside an InModuleScope block
Define variables for -ForEach in a separate BeforeDiscovery near usage
Use -ForEach only on Context and It blocks
Keep variable scope close to the usage c...
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Unit/DSC_SqlEndpointPermission.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
⚙️ CodeRabbit configuration file
**/*.[Tt]ests.ps1: # Tests GuidelinesCore Requirements
- All public commands, private functions and classes must have unit tests
- All public commands and class-based resources must have integration tests
- Use Pester v5 syntax only
- Test code only inside
Describeblocks- Assertions only in
Itblocks- Never test verbose messages, debug messages or parameter binding behavior
- Pass all mandatory parameters to avoid prompts
Requirements
- Inside
Itblocks, assign unused return objects to$null(unless part of pipeline)- Tested entity must be called from within the
Itblocks- Keep results and assertions in same
Itblock- Avoid try-catch-finally for cleanup, use
AfterAllorAfterEach- Avoid unnecessary remove/recreate cycles
Naming
- One
Describeblock per file matching the tested entity nameContextdescriptions start with 'When'Itdescriptions start with 'Should', must not contain 'when'- Mock variables prefix: 'mock'
Structure & Scope
- Public commands: Never use
InModuleScope(unless retrieving localized strings)- Private functions/class resources: Always use
InModuleScope- Each class method = separate
Contextblock- Each scenario = separate
Contextblock- Use nested
Contextblocks for complex scenarios- Mocking in
BeforeAll(BeforeEachonly when required)- Setup/teardown in
BeforeAll,BeforeEach/AfterAll,AfterEachclose to usageSyntax Rules
- PascalCase:
Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach- Use
-BeTrue/-BeFalsenever-Be $true/-Be $false- Never use
Assert-MockCalled, useShould -Invokeinstead- No
Should -Not -Throw- invoke commands directly- Never add an empty
-MockWithblock- Omit
-MockWithwhen returning$null- Set
$PSDefaultParameterValuesforMock:ModuleName,Should:ModuleName,InModuleScope:ModuleName- Omit
-ModuleNameparameter on Pester commands- Never use
Mockinside `InModuleSc...
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Unit/DSC_SqlEndpointPermission.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
tests/[iI]ntegration/Commands/*.[iI]ntegration.[tT]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)
Place command integration tests at tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1: Do not use mocking in integration tests; run against a real environment
In CI, use Get-ComputerName for computer names
Avoid using ExpectedMessage with Should -Throw assertions
When invoking commands in integration tests, pass -Force where applicable to avoid prompts
Use -ErrorAction Stop on commands so failures surface immediately
At the top of each integration test file, include SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments') with an empty justification parameter and param ()
In BeforeDiscovery, ensure DscResource.Test is available; if not loaded or not available, run build.ps1 -Tasks 'noop' (suppressing non-error streams) and Import-Module 'DscResource.Test' -Force -ErrorAction Stop
Catch [System.IO.FileNotFoundException] during setup and throw: "DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first."
In BeforeAll, set $script:moduleName and Import-Module -Name $script:moduleName -Force -ErrorAction Stop
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
⚙️ CodeRabbit configuration file
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1: # Integration Tests GuidelinesRequirements
- Location Commands:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1- Location Resources:
tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1- No mocking - real environment only
- Cover all scenarios and code paths
- Use
Get-ComputerNamefor computer names in CI- Avoid
ExpectedMessageforShould -Throwassertions- Only run integration tests in CI unless explicitly instructed.
- Call commands with
-Forceparameter where applicable (avoids prompting).- Use
-ErrorAction 'Stop'on commands so failures surface immediatelyRequired Setup Block
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { try { if (-not (Get-Module -Name 'DscResource.Test')) { # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } catch [System.IO.FileNotFoundException] { throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.' } } BeforeAll { $script:moduleName = '{MyModuleName}' Import-Module -Name $script:moduleName -Force -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
**/*.{ps1,psm1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1}: Use descriptive names (3+ characters, no abbreviations)
Function names use PascalCase Verb-Noun with approved verbs
Parameter names use PascalCase
Variable names use camelCase
Keywords are lower-case
Class names use PascalCase
Include scope prefixes for script/global/environment variables: $script:, $global:, $env:
Use one space around operators (e.g., $a = 1 + 2)
Use one space between type and variable (e.g., [String] $name)
Use one space between keyword and parenthesis (e.g., if ($condition))
Place newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed
Arrays on one line use @('one','two'); multi-line arrays have one element per line with proper indentation
Do not use unary comma in return statements to force an array
Single-line comments: '# Comment' capitalized on its own line
Multi-line comments use <# #> with brackets on their own lines and indented text
No commented-out code
Add comment-based help to all functions and scripts
Comment-based help must include SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords at 4 spaces, text at 8 spaces
Include examples for all parameter sets and combinations
INPUTS: list each pipeline-accepted type with one-line description; repeat .INPUTS per type
OUTPUTS: list each return type with one-line description; repeat .OUTPUTS per type; must match [OutputType()] and actual returns
.NOTES only if critical (constraints, side effects, security, version compatibility, breaking behavior), ≤2 short sentences
Avoid aliases; use full command names
Avoid Write-Host; prefer Write-Verbose/Write-Information/etc.
Avoid Write-Output; use return instead
Do not use ConvertTo-SecureString -AsPlainText in production code
Do not redefine reserved parameters (Verbose, Debug, etc.)
In...
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Unit/DSC_SqlEndpointPermission.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Indent with 4 spaces; do not use tabs
No spaces on empty lines
Try to limit lines to 120 characters
Empty hashtable is @{}
Hashtable: each property on its own line with proper indentation
Hashtable property names use PascalCase
End files with exactly one blank line
Use line endings as defined by .gitattributes policy
Allow at most two consecutive newlines
No trailing whitespace on any line
Use UTF-8 encoding without BOM for all files
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Unit/DSC_SqlEndpointPermission.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
tests/Integration/Commands/*.Integration.Tests.ps1: Place integration tests for public commands in tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Add integration tests for all public commands (and resources)
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Follow PowerShell style and test guideline instructions strictly
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Unit/DSC_SqlEndpointPermission.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
**
⚙️ CodeRabbit configuration file
**: # DSC Community GuidelinesTerminology
- Command: Public command
- Function: Private function
- Resource: DSC class-based resource
Build & Test Workflow Requirements
- Run PowerShell script files from repository root
- Setup build and test environment (once per
pwshsession):./build.ps1 -Tasks noop- Build project before running tests:
./build.ps1 -Tasks build- Always run tests in new
pwshsession:Invoke-Pester -Path @({test paths}) -Output DetailedFile Organization
- Public commands:
source/Public/{CommandName}.ps1- Private functions:
source/Private/{FunctionName}.ps1- Unit tests:
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1- Integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Requirements
- Follow instructions over existing code patterns
- Follow PowerShell style and test guideline instructions strictly
- Always update CHANGELOG.md Unreleased section
- Localize all strings using string keys; remove any orphaned string keys
- Check DscResource.Common before creating private functions
- Separate reusable logic into private functions
- DSC resources should always be created as class-based resources
- Add unit tests for all commands/functions/resources
- Add integration tests for all public commands and resources
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Unit/DSC_SqlEndpointPermission.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
{**/*.ps1,**/*.psm1,**/*.psd1}
⚙️ CodeRabbit configuration file
{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell GuidelinesNaming
- Use descriptive names (3+ characters, no abbreviations)
- Functions: PascalCase with Verb-Noun format using approved verbs
- Parameters: PascalCase
- Variables: camelCase
- Keywords: lower-case
- Classes: PascalCase
- Include scope for script/global/environment variables:
$script:,$global:,$env:File naming
- Class files:
###.ClassName.ps1format (e.g.001.SqlReason.ps1,004.StartupParameters.ps1)Formatting
Indentation & Spacing
- Use 4 spaces (no tabs)
- One space around operators:
$a = 1 + 2- One space between type and variable:
[String] $name- One space between keyword and parenthesis:
if ($condition)- No spaces on empty lines
- Try to limit lines to 120 characters
Braces
- Newline before opening brace (except variable assignments)
- One newline after opening brace
- Two newlines after closing brace (one if followed by another brace or continuation)
Quotes
- Use single quotes unless variable expansion is needed:
'text'vs"text $variable"Arrays
- Single line:
@('one', 'two', 'three')- Multi-line: each element on separate line with proper indentation
- Do not use the unary comma operator (
,) in return statements to force
an arrayHashtables
- Empty:
@{}- Each property on separate line with proper indentation
- Properties: Use PascalCase
Comments
- Single line:
# Comment(capitalized, on own line)- Multi-line:
<# Comment #>format (opening and closing brackets on own line), and indent text- No commented-out code
Comment-based help
- Always add comment-based help to all functions and scripts
- Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
- Comment-based help indentation: keywords 4 spaces, text 8 spaces
- Include examples for all parameter sets and combinations
- INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description...
Files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Unit/DSC_SqlEndpointPermission.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
tests/[Uu]nit/**/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md)
tests/[Uu]nit/**/*.[Tt]ests.ps1: In unit tests, access localized strings using InModuleScope -ScriptBlock { $script:localizedData.Key }
When mocking files in tests, use the $TestDrive variable for file system operations
All public commands must include parameter set validation tests
Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module
Use the provided Parameter Set Validation test template to assert command ParameterSetName and full parameter list string; for multiple parameter sets, supply multiple hashtables via -ForEach
Use the Parameter Properties template to assert a parameter is mandatory via $parameterInfo = (Get-Command -Name 'CommandName').Parameters['ParameterName']; $parameterInfo.Attributes.Mandatory | Should -BeTrue
Files:
tests/Unit/DSC_SqlEndpointPermission.Tests.ps1
⚙️ CodeRabbit configuration file
tests/[Uu]nit/**/*.[Tt]ests.ps1: # Unit Tests Guidelines
- Test with localized strings: Use
InModuleScope -ScriptBlock { $script:localizedData.Key }- Mock files: Use
$TestDrivevariable (path to the test drive)- All public commands require parameter set validation tests
- After modifying classes, always run tests in new session (for changes to take effect)
Test Setup Requirements
Use this exact setup block before
Describe:[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { try { if (-not (Get-Module -Name 'DscResource.Test')) { # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } catch [System.IO.FileNotFoundException] { throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.' } } BeforeAll { $script:moduleName = '{MyModuleName}' Import-Module -Name $script:moduleName -Force -ErrorAction 'Stop' $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:moduleName $PSDefaultParameterValues['Mock:ModuleName'] = $script:moduleName $PSDefaultParameterValues['Should:ModuleName'] = $script:moduleName } AfterAll { $PSDefaultParameterValues.Remove('InModuleScope:ModuleName') $PSDefaultParameterValues.Remove('Mock:ModuleNam...
Files:
tests/Unit/DSC_SqlEndpointPermission.Tests.ps1
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Do not use Should -Not -Throw; invoke commands directly
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use -ErrorAction Stop on commands so failures surface immediately
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using ExpectedMessage with Should -Throw assertions
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1} : Set $ErrorActionPreference='Stop' immediately before commands using -ErrorAction 'Stop' and restore after; do not use try-catch-finally for this
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1} : Avoid empty catch blocks; prefer -ErrorAction SilentlyContinue
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Inside It blocks, assign unused return objects to $null (unless part of a pipeline)
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid try/catch/finally for cleanup; use AfterAll or AfterEach
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use Assert-MockCalled; use Should -Invoke instead
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit -MockWith when returning $null
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use -ErrorAction Stop on commands so failures surface immediately
Applied to files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Unit/DSC_SqlEndpointPermission.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
📚 Learning: 2025-09-23T10:20:59.832Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-23T10:20:59.832Z
Learning: In unit tests, add $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll
Applied to files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : In BeforeAll, set $script:moduleName and Import-Module -Name $script:moduleName -Force -ErrorAction Stop
Applied to files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles
Applied to files:
tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1
📚 Learning: 2025-09-23T10:20:59.832Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-23T10:20:59.832Z
Learning: Integration tests must use Connect-SqlDscDatabaseEngine with correct CI credentials and call Disconnect-SqlDscDatabaseEngine after
Applied to files:
tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource must not return anything (void)
Applied to files:
tests/Unit/DSC_SqlEndpointPermission.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource and Test-TargetResource must have identical parameters
Applied to files:
tests/Unit/DSC_SqlEndpointPermission.Tests.ps1
📚 Learning: 2025-08-18T13:50:53.789Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.
Applied to files:
tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
- GitHub Check: Setup PowerShell Development Environment
🔇 Additional comments (17)
tests/Unit/DSC_SqlEndpointPermission.Tests.ps1 (4)
332-332: LGTM!The change correctly replaces the Should -Not -Throw pattern with direct invocation. The
-ErrorAction 'Stop'ensures failures surface as exceptions, and the$nullassignment properly captures unused output.Based on learnings
355-355: LGTM!The change correctly implements the test pattern update. Direct invocation with
-ErrorAction 'Stop'and$nullassignment aligns with the PR objectives and DSC Community test guidelines.Based on learnings
433-433: LGTM!The change correctly removes the Should -Not -Throw wrapper and implements direct invocation. The
-ErrorAction 'Stop'ensures exceptions are raised for failures.Based on learnings
460-460: LGTM!The change correctly implements the direct invocation pattern with
-ErrorAction 'Stop'and$nullassignment, consistent with the other changes in this file and the PR objectives.Based on learnings
tests/Integration/Commands/Set-SqlDscAgentAlert.Integration.Tests.ps1 (1)
46-115: LGTM! Changes correctly implement the PR objectives.All modifications properly replace
Should -Not -Throwpatterns with direct command invocations using$null = Command -ErrorAction 'Stop', which aligns with the project's test guidelines. The cleanup operations now use-ErrorAction 'Stop'instead of-ErrorAction 'SilentlyContinue', ensuring failures surface immediately.The error test cases at lines 108-109 and 113-114 correctly retain
Should -Throwfor testing expected failure scenarios, which is the appropriate pattern per Pester best practices.Based on learnings.
tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1 (6)
42-42: LGTM!The connection setup correctly uses
-ErrorAction 'Stop'to ensure failures surface immediately during integration tests. Based on learnings.
49-64: LGTM!The cleanup pattern correctly uses
-ErrorAction 'SilentlyContinue'for the Get operation (to check existence without errors) and-ErrorAction 'Stop'for the Remove operation (to surface failures immediately). This aligns with the PR objectives which focus on Remove operations using 'Stop'.
67-77: LGTM!The test correctly uses direct invocation with
-ErrorAction 'Stop'on both New-SqlDscDatabase and Get-SqlDscDatabase commands, ensuring failures surface immediately in integration tests. Based on learnings.
79-90: LGTM!The test correctly uses direct invocation with
-ErrorAction 'Stop', consistent with integration test guidelines.
92-95: LGTM!The script block with
Should -Throwis the correct pattern for testing that an operation should fail (duplicate database creation). This is different from the anti-patternShould -Not -Throwthat the PR aims to remove. The script block is necessary here to capture the expected error.
98-123: LGTM!The test correctly uses direct invocation with
-ErrorAction 'Stop'for the New-SqlDscDatabase command. The AfterEach cleanup follows the same safe pattern as AfterAll, using 'SilentlyContinue' for checking existence and 'Stop' for the actual removal.tests/Integration/Commands/Assert-SqlDscAgentOperator.Integration.Tests.ps1 (3)
38-38: LGTM! Cleanup now uses direct invocation with explicit error handling.The environment variable cleanup correctly assigns output to
$nulland uses-ErrorAction 'Stop'to ensure failures surface immediately, aligning with the PR objectives and integration test guidelines.
59-77: LGTM! Test patterns correctly refactored.The changes successfully replace
Should -Not -Throwpatterns with direct command invocation:
- Line 59: Cleanup operation properly assigns to
$nullwith-ErrorAction 'Stop'- Lines 67, 71: Tests now invoke commands directly with
$nullassignment instead of wrapping in script blocks- Line 75: Appropriately assigns to
$resultvariable for value assertionAll changes align with the PR objectives and follow the DSC Community test guidelines.
Based on learnings
82-82: LGTM! Negative test correctly usesShould -Throw.The script block wrapper and
Should -Throwassertion are appropriate here since the test verifies that a terminating error is thrown for a non-existent operator. This differs from theShould -Not -Throwpatterns being removed elsewhere in the PR.tests/Integration/Commands/New-SqlDscAudit.Integration.Tests.ps1 (3)
42-42: LGTM: Standardized ErrorAction syntax.The change from
-ErrorAction Stopto-ErrorAction 'Stop'follows PowerShell best practices by using quoted strings for parameter values.
86-289: LGTM: ErrorAction syntax standardized across all test cases.All test execution commands have been correctly updated to use
-ErrorAction 'Stop'with quoted strings, ensuring failures surface immediately as required by the integration test guidelines.
308-322: LGTM: Should -Not -Throw pattern correctly removed.Line 310 correctly replaces the Should -Not -Throw pattern with direct invocation using
$null =assignment. Lines 313-314 and 320-321 appropriately retainShould -Throwfor negative test cases to verify that errors are thrown in error conditions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1 (2)
109-117: Consider removing unnecessary-PassThruparameters.Lines 111 and 115 use
-PassThrubut discard the output by assigning to$null. Since these tests verifyStatementTimeoutandRedactTextparameters (notPassThrufunctionality), the-PassThruparameter appears unnecessary.Apply this diff to remove the unnecessary parameter:
- $null = Invoke-SqlDscQuery -ServerObject $script:serverObject -DatabaseName $script:testDatabaseName -Query 'SELECT COUNT(*) FROM TestTable' -StatementTimeout 30 -PassThru -Force -ErrorAction 'Stop' + $null = Invoke-SqlDscQuery -ServerObject $script:serverObject -DatabaseName $script:testDatabaseName -Query 'SELECT COUNT(*) FROM TestTable' -StatementTimeout 30 -Force -ErrorAction 'Stop'- $null = Invoke-SqlDscQuery -ServerObject $script:serverObject -DatabaseName $script:testDatabaseName -Query "SELECT * FROM TestTable WHERE Name = 'SensitiveData'" -RedactText @('SensitiveData') -PassThru -Force -ErrorAction 'Stop' + $null = Invoke-SqlDscQuery -ServerObject $script:serverObject -DatabaseName $script:testDatabaseName -Query "SELECT * FROM TestTable WHERE Name = 'SensitiveData'" -RedactText @('SensitiveData') -Force -ErrorAction 'Stop'
147-164: Consider removing unnecessary-PassThruparameters.Lines 150, 158, and 162 use
-PassThrubut discard the output by assigning to$null. Since these tests verifyEncrypt,LoginType, andStatementTimeoutparameters respectively (notPassThrufunctionality), the-PassThruparameter appears unnecessary.Apply this diff to remove the unnecessary parameters:
- $null = Invoke-SqlDscQuery -ServerName $script:mockComputerName -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential -DatabaseName $script:testDatabaseName -Query 'SELECT 1 as TestValue' -Encrypt -PassThru -Force -ErrorAction 'Stop' + $null = Invoke-SqlDscQuery -ServerName $script:mockComputerName -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential -DatabaseName $script:testDatabaseName -Query 'SELECT 1 as TestValue' -Encrypt -Force -ErrorAction 'Stop'- $null = Invoke-SqlDscQuery -ServerName $script:mockComputerName -InstanceName $script:mockInstanceName -Credential $sqlLoginCredential -LoginType 'SqlLogin' -DatabaseName $script:testDatabaseName -Query 'SELECT 1 as TestValue' -PassThru -Force -ErrorAction 'Stop' + $null = Invoke-SqlDscQuery -ServerName $script:mockComputerName -InstanceName $script:mockInstanceName -Credential $sqlLoginCredential -LoginType 'SqlLogin' -DatabaseName $script:testDatabaseName -Query 'SELECT 1 as TestValue' -Force -ErrorAction 'Stop'- $null = Invoke-SqlDscQuery -ServerName $script:mockComputerName -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential -DatabaseName $script:testDatabaseName -Query 'SELECT 1 as TestValue' -StatementTimeout 60 -PassThru -Force -ErrorAction 'Stop' + $null = Invoke-SqlDscQuery -ServerName $script:mockComputerName -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential -DatabaseName $script:testDatabaseName -Query 'SELECT 1 as TestValue' -StatementTimeout 60 -Force -ErrorAction 'Stop'
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1(4 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)
**/*.[Tt]ests.ps1: All public commands, private functions, and classes must have unit tests
All public commands and class-based resources must have integration tests
Use Pester v5 syntax only
Test code only inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages, or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of a pipeline)
Call the tested entity from within the It blocks
Keep results and assertions in the same It block
Avoid try/catch/finally for cleanup; use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should' and must not contain 'when'
Mock variables must be prefixed with 'mock'
Public commands: never use InModuleScope (except for retrieving localized strings)
Private functions and class resources: always use InModuleScope
Each class method gets a separate Context block
Each scenario gets a separate Context block
Use nested Context blocks for complex scenarios
Perform mocking in BeforeAll (use BeforeEach only when required)
Place setup/teardown (BeforeAll/BeforeEach/AfterAll/AfterEach) close to usage
Use PascalCase for Pester keywords: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse; never use -Be $true/-Be $false
Never use Assert-MockCalled; use Should -Invoke instead
Do not use Should -Not -Throw; invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, and InModuleScope:ModuleName
Omit the -ModuleName parameter on Pester commands
Never use Mock inside an InModuleScope block
Define variables for -ForEach in a separate BeforeDiscovery near usage
Use -ForEach only on Context and It blocks
Keep variable scope close to the usage c...
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
⚙️ CodeRabbit configuration file
**/*.[Tt]ests.ps1: # Tests GuidelinesCore Requirements
- All public commands, private functions and classes must have unit tests
- All public commands and class-based resources must have integration tests
- Use Pester v5 syntax only
- Test code only inside
Describeblocks- Assertions only in
Itblocks- Never test verbose messages, debug messages or parameter binding behavior
- Pass all mandatory parameters to avoid prompts
Requirements
- Inside
Itblocks, assign unused return objects to$null(unless part of pipeline)- Tested entity must be called from within the
Itblocks- Keep results and assertions in same
Itblock- Avoid try-catch-finally for cleanup, use
AfterAllorAfterEach- Avoid unnecessary remove/recreate cycles
Naming
- One
Describeblock per file matching the tested entity nameContextdescriptions start with 'When'Itdescriptions start with 'Should', must not contain 'when'- Mock variables prefix: 'mock'
Structure & Scope
- Public commands: Never use
InModuleScope(unless retrieving localized strings)- Private functions/class resources: Always use
InModuleScope- Each class method = separate
Contextblock- Each scenario = separate
Contextblock- Use nested
Contextblocks for complex scenarios- Mocking in
BeforeAll(BeforeEachonly when required)- Setup/teardown in
BeforeAll,BeforeEach/AfterAll,AfterEachclose to usageSyntax Rules
- PascalCase:
Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach- Use
-BeTrue/-BeFalsenever-Be $true/-Be $false- Never use
Assert-MockCalled, useShould -Invokeinstead- No
Should -Not -Throw- invoke commands directly- Never add an empty
-MockWithblock- Omit
-MockWithwhen returning$null- Set
$PSDefaultParameterValuesforMock:ModuleName,Should:ModuleName,InModuleScope:ModuleName- Omit
-ModuleNameparameter on Pester commands- Never use
Mockinside `InModuleSc...
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
tests/[iI]ntegration/Commands/*.[iI]ntegration.[tT]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)
Place command integration tests at tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1: Do not use mocking in integration tests; run against a real environment
In CI, use Get-ComputerName for computer names
Avoid using ExpectedMessage with Should -Throw assertions
When invoking commands in integration tests, pass -Force where applicable to avoid prompts
Use -ErrorAction Stop on commands so failures surface immediately
At the top of each integration test file, include SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments') with an empty justification parameter and param ()
In BeforeDiscovery, ensure DscResource.Test is available; if not loaded or not available, run build.ps1 -Tasks 'noop' (suppressing non-error streams) and Import-Module 'DscResource.Test' -Force -ErrorAction Stop
Catch [System.IO.FileNotFoundException] during setup and throw: "DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first."
In BeforeAll, set $script:moduleName and Import-Module -Name $script:moduleName -Force -ErrorAction Stop
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
⚙️ CodeRabbit configuration file
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1: # Integration Tests GuidelinesRequirements
- Location Commands:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1- Location Resources:
tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1- No mocking - real environment only
- Cover all scenarios and code paths
- Use
Get-ComputerNamefor computer names in CI- Avoid
ExpectedMessageforShould -Throwassertions- Only run integration tests in CI unless explicitly instructed.
- Call commands with
-Forceparameter where applicable (avoids prompting).- Use
-ErrorAction 'Stop'on commands so failures surface immediatelyRequired Setup Block
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')] param () BeforeDiscovery { try { if (-not (Get-Module -Name 'DscResource.Test')) { # Assumes dependencies have been resolved, so if this module is not available, run 'noop' task. if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable)) { # Redirect all streams to $null, except the error stream (stream 2) & "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null } # If the dependencies have not been resolved, this will throw an error. Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop' } } catch [System.IO.FileNotFoundException] { throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.' } } BeforeAll { $script:moduleName = '{MyModuleName}' Import-Module -Name $script:moduleName -Force -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
**/*.{ps1,psm1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1}: Use descriptive names (3+ characters, no abbreviations)
Function names use PascalCase Verb-Noun with approved verbs
Parameter names use PascalCase
Variable names use camelCase
Keywords are lower-case
Class names use PascalCase
Include scope prefixes for script/global/environment variables: $script:, $global:, $env:
Use one space around operators (e.g., $a = 1 + 2)
Use one space between type and variable (e.g., [String] $name)
Use one space between keyword and parenthesis (e.g., if ($condition))
Place newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed
Arrays on one line use @('one','two'); multi-line arrays have one element per line with proper indentation
Do not use unary comma in return statements to force an array
Single-line comments: '# Comment' capitalized on its own line
Multi-line comments use <# #> with brackets on their own lines and indented text
No commented-out code
Add comment-based help to all functions and scripts
Comment-based help must include SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords at 4 spaces, text at 8 spaces
Include examples for all parameter sets and combinations
INPUTS: list each pipeline-accepted type with one-line description; repeat .INPUTS per type
OUTPUTS: list each return type with one-line description; repeat .OUTPUTS per type; must match [OutputType()] and actual returns
.NOTES only if critical (constraints, side effects, security, version compatibility, breaking behavior), ≤2 short sentences
Avoid aliases; use full command names
Avoid Write-Host; prefer Write-Verbose/Write-Information/etc.
Avoid Write-Output; use return instead
Do not use ConvertTo-SecureString -AsPlainText in production code
Do not redefine reserved parameters (Verbose, Debug, etc.)
In...
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Indent with 4 spaces; do not use tabs
No spaces on empty lines
Try to limit lines to 120 characters
Empty hashtable is @{}
Hashtable: each property on its own line with proper indentation
Hashtable property names use PascalCase
End files with exactly one blank line
Use line endings as defined by .gitattributes policy
Allow at most two consecutive newlines
No trailing whitespace on any line
Use UTF-8 encoding without BOM for all files
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
tests/Integration/Commands/*.Integration.Tests.ps1: Place integration tests for public commands in tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Add integration tests for all public commands (and resources)
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Follow PowerShell style and test guideline instructions strictly
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
**
⚙️ CodeRabbit configuration file
**: # DSC Community GuidelinesTerminology
- Command: Public command
- Function: Private function
- Resource: DSC class-based resource
Build & Test Workflow Requirements
- Run PowerShell script files from repository root
- Setup build and test environment (once per
pwshsession):./build.ps1 -Tasks noop- Build project before running tests:
./build.ps1 -Tasks build- Always run tests in new
pwshsession:Invoke-Pester -Path @({test paths}) -Output DetailedFile Organization
- Public commands:
source/Public/{CommandName}.ps1- Private functions:
source/Private/{FunctionName}.ps1- Unit tests:
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1- Integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Requirements
- Follow instructions over existing code patterns
- Follow PowerShell style and test guideline instructions strictly
- Always update CHANGELOG.md Unreleased section
- Localize all strings using string keys; remove any orphaned string keys
- Check DscResource.Common before creating private functions
- Separate reusable logic into private functions
- DSC resources should always be created as class-based resources
- Add unit tests for all commands/functions/resources
- Add integration tests for all public commands and resources
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
{**/*.ps1,**/*.psm1,**/*.psd1}
⚙️ CodeRabbit configuration file
{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell GuidelinesNaming
- Use descriptive names (3+ characters, no abbreviations)
- Functions: PascalCase with Verb-Noun format using approved verbs
- Parameters: PascalCase
- Variables: camelCase
- Keywords: lower-case
- Classes: PascalCase
- Include scope for script/global/environment variables:
$script:,$global:,$env:File naming
- Class files:
###.ClassName.ps1format (e.g.001.SqlReason.ps1,004.StartupParameters.ps1)Formatting
Indentation & Spacing
- Use 4 spaces (no tabs)
- One space around operators:
$a = 1 + 2- One space between type and variable:
[String] $name- One space between keyword and parenthesis:
if ($condition)- No spaces on empty lines
- Try to limit lines to 120 characters
Braces
- Newline before opening brace (except variable assignments)
- One newline after opening brace
- Two newlines after closing brace (one if followed by another brace or continuation)
Quotes
- Use single quotes unless variable expansion is needed:
'text'vs"text $variable"Arrays
- Single line:
@('one', 'two', 'three')- Multi-line: each element on separate line with proper indentation
- Do not use the unary comma operator (
,) in return statements to force
an arrayHashtables
- Empty:
@{}- Each property on separate line with proper indentation
- Properties: Use PascalCase
Comments
- Single line:
# Comment(capitalized, on own line)- Multi-line:
<# Comment #>format (opening and closing brackets on own line), and indent text- No commented-out code
Comment-based help
- Always add comment-based help to all functions and scripts
- Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
- Comment-based help indentation: keywords 4 spaces, text 8 spaces
- Include examples for all parameter sets and combinations
- INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description...
Files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Do not use Should -Not -Throw; invoke commands directly
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using ExpectedMessage with Should -Throw assertions
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Inside It blocks, assign unused return objects to $null (unless part of a pipeline)
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1} : Avoid empty catch blocks; prefer -ErrorAction SilentlyContinue
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use -ErrorAction Stop on commands so failures surface immediately
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid try/catch/finally for cleanup; use AfterAll or AfterEach
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Do not use Should -Not -Throw; invoke commands directly
Applied to files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using ExpectedMessage with Should -Throw assertions
Applied to files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : When invoking commands in integration tests, pass -Force where applicable to avoid prompts
Applied to files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Inside It blocks, assign unused return objects to $null (unless part of a pipeline)
Applied to files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : At the top of each integration test file, include SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments') with an empty justification parameter and param ()
Applied to files:
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
- GitHub Check: PSScriptAnalyzer
- GitHub Check: PSScriptAnalyzer
- GitHub Check: Setup PowerShell Development Environment
🔇 Additional comments (3)
tests/Integration/Commands/Invoke-SqlDscQuery.Integration.Tests.ps1 (3)
81-87: Conversions correctly implement the new test pattern.The test cases now invoke commands directly with
$null =assignment instead of usingShould -Not -Throw, allowing exceptions to surface naturally. This aligns with the PR objectives and test guidelines.Based on learnings.
130-135: LGTM! Correct conversion for ByServerName parameter set.The test correctly invokes the command directly with
$null =assignment, following the new pattern.Based on learnings.
206-221: LGTM! WhatIf test correctly converted.The test now invokes the command with
-WhatIfdirectly, assigning to$null, and properly verifies that the operation was not executed by comparing record counts.Based on learnings.
Pull Request (PR) description
This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is