-
Notifications
You must be signed in to change notification settings - Fork 227
Add service account management for Reporting Services #2402
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
base: main
Are you sure you want to change the base?
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... 📒 Files selected for processing (14)
WalkthroughAdds RS/PBIRS service-account management (Get/Set), log-path retrieval, encryption-key rotate/remove, URL-reservation recreate mode, DB-rights username validation, localization strings, CI pipeline adjustments, and extensive unit/integration tests for these flows. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant SetCmd as Set-SqlDscRSServiceAccount
participant CIM as CIM (MSReportServer_ConfigurationSetting)
participant UrlTool as Set-SqlDscRSUrlReservation
participant SvcMgr as RS Service
User->>SetCmd: Invoke(Configuration/InstanceName, Credential/UseBuiltInAccount, RestartService?, SuppressUrlReservationWarning?)
SetCmd->>SetCmd: Validate inputs, ShouldProcess
SetCmd->>CIM: Invoke SetWindowsServiceIdentity(Account, Password?, UseBuiltInAccount)
CIM-->>SetCmd: Success/Error
alt Success and account changed and not Suppressed
SetCmd->>UrlTool: Call -RecreateExisting (remove then add reservations)
UrlTool-->>SetCmd: Removal/Add results
end
alt RestartService requested
SetCmd->>SvcMgr: Restart service
SvcMgr-->>SetCmd: Restart result
end
SetCmd-->>User: Return (PassThru optional) / Complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 3
🤖 Fix all issues with AI agents
In @tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1:
- Around line 46-225: Tests are missing coverage for RestartService and
SuppressUrlReservationWarning behaviors; add new Context blocks to exercise
Set-SqlDscRSServiceAccount with the -RestartService switch (mock
Restart-SqlDscRSService and assert it is invoked with ServiceName
'SQLServerReportingServices' and Force=$true) and to test URL reservation
warnings (set WindowsServiceIdentityActual to an old account, change Credential
to a new account, mock Write-Warning and assert it is invoked once when
SuppressUrlReservationWarning is absent and invoked zero times when
SuppressUrlReservationWarning is present); ensure Invoke-RsCimMethod is mocked
in those contexts and use the existing pattern of piping a PSCustomObject to
Set-SqlDscRSServiceAccount and -Confirm:$false in the assertions.
- Around line 48-63: The parameter-set assertion for Get-Command -Name
'Set-SqlDscRSServiceAccount' is missing two switch parameters; update the
ExpectedParameters string in the test block that defines
ExpectedParameterSetName = '__AllParameterSets' so it includes the
RestartService and SuppressUrlReservationWarning switches (e.g. append
'[-RestartService] [-SuppressUrlReservationWarning]' in the correct switch
syntax within ExpectedParameters) so the comparison of
$result.ParameterListAsString matches the actual parameter list.
🧹 Nitpick comments (5)
source/Public/Set-SqlDscRSServiceAccount.ps1 (3)
99-99: Refine the OutputType declarations.The OutputType should be more specific. Based on the PassThru behavior, this command either returns nothing or returns the Configuration CIM instance.
♻️ Proposed refinement
Use two OutputType declarations to accurately reflect the return behavior:
- [OutputType([System.Object])] + [OutputType([Microsoft.Management.Infrastructure.CimInstance])] + [OutputType()]Place
[OutputType()]first since that's the default behavior (no output), and[OutputType([Microsoft.Management.Infrastructure.CimInstance])]for when PassThru is specified.
155-164: Use PtrToStringUni instead of PtrToStringAuto for consistent behavior.Using
PtrToStringAutocan have platform-dependent behavior. For SecureString conversion,PtrToStringUni(UTF-16) is more explicit and consistent across platforms.♻️ Proposed fix
try { - $passwordPlainText = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($passwordBstr) + $passwordPlainText = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($passwordBstr) } finally
102-104: Consider more specific typing for the Configuration parameter.The Configuration parameter is typed as
[System.Object], which is very permissive. Consider using[Microsoft.Management.Infrastructure.CimInstance]for better type safety and clearer intent.♻️ Proposed refinement
[Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [System.Object] + [Microsoft.Management.Infrastructure.CimInstance] $Configuration,Note: If the loose typing is intentional for unit testing flexibility, this suggestion can be disregarded.
tests/Integration/Commands/Get-SqlDscRSServiceAccount.Integration.Tests.ps1 (1)
26-32: Consider adding PSDefaultParameterValues for consistency.While not strictly required for integration tests, setting
$PSDefaultParameterValuesfor Pester commands can improve consistency across the test suite. However, since integration tests typically don't use mocking and have different patterns than unit tests, this is optional.♻️ Optional addition
If you want consistency with other integration tests that do use Should assertions with custom error messages:
BeforeAll { $script:moduleName = 'SqlServerDsc' # Do not use -Force. Doing so, or unloading the module in AfterAll, causes # PowerShell class types to get new identities, breaking type comparisons. Import-Module -Name $script:moduleName -ErrorAction 'Stop' + + $PSDefaultParameterValues['Should:ModuleName'] = $script:moduleName }And add a corresponding AfterAll:
+AfterAll { + $PSDefaultParameterValues.Remove('Should:ModuleName') +}tests/Integration/Commands/Set-SqlDscRSServiceAccount.Integration.Tests.ps1 (1)
41-151: Consider using-ForEachto reduce duplication across Context blocks.The four
Contextblocks (SQL2017_RS, SQL2019_RS, SQL2022_RS, PowerBI) contain nearly identical logic with only the instance name and tag differing. Using-ForEachwith test cases would reduce duplication and improve maintainability.♻️ Optional refactor using -ForEach
BeforeDiscovery { # ... existing module import code ... $script:testCases = @( @{ Tag = 'Integration_SQL2017_RS'; InstanceName = 'SSRS'; Description = 'SQL Server Reporting Services' } @{ Tag = 'Integration_SQL2019_RS'; InstanceName = 'SSRS'; Description = 'SQL Server Reporting Services' } @{ Tag = 'Integration_SQL2022_RS'; InstanceName = 'SSRS'; Description = 'SQL Server Reporting Services' } @{ Tag = 'Integration_PowerBI'; InstanceName = 'PBIRS'; Description = 'Power BI Report Server' } ) } Describe 'Set-SqlDscRSServiceAccount' { Context 'When setting service account for <Description>' -Tag @($Tag) -ForEach $script:testCases { BeforeAll { $computerName = Get-ComputerName $script:serviceAccountName = '{0}\svc-RS' -f $computerName $script:serviceAccountPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force $script:serviceAccountCredential = [System.Management.Automation.PSCredential]::new($script:serviceAccountName, $script:serviceAccountPassword) $script:configuration = Get-SqlDscRSConfiguration -InstanceName $InstanceName -ErrorAction 'Stop' $script:originalServiceAccount = $script:configuration | Get-SqlDscRSServiceAccount -ErrorAction 'Stop' } It 'Should have the original service account set' { $script:originalServiceAccount | Should -Not -BeNullOrEmpty } It 'Should change the service account to svc-RS' { $script:configuration | Set-SqlDscRSServiceAccount -Credential $script:serviceAccountCredential -RestartService -SuppressUrlReservationWarning -Force -ErrorAction 'Stop' } It 'Should have the new service account set after the change' { $configuration = Get-SqlDscRSConfiguration -InstanceName $InstanceName -ErrorAction 'Stop' $result = $configuration | Get-SqlDscRSServiceAccount -ErrorAction 'Stop' $result | Should -BeExactly $script:serviceAccountName } } }
- Added Recreate mode to Set-SqlDscRSUrlReservation for removing and re-adding all existing URL reservations. - Updated parameter sets to include a separate Recreate set. - Enhanced documentation to clarify command behavior in both Set and Recreate modes. - Added integration tests for URL reservation recreation after service account changes. - Updated unit tests to validate new parameter sets and functionality.
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
🤖 Fix all issues with AI agents
In @tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1:
- Around line 348-415: Mocks are defined in BeforeAll so invocation counts
accumulate across the three It blocks calling Set-SqlDscRSUrlReservation,
causing the -Exactly -Times 1 assertions to fail; fix by either moving the Mock
definitions from BeforeAll into BeforeEach so each It gets fresh mocks
(resetting invocation counts for Get-SqlDscRSUrlReservation,
Remove-SqlDscRSUrlReservation, Add-SqlDscRSUrlReservation), or consolidate the
three It blocks into a single It that performs all assertions after one call to
Set-SqlDscRSUrlReservation; update the Context to use BeforeEach or merge the
Its and adjust assertions accordingly.
🧹 Nitpick comments (1)
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1 (1)
64-76: AvoidShould -Not -Throwand invoke the command directlyCurrent pattern:
- Wraps
Set-SqlDscRSUrlReservationin a scriptblock and asserts withShould -Not -Throw, which goes against the Pester/DSC guidelines for tests.- Also does not explicitly discard the (unused) return object from
Set-SqlDscRSUrlReservationinside theItblock.Refactor to call the command directly and assign the unused result to
$nullso the test naturally fails if an exception is thrown and aligns with the guidelines. As per coding guidelines, tests should not useShould -Not -Throw.♻️ Suggested refactor for this `It` block
- It 'Should recreate all URL reservations without throwing' { - { - $script:configuration | Set-SqlDscRSUrlReservation -RecreateExisting -Force -ErrorAction 'Stop' - } | Should -Not -Throw - } + It 'Should recreate all URL reservations without throwing' { + $null = $script:configuration | Set-SqlDscRSUrlReservation -RecreateExisting -Force -ErrorAction 'Stop' + }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
CHANGELOG.mdazure-pipelines.ymlsource/Public/Set-SqlDscRSUrlReservation.ps1source/en-US/SqlServerDsc.strings.psd1tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
- azure-pipelines.yml
🧰 Additional context used
📓 Path-based instructions (18)
**/*.[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 insideDescribeblocks
Assertions only inItblocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
InsideItblocks, assign unused return objects to$null(unless part of pipeline)
Tested entity must be called from within theItblocks
Keep results and assertions in sameItblock
Avoid try-catch-finally for cleanup, useAfterAllorAfterEach
Avoid unnecessary remove/recreate cycles
OneDescribeblock per file matching the tested entity name
Contextdescriptions start with 'When'
Itdescriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
Public commands: Never useInModuleScope(unless retrieving localized strings or creating an object using an internal class)
Private functions/class resources: Always useInModuleScope
Each class method = separateContextblock
Each scenario = separateContextblock
Use nestedContextblocks for complex scenarios
Mocking inBeforeAll(BeforeEachonly when required)
Setup/teardown inBeforeAll,BeforeEach/AfterAll,AfterEachclose to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase:Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach
Use-BeTrue/-BeFalsenever-Be $true/-Be $false
Never useAssert-MockCalled, useShould -Invokeinstead
NoShould -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 useMockinsideInModuleScope-block
Never useparam()inside-MockWithscriptblock...
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.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 or creating an object using an internal class)- 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 usage- Spacing between blocks, arrange, act, and assert for readability
Syntax 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, `...
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Integration tests for commands should be located in
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Location for command integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1source/Public/Set-SqlDscRSUrlReservation.ps1source/en-US/SqlServerDsc.strings.psd1tests/Unit/Public/Set-SqlDscRSUrlReservation.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: Integration tests must use real environment only - no mocking allowed
Integration tests must cover all scenarios and code paths
UseGet-ComputerNamefor computer names in CI environments within integration tests
Avoid usingExpectedMessageparameter forShould -Throwassertions in integration tests
Call commands with-Forceparameter where applicable in integration tests to avoid prompting
Use-ErrorAction 'Stop'on commands in integration tests so failures surface immediately
Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.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 -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
**/tests/Integration/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Integration/**/*.ps1: Integration tests must useConnect-SqlDscDatabaseEnginefor SQL Server DB session with correct CI credentials
Integration tests must useDisconnect-SqlDscDatabaseEngineafterConnect-SqlDscDatabaseEngine
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.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- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.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/Post.UrlReservationRecreate.RS.Integration.Tests.ps1source/Public/Set-SqlDscRSUrlReservation.ps1CHANGELOG.mdsource/en-US/SqlServerDsc.strings.psd1tests/Unit/Public/Set-SqlDscRSUrlReservation.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 as inline code with a 1‑line description...
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1source/Public/Set-SqlDscRSUrlReservation.ps1source/en-US/SqlServerDsc.strings.psd1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
source/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)
source/**/*.ps1: Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages in PowerShell scripts
Use localized string keys from $script:localizedData, not hardcoded strings, in diagnostic messages
Reference localized strings using the syntax: Write-Verbose -Message ($script:localizedData.KeyName -f $value1)Localize all strings using string keys; remove any orphaned string keys
Files:
source/Public/Set-SqlDscRSUrlReservation.ps1
⚙️ CodeRabbit configuration file
source/**/*.ps1: # Localization GuidelinesRequirements
- Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
- Use localized string keys, not hardcoded strings
- Assume
$script:localizedDatais availableString Files
- Commands/functions:
source/en-US/{MyModuleName}.strings.psd1- Class resources:
source/en-US/{ResourceClassName}.strings.psd1Key Naming Patterns
- Format:
Verb_FunctionName_Action(underscore separators), e.g.Get_Database_ConnectingToDatabaseString Format
ConvertFrom-StringData @' KeyName = Message with {0} placeholder. (PREFIX0001) '@String IDs
- Format:
(PREFIX####)- PREFIX: First letter of each word in class or function name (SqlSetup → SS, Get-SqlDscDatabase → GSDD)
- Number: Sequential from 0001
Usage
Write-Verbose -Message ($script:localizedData.KeyName -f $value1)
Files:
source/Public/Set-SqlDscRSUrlReservation.ps1
source/Public/*.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Public commands should be located in
source/Public/{CommandName}.ps1
Files:
source/Public/Set-SqlDscRSUrlReservation.ps1
**/Public/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Public commands must follow the naming format
{Verb}-SqlDsc{Noun}
Files:
source/Public/Set-SqlDscRSUrlReservation.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
CHANGELOG.md
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-changelog.instructions.md)
CHANGELOG.md: Always update the Unreleased section in CHANGELOG.md
Use Keep a Changelog format in CHANGELOG.md
Describe notable changes briefly in CHANGELOG.md, ≤2 items per change type
Reference issues using format issue #<issue_number> in CHANGELOG.md
No empty lines between list items in same section of CHANGELOG.md
Skip adding entry if same change already exists in Unreleased section of CHANGELOG.md
No duplicate sections or items in Unreleased section of CHANGELOG.mdAlways update CHANGELOG.md Unreleased section
Files:
CHANGELOG.md
⚙️ CodeRabbit configuration file
CHANGELOG.md: # Changelog Guidelines
- Always update the Unreleased section in CHANGELOG.md
- Use Keep a Changelog format
- Describe notable changes briefly, ≤2 items per change type
- Reference issues using format issue #<issue_number>
- No empty lines between list items in same section
- Skip adding entry if same change already exists in Unreleased section
- No duplicate sections or items in Unreleased section
Files:
CHANGELOG.md
**/*.md
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-markdown.instructions.md)
**/*.md: Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
Use 2 spaces for indentation in Markdown files
Use '1.' for all items in ordered lists (1/1/1 numbering style)
DisableMD013rule by adding a comment for tables/code blocks exceeding 80 characters
Empty lines required before/after code blocks and headings (except before line 1)
Escape backslashes in file paths only (not in code blocks)
Code blocks must specify language identifiers
Format parameters using bold in Markdown documentation
Format values and literals usinginline codein Markdown documentation
Format resource/module/product names using italic in Markdown documentation
Format commands/files/paths usinginline codein Markdown documentation
Files:
CHANGELOG.md
⚙️ CodeRabbit configuration file
**/*.md: # Markdown Style Guidelines
- Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
- Use 2 spaces for indentation
- Use '1.' for all items in ordered lists (1/1/1 numbering style)
- Disable
MD013rule by adding a comment for tables/code blocks exceeding 80 characters- Empty lines required before/after code blocks and headings (except before line 1)
- Escape backslashes in file paths only (not in code blocks)
- Code blocks must specify language identifiers
Text Formatting
- Parameters: bold
- Values/literals:
inline code- Resource/module/product names: italic
- Commands/files/paths:
inline code
Files:
CHANGELOG.md
source/en-US/*.strings.psd1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)
source/en-US/*.strings.psd1: Store command/function localized strings in source/en-US/{MyModuleName}.strings.psd1 files
Store class resource localized strings in source/en-US/{ResourceClassName}.strings.psd1 files
Use Key Naming Pattern format: Verb_FunctionName_Action with underscore separators (e.g., Get_Database_ConnectingToDatabase)
Format localized strings using ConvertFrom-StringData with placeholder syntax: KeyName = Message with {0} placeholder. (PREFIX0001)
Prefix string IDs with an acronym derived from the first letter of each word in the class or function name (e.g., SqlSetup → SS, Get-SqlDscDatabase → GSDD), followed by sequential numbers starting from 0001
Files:
source/en-US/SqlServerDsc.strings.psd1
**/*.psd1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
Don't use
NestedModulesfor shared commands withoutRootModulein module manifest
Files:
source/en-US/SqlServerDsc.strings.psd1
tests/Unit/Public/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)
Public commands:
tests/Unit/Public/{Name}.Tests.ps1
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
tests/Unit/**/*.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Unit tests should be located in
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.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: Test with localized strings usingInModuleScope -ScriptBlock { $script:localizedData.Key }in Pester unit tests
Mock files using the$TestDrivevariable (path to the test drive) in Pester unit tests
All public commands require parameter set validation tests in unit tests
Use the exact Pester test setup block withBeforeDiscovery,BeforeAll, andAfterAllblocks beforeDescribein unit tests, includingDscResource.Testmodule import and PSDefaultParameterValues configuration
Use parameter set validation test template withGet-CommandandParameterSetsproperty, supporting both single and multiple parameter sets via-ForEacharray in Pester unit tests
Use parameter properties test template withGet-Commandto validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.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 -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:ModuleName') ...
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
**/tests/Unit/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Unit/**/*.ps1: Unit tests must use SMO stub types from SMO.cs, never mock SMO types
Unit tests must add$env:SqlServerDscCI = $trueinBeforeAllblock and remove inAfterAllblock
Load SMO stub types from SMO.cs in unit test files usingAdd-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
🧠 Learnings (52)
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1CHANGELOG.md
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for command integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1CHANGELOG.mdtests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact Pester test setup block with `BeforeDiscovery`, `BeforeAll`, and `AfterAll` blocks before `Describe` in unit tests, including `DscResource.Test` module import and PSDefaultParameterValues configuration
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration tests must cover all scenarios and code paths
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for commands should be located in `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.759Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.759Z
Learning: Integration tests for MOF-based DSC resources (located in source/DSCResources/**) should use the Initialize-TestEnvironment pattern with -ResourceType 'Mof', not the BeforeDiscovery/BeforeAll pattern. The BeforeDiscovery/BeforeAll pattern is for class-based resources only.
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1CHANGELOG.mdtests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mocking in `BeforeAll` (`BeforeEach` only when required)
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define `-ForEach` variables in `BeforeDiscovery` (close to usage)
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-10-11T08:18:26.062Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:18:26.062Z
Learning: In unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), when DscResource.Test module dependency is not found during BeforeDiscovery setup, the error message should instruct users to run ".\build.ps1 -Tasks noop" (not "build") because the noop task is designed for quick test environment setup. The build task is more extensive and unnecessary when tests run in a separate process, as the module should already be built before running tests.
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Force Parameter Pattern: Use `if ($Force.IsPresent -and -not $Confirm) { $ConfirmPreference = 'None' }`
Applied to files:
source/Public/Set-SqlDscRSUrlReservation.ps1
📚 Learning: 2025-08-18T10:44:38.990Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: source/Public/New-SqlDscLogin.ps1:254-257
Timestamp: 2025-08-18T10:44:38.990Z
Learning: When implementing Force and Confirm parameter interaction in PowerShell functions with SupportsShouldProcess, use the pattern `if ($Force.IsPresent -and -not $Confirm)` to suppress confirmations. This ensures that explicit `-Confirm:$true` is respected even when `-Force` is present, preserving user intent when they explicitly request confirmation alongside Force.
Applied to files:
source/Public/Set-SqlDscRSUrlReservation.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Include a `Force` parameter for functions that use `$PSCmdlet.ShouldContinue` or `$PSCmdlet.ShouldProcess`
Applied to files:
source/Public/Set-SqlDscRSUrlReservation.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : `$PSCmdlet.ShouldProcess` must use the required pattern with `$descriptionMessage`, `$confirmationMessage`, and `$captionMessage`
Applied to files:
source/Public/Set-SqlDscRSUrlReservation.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/Public/**/*.ps1 : Public commands must follow the naming format `{Verb}-SqlDsc{Noun}`
Applied to files:
CHANGELOG.md
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/DSCResources/**/*DatabaseEngine*/*.ps1 : Database Engine resources must inherit from `SqlResourceBase`
Applied to files:
CHANGELOG.md
📚 Learning: 2025-11-27T17:58:20.404Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-11-27T17:58:20.404Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : DSC class-based resources must implement required methods: `Get()`, `Test()`, `Set()`, `GetCurrentState()`, and `Modify()` following the specified pattern
Applied to files:
CHANGELOG.md
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Classes/*.[Tt]ests.ps1 : Class resources: `tests/Unit/Classes/{Name}.Tests.ps1`
Applied to files:
CHANGELOG.md
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` and `Test-TargetResource` must have identical parameters
Applied to files:
CHANGELOG.mdtests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-22T17:36:09.703Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2343
File: source/Classes/004.DatabaseFileGroupSpec.ps1:5-34
Timestamp: 2025-11-22T17:36:09.703Z
Learning: The comment-based help requirements for ## Requirements and ## Known issues sections only apply to class-based DSC resources (classes decorated with [DscResource(...)]) in source/Classes/**/*.ps1, not to regular helper classes, DTO classes, or specification classes in the same directory.
Applied to files:
CHANGELOG.md
📚 Learning: 2025-12-10T20:07:36.848Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2367
File: source/en-US/SqlServerDsc.strings.psd1:489-498
Timestamp: 2025-12-10T20:07:36.848Z
Learning: Do not renumber localization keys to make them sequential when gaps exist in error codes (e.g., RSDD0001 vs RSDD0003). Preserve existing keys. QA tests should already guard against missing or extra localization string keys, so avoid altering the numbering just to achieve contiguity. If modifications touch localization strings, ensure tests reflect the current keys and document any intentional gaps.
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-10-04T21:33:23.022Z
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use localized strings for all messages including Write-Verbose, Write-Error, and other messaging commands
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-10-03T15:27:24.417Z
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:9-22
Timestamp: 2025-10-03T15:27:24.417Z
Learning: In the UpdateServicesDsc repository, MOF-based DSC resources follow a minimal comment-based help convention that includes only .SYNOPSIS and .PARAMETER sections. The .DESCRIPTION, .INPUTS, and .OUTPUTS sections are intentionally omitted, even though functions have [OutputType()] attributes. This is consistent across all existing DSC resources: MSFT_UpdateServicesServer, MSFT_UpdateServicesCleanup, and MSFT_UpdateServicesApprovalRule.
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/en-US/DSC_*.strings.psd1 : Name localized strings file as `DSC_<ResourceName>.strings.psd1` in the `en-US` folder
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:58:42.327Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-11-27T17:58:42.327Z
Learning: Applies to source/en-US/*.strings.psd1 : Prefix string IDs with an acronym derived from the first letter of each word in the class or function name (e.g., SqlSetup → SS, Get-SqlDscDatabase → GSDD), followed by sequential numbers starting from 0001
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/en-US/DSC_*.strings.psd1 : In `.strings.psd1` files, use underscores as word separators in localized string key names for multi-word keys
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use names returned from `Get-UICulture` for additional language folder names in DSC resources
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Import localized strings using `Get-LocalizedData` at the module top level
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:58:42.327Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-11-27T17:58:42.327Z
Learning: Applies to source/en-US/*.strings.psd1 : Store class resource localized strings in source/en-US/{ResourceClassName}.strings.psd1 files
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` verbose messages must start with "Setting the desired state of..."
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use parameter set validation test template with `Get-Command` and `ParameterSets` property, supporting both single and multiple parameter sets via `-ForEach` array in Pester unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : All public commands require parameter set validation tests in unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Set `$PSDefaultParameterValues` for `Mock:ModuleName`, `Should:ModuleName`, `InModuleScope:ModuleName`
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use parameter properties test template with `Get-Command` to validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Unused mandatory parameters in `Set-TargetResource` and `Test-TargetResource` should include "Not used in <function_name>" in the help comment
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use `$PSDefaultParameterValues` only for Pester commands (`Describe`, `Context`, `It`, `Mock`, `Should`, `InModuleScope`)
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-09-25T16:38:08.867Z
Learnt from: johlju
Repo: dsccommunity/ActiveDirectoryDsc PR: 741
File: tests/Integration/MSFT_ADReadOnlyDomainControllerAccount.Integration.Tests.ps1:102-104
Timestamp: 2025-09-25T16:38:08.867Z
Learning: Test-DscConfiguration cmdlet returns string values 'True' or 'False', not boolean values. Therefore, Should -Be 'True' is correct, and Should -BeTrue would be incorrect for this cmdlet.
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-08-16T13:22:15.230Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:78-93
Timestamp: 2025-08-16T13:22:15.230Z
Learning: In PowerShell unit tests for parameter validation in SqlServerDsc, accessing parameter attributes directly like `$cmd.Parameters['ParameterName'].Attributes.Mandatory` works correctly because PowerShell automatically iterates through the array and returns the property values. Additional filtering to ParameterAttribute is not necessary when the parameter structure is known and controlled.
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : `ValueFromPipeline` must be consistent across all parameter sets declarations for the same parameter
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Follow PowerShell style and test guideline instructions strictly
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Each scenario = separate `Context` block
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit `-MockWith` when returning `$null`
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: After changing SMO stub types, run tests in a new PowerShell session for changes to take effect
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.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: PSScriptAnalyzer
🔇 Additional comments (15)
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1 (2)
4-32: Integration test harness and module initialization look correctThe
BeforeDiscoveryandBeforeAllblocks follow the standard DscResource.Test + module import pattern and satisfy the required integration test setup for this repo. No issues here.
77-126: URL reservation/state validation is thorough and well-structuredThe comparison logic between
$script:urlReservationsBeforeand$urlReservationsAfterand the accessibility checks viaTest-SqlDscRSAccessible -Detailedcover the critical paths (same reservations after recreate, per-application accessibility and HTTP 200). The loops and assertions are clear and match the intended RecreateExisting behavior.CHANGELOG.md (2)
192-196: RS service account changelog entry is clear and well-placedThe “Added” entry for
Get-SqlDscRSServiceAccount/Set-SqlDscRSServiceAccountsuccinctly explains purpose, scope, and key implementation detail (SetWindowsServiceIdentity+ encryption key backups) and fits the existing style in the section.
262-271:Set-SqlDscRSUrlReservationRecreate mode and prerequisites entries look goodThe “Changed” entries accurately document the new
Recreateparameter set, its behavior, and the addedsvc-RSprerequisite user for integration tests, using consistent wording and markdown formatting with the rest of the changelog.source/en-US/SqlServerDsc.strings.psd1 (2)
764-769: LGTM!The new localization strings for the URL reservation recreation feature follow the correct naming pattern (
Verb_FunctionName_Action) and appropriately include string IDs for error messages while omitting them for verbose/ShouldProcess messages.
807-818: LGTM!The new localization strings for service account management follow the established conventions:
- Key naming uses the correct
Verb_FunctionName_Actionformat- Error and warning messages include appropriate string IDs (
SSRSSA0001,SSRSSA0002)- ShouldProcess messages follow the required pattern with Description, Confirmation, and Caption variants
source/Public/Set-SqlDscRSUrlReservation.ps1 (6)
1-57: LGTM!The comment-based help is comprehensive and well-structured. It properly documents:
- Both operation modes (Set and Recreate) with clear descriptions
- Parameter-specific notes indicating which parameters apply to which mode
- Important caveats about LCID behavior in Recreate mode
- Appropriate examples covering both usage patterns
114-149: LGTM!The parameter definitions are well-structured:
DefaultParameterSetName = 'Set'correctly establishes the default behavior- Parameter set separation properly ensures
-RecreateExistingcannot be combined with-Applicationor-UrlStringConfirmImpact = 'High'is appropriate for operations that modify URL reservations
151-175: LGTM!The Force parameter pattern at lines 153-156 correctly follows the required pattern:
if ($Force.IsPresent -and -not $Confirm). The ShouldProcess message construction properly differentiates between Recreate and Set modes with appropriate localized strings.
179-215: LGTM!The Recreate mode logic is well-implemented:
- Properly handles empty/null reservation arrays
- Uses verbose logging for the no-reservations case
- LCID handling correctly checks
$PSBoundParametersbefore adding to common params- The remove-then-add pattern for each reservation ensures proper recreation
216-268: LGTM!The Set mode logic correctly:
- Builds the current URL list by filtering on the specified application
- Uses
Write-Debugfor diagnostic messages (appropriate for current/desired URL logging)- Computes the diff between current and desired URLs using
Where-Objectwith-notin- Shares common parameters for both Add and Remove operations
270-275: LGTM!The PassThru handling is correctly placed outside the ShouldProcess block, ensuring the configuration object is returned even during WhatIf operations if PassThru is specified.
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1 (3)
1-45: LGTM!The test setup follows the required pattern with proper
BeforeDiscovery,BeforeAll, andAfterAllblocks. The CI environment variable is correctly set and removed, andPSDefaultParameterValuesare properly configured.
46-81: LGTM!The parameter set validation tests correctly verify both the
SetandRecreateparameter sets, as well as confirmingSetis the default. This follows the required template for parameter set validation.
417-546: LGTM!The remaining test contexts for
RecreateExistingmode are well-structured:
- Each scenario is in a separate Context block
- Tests cover custom LCID, PassThru, empty reservations, WhatIf, and null reservations
- Mock assertions are appropriate for each scenario
…remove redundant checks
…rvation to improve clarity and ensure proper invocation counts
johlju
left a 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.
@johlju partially reviewed 16 files and all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2402 +/- ##
======================================
Coverage 94% 94%
======================================
Files 200 205 +5
Lines 10455 10570 +115
======================================
+ Hits 9840 9955 +115
Misses 615 615
🚀 New features to boost your workflow:
|
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/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1 (1)
80-88: AvoidShould -Not -Throw- invoke commands directly.Per coding guidelines, commands should be invoked directly rather than wrapping them in
{ } | Should -Not -Throw. This pattern appears multiple times in this file (lines 81, 112, 157, 220, 243, 270, 293).♻️ Suggested refactor for this occurrence
It 'Should set service account without errors' { - { $mockCimInstance | Set-SqlDscRSServiceAccount -Credential $mockCredential -Confirm:$false } | Should -Not -Throw + $null = $mockCimInstance | Set-SqlDscRSServiceAccount -Credential $mockCredential -Confirm:$false Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter {tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1 (1)
47-81: Consider consolidating parameter set tests using-ForEach.The guidelines recommend using
-ForEacharray for testing multiple parameter sets. While the current approach with separateItblocks is valid, consolidation improves maintainability.♻️ Optional consolidation using -ForEach pattern
It 'Should have the correct parameters in parameter set <ExpectedParameterSetName>' -ForEach @( @{ ExpectedParameterSetName = 'Set' ExpectedParameters = '-Configuration <Object> -Application <string> -UrlString <string[]> [-Lcid <int>] [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]' } @{ ExpectedParameterSetName = 'Recreate' ExpectedParameters = '-Configuration <Object> -RecreateExisting [-Lcid <int>] [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]' } ) { $result = $command.ParameterSets | Where-Object -FilterScript { $_.Name -eq $ExpectedParameterSetName } | Select-Object -Property @{ Name = 'ParameterListAsString' Expression = { $_.ToString() } } $result.ParameterListAsString | Should -Be $ExpectedParameters }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (12)
**/*.[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 insideDescribeblocks
Assertions only inItblocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
InsideItblocks, assign unused return objects to$null(unless part of pipeline)
Tested entity must be called from within theItblocks
Keep results and assertions in sameItblock
Avoid try-catch-finally for cleanup, useAfterAllorAfterEach
Avoid unnecessary remove/recreate cycles
OneDescribeblock per file matching the tested entity name
Contextdescriptions start with 'When'
Itdescriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
Public commands: Never useInModuleScope(unless retrieving localized strings or creating an object using an internal class)
Private functions/class resources: Always useInModuleScope
Each class method = separateContextblock
Each scenario = separateContextblock
Use nestedContextblocks for complex scenarios
Mocking inBeforeAll(BeforeEachonly when required)
Setup/teardown inBeforeAll,BeforeEach/AfterAll,AfterEachclose to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase:Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach
Use-BeTrue/-BeFalsenever-Be $true/-Be $false
Never useAssert-MockCalled, useShould -Invokeinstead
NoShould -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 useMockinsideInModuleScope-block
Never useparam()inside-MockWithscriptblock...
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.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 or creating an object using an internal class)- 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 usage- Spacing between blocks, arrange, act, and assert for readability
Syntax 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, `...
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
tests/Unit/Public/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)
Public commands:
tests/Unit/Public/{Name}.Tests.ps1
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
tests/Unit/**/*.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Unit tests should be located in
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.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: Test with localized strings usingInModuleScope -ScriptBlock { $script:localizedData.Key }in Pester unit tests
Mock files using the$TestDrivevariable (path to the test drive) in Pester unit tests
All public commands require parameter set validation tests in unit tests
Use the exact Pester test setup block withBeforeDiscovery,BeforeAll, andAfterAllblocks beforeDescribein unit tests, includingDscResource.Testmodule import and PSDefaultParameterValues configuration
Use parameter set validation test template withGet-CommandandParameterSetsproperty, supporting both single and multiple parameter sets via-ForEacharray in Pester unit tests
Use parameter properties test template withGet-Commandto validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.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 -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:ModuleName') ...
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
**/Public/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Public commands must follow the naming format
{Verb}-SqlDsc{Noun}
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
**/tests/Unit/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Unit/**/*.ps1: Unit tests must use SMO stub types from SMO.cs, never mock SMO types
Unit tests must add$env:SqlServerDscCI = $trueinBeforeAllblock and remove inAfterAllblock
Load SMO stub types from SMO.cs in unit test files usingAdd-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.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- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.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/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.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 as inline code with a 1‑line description...
Files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Integration tests for commands should be located in
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Location for command integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.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: Integration tests must use real environment only - no mocking allowed
Integration tests must cover all scenarios and code paths
UseGet-ComputerNamefor computer names in CI environments within integration tests
Avoid usingExpectedMessageparameter forShould -Throwassertions in integration tests
Call commands with-Forceparameter where applicable in integration tests to avoid prompting
Use-ErrorAction 'Stop'on commands in integration tests so failures surface immediately
Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.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 -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
**/tests/Integration/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Integration/**/*.ps1: Integration tests must useConnect-SqlDscDatabaseEnginefor SQL Server DB session with correct CI credentials
Integration tests must useDisconnect-SqlDscDatabaseEngineafterConnect-SqlDscDatabaseEngine
Files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
🧠 Learnings (47)
📓 Common learnings
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2367
File: source/en-US/SqlServerDsc.strings.psd1:489-498
Timestamp: 2025-12-10T20:07:45.822Z
Learning: In SqlServerDsc (and DSC Community modules), localization string error codes may have gaps in their sequential numbering (e.g., RSDD0001, RSDD0003) when strings are removed over time. Never suggest renumbering localization keys to make them sequential. QA tests safeguard against missing or extra localization string keys.
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use parameter set validation test template with `Get-Command` and `ParameterSets` property, supporting both single and multiple parameter sets via `-ForEach` array in Pester unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : All public commands require parameter set validation tests in unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` and `Test-TargetResource` must have identical parameters
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact Pester test setup block with `BeforeDiscovery`, `BeforeAll`, and `AfterAll` blocks before `Describe` in unit tests, including `DscResource.Test` module import and PSDefaultParameterValues configuration
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Unused mandatory parameters in `Set-TargetResource` and `Test-TargetResource` should include "Not used in <function_name>" in the help comment
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use parameter properties test template with `Get-Command` to validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Set `$PSDefaultParameterValues` for `Mock:ModuleName`, `Should:ModuleName`, `InModuleScope:ModuleName`
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mocking in `BeforeAll` (`BeforeEach` only when required)
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Mock` inside `InModuleScope`-block
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use `BeforeEach` and `AfterEach` sparingly
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never add an empty `-MockWith` block
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must use SMO stub types from SMO.cs, never mock SMO types
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Keep results and assertions in same `It` block
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Each scenario = separate `Context` block
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use nested `Context` blocks for complex scenarios
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Assert-MockCalled`, use `Should -Invoke` instead
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use `$PSDefaultParameterValues` only for Pester commands (`Describe`, `Context`, `It`, `Mock`, `Should`, `InModuleScope`)
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-09-25T16:38:08.867Z
Learnt from: johlju
Repo: dsccommunity/ActiveDirectoryDsc PR: 741
File: tests/Integration/MSFT_ADReadOnlyDomainControllerAccount.Integration.Tests.ps1:102-104
Timestamp: 2025-09-25T16:38:08.867Z
Learning: Test-DscConfiguration cmdlet returns string values 'True' or 'False', not boolean values. Therefore, Should -Be 'True' is correct, and Should -BeTrue would be incorrect for this cmdlet.
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-08-16T13:22:15.230Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:78-93
Timestamp: 2025-08-16T13:22:15.230Z
Learning: In PowerShell unit tests for parameter validation in SqlServerDsc, accessing parameter attributes directly like `$cmd.Parameters['ParameterName'].Attributes.Mandatory` works correctly because PowerShell automatically iterates through the array and returns the property values. Additional filtering to ParameterAttribute is not necessary when the parameter structure is known and controlled.
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : `ValueFromPipeline` must be consistent across all parameter sets declarations for the same parameter
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Follow PowerShell style and test guideline instructions strictly
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.759Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.759Z
Learning: Integration tests for MOF-based DSC resources (located in source/DSCResources/**) should use the Initialize-TestEnvironment pattern with -ResourceType 'Mof', not the BeforeDiscovery/BeforeAll pattern. The BeforeDiscovery/BeforeAll pattern is for class-based resources only.
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit `-MockWith` when returning `$null`
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-08-17T10:15:48.194Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: tests/Unit/Public/Remove-SqlDscLogin.Tests.ps1:36-39
Timestamp: 2025-08-17T10:15:48.194Z
Learning: Public command unit tests guideline: Never use InModuleScope unless accessing localized strings from $script:localizedData. PSDefaultParameterValues for InModuleScope should be kept in public command tests to support localized string retrieval when necessary.
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths
Applied to files:
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions and classes must have unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration tests must cover all scenarios and code paths
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-08-17T10:13:30.079Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: source/Public/Remove-SqlDscLogin.ps1:104-108
Timestamp: 2025-08-17T10:13:30.079Z
Learning: In SqlServerDsc unit tests, SMO object stubs (like Login objects) should have properly mocked Parent properties with correct Server stub types and valid InstanceName values, rather than handling null Parent scenarios in production code.
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: After changing SMO stub types, run tests in a new PowerShell session for changes to take effect
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Pass all mandatory parameters to avoid prompts
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : No default values for mandatory or switch parameters
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-10-03T15:27:24.417Z
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:9-22
Timestamp: 2025-10-03T15:27:24.417Z
Learning: In the UpdateServicesDsc repository, MOF-based DSC resources follow a minimal comment-based help convention that includes only .SYNOPSIS and .PARAMETER sections. The .DESCRIPTION, .INPUTS, and .OUTPUTS sections are intentionally omitted, even though functions have [OutputType()] attributes. This is consistent across all existing DSC resources: MSFT_UpdateServicesServer, MSFT_UpdateServicesCleanup, and MSFT_UpdateServicesApprovalRule.
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:58:20.404Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-11-27T17:58:20.404Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : DSC class-based resources must implement required methods: `Get()`, `Test()`, `Set()`, `GetCurrentState()`, and `Modify()` following the specified pattern
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for command integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for commands should be located in `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use `Get-ComputerName` for computer names in CI environments within integration tests
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define `-ForEach` variables in `BeforeDiscovery` (close to usage)
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.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: PSScriptAnalyzer
🔇 Additional comments (10)
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1 (4)
1-44: LGTM!The test setup block follows the required template correctly:
BeforeDiscoveryblock with DscResource.Test module importBeforeAllwith$env:SqlServerDscCI = $true(line 29)AfterAllproperly removes the environment variable (line 43)$PSDefaultParameterValuescorrectly configured for Pester commands
46-64: LGTM!Parameter set validation follows the required template pattern with
Get-Commandand-ForEacharray.
66-95: Good test structure with separated concerns.The context correctly separates the invocation test from the return value test into distinct
Itblocks, following good testing practices.
179-181: Good error handling test pattern.Using
Should -Throw -ErrorIdto validate specific error IDs is the correct approach for testing terminating errors.tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1 (3)
1-34: LGTM!The integration test setup block follows the required pattern:
BeforeDiscoverywith DscResource.Test module import and fallbackBeforeAllimports the module and CommonTestHelper- No
$env:SqlServerDscCI(correct - this is only for unit tests)- No mocking (correct for integration tests)
47-68: LGTM!Excellent integration test setup:
- Uses
Get-ComputerNameper guidelines (line 59)- Commands use
-ErrorAction 'Stop'to surface failures immediately (lines 62, 65)- CI-aware instance selection for PBIRS vs SSRS
- Verbose logging aids debugging in CI
70-109: LGTM!Well-structured integration test context:
- Context/It descriptions follow naming conventions ('When...', 'Should...')
-ErrorAction 'Stop'used consistently on commands-Becauseparameters provide clear failure context- Comprehensive validation of service account, initialization, URL reservations, and site accessibility
tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1 (3)
26-44: LGTM!The test setup follows the required template with
$env:SqlServerDscCI = $truein BeforeAll and proper cleanup in AfterAll.
349-415: Comprehensive RecreateExisting tests.The new tests thoroughly cover the
RecreateExistingparameter set:
- Multiple applications with proper remove/re-add verification
- Uses
-Scope ItonShould -Invokewhere multipleItblocks share the same mocks- Validates each URL reservation is removed and re-added correctly
417-546: Good edge case and behavior coverage.The additional contexts properly test:
- Custom Lcid propagation (lines 436-442)
- PassThru return value (lines 464-469)
- Empty reservations array handling (lines 491-497)
- WhatIf prevention of modifications (lines 511-517)
- Null reservations handling (lines 539-545)
…fact download step
…and `Test_HQRM`) to reduce overall pipeline execution time by approximately 15 minutes.
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)
CHANGELOG.md (1)
266-275: Consider consolidating Changed bullets and calling out the new integration testFunctionally this section is accurate, but two minor polish points:
You now have three separate Changed bullets for this PR (
SqlServerDsc,Set-SqlDscRSUrlReservation, and “Prerequisites Integration Tests”), which nudges against the “≤2 items per change type” guidance. You could fold the “Prerequisites Integration Tests” line into theSet-SqlDscRSUrlReservationbullet (as an extra sub-bullet) to keep this as a single logical change related to RS URL reservations/service accounts.The PR also adds an integration test that restarts the RS service after URL reservation recreation; that behavior isn’t mentioned. It might be worth expanding the existing “Prerequisites Integration Tests” text to something like “…for Reporting Services service account integration testing and post-reservation-recreate service restart coverage” instead of introducing a separate bullet.
Not required, but would tighten adherence to the changelog guidelines and better reflect the RS test changes.
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1 (1)
77-79: Assign unused return to$nullfor consistency.Line 74 correctly uses
$null = $script:configuration | Set-SqlDscRSUrlReservation ...to suppress output, but line 78 does not follow the same pattern. As per coding guidelines, unused return objects insideItblocks should be assigned to$null.♻️ Suggested fix
It 'Should restart the Reporting Services service' { - $script:configuration | Restart-SqlDscRSService -Force -ErrorAction 'Stop' + $null = $script:configuration | Restart-SqlDscRSService -Force -ErrorAction 'Stop' }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
CHANGELOG.mdazure-pipelines.ymltests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.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 insideDescribeblocks
Assertions only inItblocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
InsideItblocks, assign unused return objects to$null(unless part of pipeline)
Tested entity must be called from within theItblocks
Keep results and assertions in sameItblock
Avoid try-catch-finally for cleanup, useAfterAllorAfterEach
Avoid unnecessary remove/recreate cycles
OneDescribeblock per file matching the tested entity name
Contextdescriptions start with 'When'
Itdescriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
Public commands: Never useInModuleScope(unless retrieving localized strings or creating an object using an internal class)
Private functions/class resources: Always useInModuleScope
Each class method = separateContextblock
Each scenario = separateContextblock
Use nestedContextblocks for complex scenarios
Mocking inBeforeAll(BeforeEachonly when required)
Setup/teardown inBeforeAll,BeforeEach/AfterAll,AfterEachclose to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase:Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach
Use-BeTrue/-BeFalsenever-Be $true/-Be $false
Never useAssert-MockCalled, useShould -Invokeinstead
NoShould -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 useMockinsideInModuleScope-block
Never useparam()inside-MockWithscriptblock...
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.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 or creating an object using an internal class)- 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 usage- Spacing between blocks, arrange, act, and assert for readability
Syntax 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, `...
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Integration tests for commands should be located in
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Location for command integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.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: Integration tests must use real environment only - no mocking allowed
Integration tests must cover all scenarios and code paths
UseGet-ComputerNamefor computer names in CI environments within integration tests
Avoid usingExpectedMessageparameter forShould -Throwassertions in integration tests
Call commands with-Forceparameter where applicable in integration tests to avoid prompting
Use-ErrorAction 'Stop'on commands in integration tests so failures surface immediately
Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.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 -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
**/tests/Integration/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Integration/**/*.ps1: Integration tests must useConnect-SqlDscDatabaseEnginefor SQL Server DB session with correct CI credentials
Integration tests must useDisconnect-SqlDscDatabaseEngineafterConnect-SqlDscDatabaseEngine
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.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- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.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/Post.UrlReservationRecreate.RS.Integration.Tests.ps1CHANGELOG.mdazure-pipelines.yml
{**/*.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 as inline code with a 1‑line description...
Files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
CHANGELOG.md
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-changelog.instructions.md)
CHANGELOG.md: Always update the Unreleased section in CHANGELOG.md
Use Keep a Changelog format in CHANGELOG.md
Describe notable changes briefly in CHANGELOG.md, ≤2 items per change type
Reference issues using format issue #<issue_number> in CHANGELOG.md
No empty lines between list items in same section of CHANGELOG.md
Skip adding entry if same change already exists in Unreleased section of CHANGELOG.md
No duplicate sections or items in Unreleased section of CHANGELOG.mdAlways update CHANGELOG.md Unreleased section
Files:
CHANGELOG.md
⚙️ CodeRabbit configuration file
CHANGELOG.md: # Changelog Guidelines
- Always update the Unreleased section in CHANGELOG.md
- Use Keep a Changelog format
- Describe notable changes briefly, ≤2 items per change type
- Reference issues using format issue #<issue_number>
- No empty lines between list items in same section
- Skip adding entry if same change already exists in Unreleased section
- No duplicate sections or items in Unreleased section
Files:
CHANGELOG.md
**/*.md
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-markdown.instructions.md)
**/*.md: Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
Use 2 spaces for indentation in Markdown files
Use '1.' for all items in ordered lists (1/1/1 numbering style)
DisableMD013rule by adding a comment for tables/code blocks exceeding 80 characters
Empty lines required before/after code blocks and headings (except before line 1)
Escape backslashes in file paths only (not in code blocks)
Code blocks must specify language identifiers
Format parameters using bold in Markdown documentation
Format values and literals usinginline codein Markdown documentation
Format resource/module/product names using italic in Markdown documentation
Format commands/files/paths usinginline codein Markdown documentation
Files:
CHANGELOG.md
⚙️ CodeRabbit configuration file
**/*.md: # Markdown Style Guidelines
- Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
- Use 2 spaces for indentation
- Use '1.' for all items in ordered lists (1/1/1 numbering style)
- Disable
MD013rule by adding a comment for tables/code blocks exceeding 80 characters- Empty lines required before/after code blocks and headings (except before line 1)
- Escape backslashes in file paths only (not in code blocks)
- Code blocks must specify language identifiers
Text Formatting
- Parameters: bold
- Values/literals:
inline code- Resource/module/product names: italic
- Commands/files/paths:
inline code
Files:
CHANGELOG.md
azure-pipelines.yml
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Integration test script files must be added to a group within the test stage in ./azure-pipelines.yml based on required dependencies
Files:
azure-pipelines.yml
🧠 Learnings (33)
📓 Common learnings
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2367
File: source/en-US/SqlServerDsc.strings.psd1:489-498
Timestamp: 2025-12-10T20:07:45.822Z
Learning: In SqlServerDsc (and DSC Community modules), localization string error codes may have gaps in their sequential numbering (e.g., RSDD0001, RSDD0003) when strings are removed over time. Never suggest renumbering localization keys to make them sequential. QA tests safeguard against missing or extra localization string keys.
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for command integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for commands should be located in `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration tests must cover all scenarios and code paths
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1CHANGELOG.mdazure-pipelines.yml
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact Pester test setup block with `BeforeDiscovery`, `BeforeAll`, and `AfterAll` blocks before `Describe` in unit tests, including `DscResource.Test` module import and PSDefaultParameterValues configuration
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1CHANGELOG.mdazure-pipelines.yml
📚 Learning: 2025-11-27T18:56:46.759Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.759Z
Learning: Integration tests for MOF-based DSC resources (located in source/DSCResources/**) should use the Initialize-TestEnvironment pattern with -ResourceType 'Mof', not the BeforeDiscovery/BeforeAll pattern. The BeforeDiscovery/BeforeAll pattern is for class-based resources only.
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1CHANGELOG.md
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mocking in `BeforeAll` (`BeforeEach` only when required)
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-10-11T08:18:26.062Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:18:26.062Z
Learning: In unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), when DscResource.Test module dependency is not found during BeforeDiscovery setup, the error message should instruct users to run ".\build.ps1 -Tasks noop" (not "build") because the noop task is designed for quick test environment setup. The build task is more extensive and unnecessary when tests run in a separate process, as the module should already be built before running tests.
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define `-ForEach` variables in `BeforeDiscovery` (close to usage)
Applied to files:
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/Public/**/*.ps1 : Public commands must follow the naming format `{Verb}-SqlDsc{Noun}`
Applied to files:
CHANGELOG.md
📚 Learning: 2025-12-10T20:07:45.822Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2367
File: source/en-US/SqlServerDsc.strings.psd1:489-498
Timestamp: 2025-12-10T20:07:45.822Z
Learning: In SqlServerDsc (and DSC Community modules), localization string error codes may have gaps in their sequential numbering (e.g., RSDD0001, RSDD0003) when strings are removed over time. Never suggest renumbering localization keys to make them sequential. QA tests safeguard against missing or extra localization string keys.
Applied to files:
CHANGELOG.md
📚 Learning: 2025-10-03T15:27:24.417Z
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:9-22
Timestamp: 2025-10-03T15:27:24.417Z
Learning: In the UpdateServicesDsc repository, MOF-based DSC resources follow a minimal comment-based help convention that includes only .SYNOPSIS and .PARAMETER sections. The .DESCRIPTION, .INPUTS, and .OUTPUTS sections are intentionally omitted, even though functions have [OutputType()] attributes. This is consistent across all existing DSC resources: MSFT_UpdateServicesServer, MSFT_UpdateServicesCleanup, and MSFT_UpdateServicesApprovalRule.
Applied to files:
CHANGELOG.md
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
Repo: dsccommunity/ActiveDirectoryDsc PR: 741
File: azure-pipelines.yml:104-104
Timestamp: 2025-08-10T15:11:52.897Z
Learning: In the ActiveDirectoryDsc project, HQRM (High Quality Resource Module) tests must run in PowerShell 5 (Windows PowerShell) using `pwsh: false` in the Azure Pipelines configuration, while unit tests can run in PowerShell 7 (PowerShell Core) with `pwsh: true`. This differentiation is intentional due to HQRM's specific requirements and dependencies on Windows PowerShell.
Applied to files:
CHANGELOG.mdazure-pipelines.yml
📚 Learning: 2025-11-27T17:57:47.617Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T17:57:47.617Z
Learning: SqlServerDsc-specific guidelines and requirements override general project guidelines and requirements
Applied to files:
CHANGELOG.md
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/DSCResources/**/*DatabaseEngine*/*.ps1 : Database Engine resources must inherit from `SqlResourceBase`
Applied to files:
CHANGELOG.md
📚 Learning: 2025-11-27T17:58:20.404Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-11-27T17:58:20.404Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : DSC class-based resources must implement required methods: `Get()`, `Test()`, `Set()`, `GetCurrentState()`, and `Modify()` following the specified pattern
Applied to files:
CHANGELOG.md
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Classes/*.[Tt]ests.ps1 : Class resources: `tests/Unit/Classes/{Name}.Tests.ps1`
Applied to files:
CHANGELOG.mdazure-pipelines.yml
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` and `Test-TargetResource` must have identical parameters
Applied to files:
CHANGELOG.md
📚 Learning: 2025-11-22T17:36:09.703Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2343
File: source/Classes/004.DatabaseFileGroupSpec.ps1:5-34
Timestamp: 2025-11-22T17:36:09.703Z
Learning: The comment-based help requirements for ## Requirements and ## Known issues sections only apply to class-based DSC resources (classes decorated with [DscResource(...)]) in source/Classes/**/*.ps1, not to regular helper classes, DTO classes, or specification classes in the same directory.
Applied to files:
CHANGELOG.md
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to azure-pipelines.yml : Integration test script files must be added to a group within the test stage in ./azure-pipelines.yml based on required dependencies
Applied to files:
azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Run QA tests using `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
Applied to files:
azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use `Get-ComputerName` for computer names in CI environments within integration tests
Applied to files:
azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Run tests with coverage using `Invoke-PesterJob -Path '{tests filepath}' -EnableSourceLineMapping -FilterCodeCoverageResult '{pattern}'`
Applied to files:
azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use `-ErrorAction 'Stop'` on commands in integration tests so failures surface immediately
Applied to files:
azure-pipelines.yml
⏰ 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: PSScriptAnalyzer
🔇 Additional comments (8)
CHANGELOG.md (2)
192-196: Service account cmdlets entry looks consistent and clearThe Added entry correctly describes the new
Get-SqlDscRSServiceAccount/Set-SqlDscRSServiceAccountcommands at the right granularity and matches the existing style for RS-related command bullets. No issues from a changelog or formatting perspective.
211-214: Pipeline change description is fine as writtenThe
SqlServerDsc/pipeline bullet is concise, specific about splittingTest_HQRMintoTest_QAandTest_HQRM, and fits the existing “module/pipeline” pattern in the Changed section. No required adjustments.azure-pipelines.yml (3)
119-150: LGTM! Job rename clarifies responsibility.The rename from
Test_HQRMtoTest_QAaccurately reflects that this job runs QA tests. The separation enables parallel execution with the new dedicated HQRM job, improving pipeline efficiency.
151-180: LGTM! Properly configured parallel HQRM job.The new dedicated
Test_HQRMjob is correctly configured withpwsh: false(line 172) to run in Windows PowerShell as required for HQRM tests. The separation from QA tests enables parallel execution, reducing overall pipeline time as intended.
576-580: LGTM! Group 6 tests properly integrated.The four Group 6 integration tests are correctly placed in both Reporting Services and Power BI Report Server pipelines:
- Service account set/get operations
- URL reservation recreation validation
- Post-service-account-change validation
The logical ordering (after Group 5 initialization, before Group 8 teardown) ensures proper test dependencies and validates the new service account management functionality.
Also applies to: 666-670
tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1 (3)
1-34: LGTM!The setup block correctly follows the required integration test pattern with
SuppressMessageAttribute,BeforeDiscoveryforDscResource.Testmodule resolution, andBeforeAllfor module import. The comment explaining why-Forceis not used on the module import is helpful.
36-64: LGTM!The documentation clearly explains the test's purpose and execution order dependency on
Post.ServiceAccountChange.RS. The instance selection logic properly handles both PBIRS and SSRS configurations with appropriate error handling.
81-109: LGTM!The verification logic correctly compares before and after URL reservations by checking that each Application/UrlString pair exists. The
-Becausemessages provide clear failure context. While the nested loop could potentially be simplified, the current implementation is readable and correct.
…ce account tests for clarity
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
🤖 Fix all issues with AI agents
In @tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1:
- Line 99: The test currently wraps the Invoke-SqlDscQuery call with a pipeline
to Should -Not -Throw; remove that wrapper and call Invoke-SqlDscQuery directly
so any thrown exception fails the test naturally. Locate the line containing "{
Invoke-SqlDscQuery @invokeSqlDscQueryParameters } | Should -Not -Throw -Because
..." and replace it by invoking Invoke-SqlDscQuery @invokeSqlDscQueryParameters
without the scriptblock/Should assertion, preserving the same parameters and
intent.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
azure-pipelines.ymltests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (13)
**/*.[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 insideDescribeblocks
Assertions only inItblocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
InsideItblocks, assign unused return objects to$null(unless part of pipeline)
Tested entity must be called from within theItblocks
Keep results and assertions in sameItblock
Avoid try-catch-finally for cleanup, useAfterAllorAfterEach
Avoid unnecessary remove/recreate cycles
OneDescribeblock per file matching the tested entity name
Contextdescriptions start with 'When'
Itdescriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
Public commands: Never useInModuleScope(unless retrieving localized strings or creating an object using an internal class)
Private functions/class resources: Always useInModuleScope
Each class method = separateContextblock
Each scenario = separateContextblock
Use nestedContextblocks for complex scenarios
Mocking inBeforeAll(BeforeEachonly when required)
Setup/teardown inBeforeAll,BeforeEach/AfterAll,AfterEachclose to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase:Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach
Use-BeTrue/-BeFalsenever-Be $true/-Be $false
Never useAssert-MockCalled, useShould -Invokeinstead
NoShould -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 useMockinsideInModuleScope-block
Never useparam()inside-MockWithscriptblock...
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.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 or creating an object using an internal class)- 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 usage- Spacing between blocks, arrange, act, and assert for readability
Syntax 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, `...
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Integration tests for commands should be located in
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Location for command integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.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: Integration tests must use real environment only - no mocking allowed
Integration tests must cover all scenarios and code paths
UseGet-ComputerNamefor computer names in CI environments within integration tests
Avoid usingExpectedMessageparameter forShould -Throwassertions in integration tests
Call commands with-Forceparameter where applicable in integration tests to avoid prompting
Use-ErrorAction 'Stop'on commands in integration tests so failures surface immediately
Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.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 -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
**/tests/Integration/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Integration/**/*.ps1: Integration tests must useConnect-SqlDscDatabaseEnginefor SQL Server DB session with correct CI credentials
Integration tests must useDisconnect-SqlDscDatabaseEngineafterConnect-SqlDscDatabaseEngine
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.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- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.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/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1azure-pipelines.yml
{**/*.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 as inline code with a 1‑line description...
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
tests/Unit/Public/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)
Public commands:
tests/Unit/Public/{Name}.Tests.ps1
Files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
tests/Unit/**/*.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Unit tests should be located in
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
Files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.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: Test with localized strings usingInModuleScope -ScriptBlock { $script:localizedData.Key }in Pester unit tests
Mock files using the$TestDrivevariable (path to the test drive) in Pester unit tests
All public commands require parameter set validation tests in unit tests
Use the exact Pester test setup block withBeforeDiscovery,BeforeAll, andAfterAllblocks beforeDescribein unit tests, includingDscResource.Testmodule import and PSDefaultParameterValues configuration
Use parameter set validation test template withGet-CommandandParameterSetsproperty, supporting both single and multiple parameter sets via-ForEacharray in Pester unit tests
Use parameter properties test template withGet-Commandto validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests
Files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.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 -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:ModuleName') ...
Files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
**/Public/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Public commands must follow the naming format
{Verb}-SqlDsc{Noun}
Files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
**/tests/Unit/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Unit/**/*.ps1: Unit tests must use SMO stub types from SMO.cs, never mock SMO types
Unit tests must add$env:SqlServerDscCI = $trueinBeforeAllblock and remove inAfterAllblock
Load SMO stub types from SMO.cs in unit test files usingAdd-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"
Files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
azure-pipelines.yml
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Integration test script files must be added to a group within the test stage in ./azure-pipelines.yml based on required dependencies
Files:
azure-pipelines.yml
🧠 Learnings (39)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for commands should be located in `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for command integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration tests must cover all scenarios and code paths
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact Pester test setup block with `BeforeDiscovery`, `BeforeAll`, and `AfterAll` blocks before `Describe` in unit tests, including `DscResource.Test` module import and PSDefaultParameterValues configuration
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.759Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.759Z
Learning: Integration tests for MOF-based DSC resources (located in source/DSCResources/**) should use the Initialize-TestEnvironment pattern with -ResourceType 'Mof', not the BeforeDiscovery/BeforeAll pattern. The BeforeDiscovery/BeforeAll pattern is for class-based resources only.
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define `-ForEach` variables in `BeforeDiscovery` (close to usage)
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mocking in `BeforeAll` (`BeforeEach` only when required)
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-10-11T08:18:26.062Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:18:26.062Z
Learning: In unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), when DscResource.Test module dependency is not found during BeforeDiscovery setup, the error message should instruct users to run ".\build.ps1 -Tasks noop" (not "build") because the noop task is designed for quick test environment setup. The build task is more extensive and unnecessary when tests run in a separate process, as the module should already be built before running tests.
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : All public commands require parameter set validation tests in unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use parameter set validation test template with `Get-Command` and `ParameterSets` property, supporting both single and multiple parameter sets via `-ForEach` array in Pester unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions and classes must have unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-08-17T10:13:30.079Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: source/Public/Remove-SqlDscLogin.ps1:104-108
Timestamp: 2025-08-17T10:13:30.079Z
Learning: In SqlServerDsc unit tests, SMO object stubs (like Login objects) should have properly mocked Parent properties with correct Server stub types and valid InstanceName values, rather than handling null Parent scenarios in production code.
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must use SMO stub types from SMO.cs, never mock SMO types
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Follow PowerShell style and test guideline instructions strictly
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: After changing SMO stub types, run tests in a new PowerShell session for changes to take effect
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Unused mandatory parameters in `Set-TargetResource` and `Test-TargetResource` should include "Not used in <function_name>" in the help comment
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Pass all mandatory parameters to avoid prompts
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : No default values for mandatory or switch parameters
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` and `Test-TargetResource` must have identical parameters
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use parameter properties test template with `Get-Command` to validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-10-03T15:27:24.417Z
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:9-22
Timestamp: 2025-10-03T15:27:24.417Z
Learning: In the UpdateServicesDsc repository, MOF-based DSC resources follow a minimal comment-based help convention that includes only .SYNOPSIS and .PARAMETER sections. The .DESCRIPTION, .INPUTS, and .OUTPUTS sections are intentionally omitted, even though functions have [OutputType()] attributes. This is consistent across all existing DSC resources: MSFT_UpdateServicesServer, MSFT_UpdateServicesCleanup, and MSFT_UpdateServicesApprovalRule.
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-08-16T13:22:15.230Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:78-93
Timestamp: 2025-08-16T13:22:15.230Z
Learning: In PowerShell unit tests for parameter validation in SqlServerDsc, accessing parameter attributes directly like `$cmd.Parameters['ParameterName'].Attributes.Mandatory` works correctly because PowerShell automatically iterates through the array and returns the property values. Additional filtering to ParameterAttribute is not necessary when the parameter structure is known and controlled.
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2025-11-27T17:58:20.404Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-11-27T17:58:20.404Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : DSC class-based resources must implement required methods: `Get()`, `Test()`, `Set()`, `GetCurrentState()`, and `Modify()` following the specified pattern
Applied to files:
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to azure-pipelines.yml : Integration test script files must be added to a group within the test stage in ./azure-pipelines.yml based on required dependencies
Applied to files:
azure-pipelines.yml
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
Repo: dsccommunity/ActiveDirectoryDsc PR: 741
File: azure-pipelines.yml:104-104
Timestamp: 2025-08-10T15:11:52.897Z
Learning: In the ActiveDirectoryDsc project, HQRM (High Quality Resource Module) tests must run in PowerShell 5 (Windows PowerShell) using `pwsh: false` in the Azure Pipelines configuration, while unit tests can run in PowerShell 7 (PowerShell Core) with `pwsh: true`. This differentiation is intentional due to HQRM's specific requirements and dependencies on Windows PowerShell.
Applied to files:
azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Run QA tests using `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
Applied to files:
azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use `Get-ComputerName` for computer names in CI environments within integration tests
Applied to files:
azure-pipelines.yml
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Classes/*.[Tt]ests.ps1 : Class resources: `tests/Unit/Classes/{Name}.Tests.ps1`
Applied to files:
azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Run tests with coverage using `Invoke-PesterJob -Path '{tests filepath}' -EnableSourceLineMapping -FilterCodeCoverageResult '{pattern}'`
Applied to files:
azure-pipelines.yml
⏰ 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: PSScriptAnalyzer
🔇 Additional comments (4)
tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1 (1)
1-298: Well-structured unit tests with good coverage.The unit test file follows the required setup pattern, includes parameter set validation, and covers key scenarios including:
- Standard service account setting
- Built-in account handling with
-UseBuiltInAccount-PassThru,-Force, and-WhatIfbehaviors- Error handling for CIM method failures
- URL reservation warning with
-SuppressUrlReservationWarning-RestartServiceintegration withRestart-SqlDscRSServicetests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1 (1)
70-110: Good integration test structure with proper connection handling.The test correctly:
- Validates the expected service account is set before proceeding
- Uses
Connect-SqlDscDatabaseEnginewith properDisconnect-SqlDscDatabaseEngineinfinallyblock- Uses
-ForceonRestart-SqlDscRSServiceto avoid prompts- Uses
-ErrorAction 'Stop'for immediate failure surfacingazure-pipelines.yml (2)
151-179: HQRM job correctly configured with Windows PowerShell.The new
Test_HQRMjob correctly usespwsh: false(line 172) as required for HQRM tests that need Windows PowerShell due to DSC-related dependencies.
576-581: Group 6 service account integration tests added correctly.The new service account tests are properly sequenced after Group 5 (Post-initialization) and before Group 8 in both the Reporting Services and BI Report Server stages. The test execution order ensures:
- Service account is changed (
Set-SqlDscRSServiceAccount)- Service account is verified (
Get-SqlDscRSServiceAccount)- Database rights are granted (
Post.DatabaseRights.RS)- URL reservations are recreated (
Post.UrlReservationRecreate.RS)- Final validation (
Post.ServiceAccountChange.RS)Note: Group 7 comment appears to be skipped — the pipeline jumps from Group 6 (lines 576-581) directly to Group 8 (line 582). This is likely intentional if there's no Group 7 for RS tests.
Also applies to: 667-672
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
…ual configuration values
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
🤖 Fix all issues with AI agents
In @tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1:
- Around line 78-99: Remove the script block and the Should -Not -Throw
assertion: call Invoke-SqlDscQuery directly with the existing
$invokeSqlDscQueryParameters hashtable (i.e., Invoke-SqlDscQuery
@invokeSqlDscQueryParameters) instead of `{ Invoke-SqlDscQuery
@invokeSqlDscQueryParameters } | Should -Not -Throw`; this lets any exception
surface naturally and satisfies the Pester guideline against using Should -Not
-Throw.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (7)
**/*.[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 insideDescribeblocks
Assertions only inItblocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
InsideItblocks, assign unused return objects to$null(unless part of pipeline)
Tested entity must be called from within theItblocks
Keep results and assertions in sameItblock
Avoid try-catch-finally for cleanup, useAfterAllorAfterEach
Avoid unnecessary remove/recreate cycles
OneDescribeblock per file matching the tested entity name
Contextdescriptions start with 'When'
Itdescriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
Public commands: Never useInModuleScope(unless retrieving localized strings or creating an object using an internal class)
Private functions/class resources: Always useInModuleScope
Each class method = separateContextblock
Each scenario = separateContextblock
Use nestedContextblocks for complex scenarios
Mocking inBeforeAll(BeforeEachonly when required)
Setup/teardown inBeforeAll,BeforeEach/AfterAll,AfterEachclose to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase:Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach
Use-BeTrue/-BeFalsenever-Be $true/-Be $false
Never useAssert-MockCalled, useShould -Invokeinstead
NoShould -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 useMockinsideInModuleScope-block
Never useparam()inside-MockWithscriptblock...
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.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 or creating an object using an internal class)- 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 usage- Spacing between blocks, arrange, act, and assert for readability
Syntax 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, `...
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Integration tests for commands should be located in
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Location for command integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.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: Integration tests must use real environment only - no mocking allowed
Integration tests must cover all scenarios and code paths
UseGet-ComputerNamefor computer names in CI environments within integration tests
Avoid usingExpectedMessageparameter forShould -Throwassertions in integration tests
Call commands with-Forceparameter where applicable in integration tests to avoid prompting
Use-ErrorAction 'Stop'on commands in integration tests so failures surface immediately
Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.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 -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
**/tests/Integration/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Integration/**/*.ps1: Integration tests must useConnect-SqlDscDatabaseEnginefor SQL Server DB session with correct CI credentials
Integration tests must useDisconnect-SqlDscDatabaseEngineafterConnect-SqlDscDatabaseEngine
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.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- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.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/Post.DatabaseRights.RS.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 as inline code with a 1‑line description...
Files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
🧠 Learnings (22)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for command integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for commands should be located in `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact Pester test setup block with `BeforeDiscovery`, `BeforeAll`, and `AfterAll` blocks before `Describe` in unit tests, including `DscResource.Test` module import and PSDefaultParameterValues configuration
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : No `Should -Not -Throw` - invoke commands directly
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using `ExpectedMessage` parameter for `Should -Throw` assertions in integration tests
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Assert-MockCalled`, use `Should -Invoke` instead
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Follow PowerShell style and test guideline instructions strictly
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use `-ErrorAction 'Stop'` on commands in integration tests so failures surface immediately
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-08-17T10:48:15.384Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: source/suffix.ps1:24-24
Timestamp: 2025-08-17T10:48:15.384Z
Learning: In source/suffix.ps1, the Write-Verbose message in the catch block for Import-SqlDscPreferredModule does not need localization because the exception message from Import-SqlDscPreferredModule is already localized by that command, making it an edge case exception to the localization guidelines.
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : `It` descriptions start with 'Should', must not contain 'when'
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.759Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.759Z
Learning: Integration tests for MOF-based DSC resources (located in source/DSCResources/**) should use the Initialize-TestEnvironment pattern with -ResourceType 'Mof', not the BeforeDiscovery/BeforeAll pattern. The BeforeDiscovery/BeforeAll pattern is for class-based resources only.
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define `-ForEach` variables in `BeforeDiscovery` (close to usage)
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-10-11T08:18:26.062Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:18:26.062Z
Learning: In unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), when DscResource.Test module dependency is not found during BeforeDiscovery setup, the error message should instruct users to run ".\build.ps1 -Tasks noop" (not "build") because the noop task is designed for quick test environment setup. The build task is more extensive and unnecessary when tests run in a separate process, as the module should already be built before running tests.
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mocking in `BeforeAll` (`BeforeEach` only when required)
Applied to files:
tests/Integration/Commands/Post.DatabaseRights.RS.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: PSScriptAnalyzer
🔇 Additional comments (5)
tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1 (5)
1-2: LGTM!The SuppressMessageAttribute and param block follow the required integration test setup pattern.
4-24: LGTM!The BeforeDiscovery block correctly implements the required setup pattern for integration tests, including proper module dependency resolution and error handling.
26-34: LGTM!The BeforeAll block correctly loads the required modules and follows the integration test pattern. The comment appropriately explains why
-Forceis omitted from the module import.
36-46: LGTM!The comment block provides clear context about the test's purpose and its place in the test execution sequence.
47-76: Well-structured integration test with proper cleanup.The test correctly:
- Uses appropriate integration tags for different SQL Server and Power BI environments
- Conditionally sets instance name based on CI category
- Retrieves RS configuration and extracts necessary values
- Generates and validates database rights script
- Restarts RS service with
-Forceto apply changes- Uses proper connection management with
Connect-SqlDscDatabaseEngineandDisconnect-SqlDscDatabaseEnginein try/finally blocks- Applies
-ErrorAction 'Stop'throughout for immediate failure detectionThe sequential test structure appropriately reflects the logical dependencies between script generation, execution, and service restart.
Based on learnings, the test correctly uses
Connect-SqlDscDatabaseEngineandDisconnect-SqlDscDatabaseEnginefor database session management in integration tests.Also applies to: 101-103
…se rights context
…o service account
…r Invoke-SqlDscQuery
…ration tests to depend on Build stage
…orting Services log path retrieval
…vice account change
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: 6
🤖 Fix all issues with AI agents
In @source/Public/Get-SqlDscRSLogPath.ps1:
- Around line 101-121: The code inside the process block of
Get-SqlDscRSLogPath.ps1 is indented with 4 spaces; update the block so its
statements (the checks for $setupConfiguration, the
New-ErrorRecord/$PSCmdlet.ThrowTerminatingError calls, the Write-Verbose call,
and the return $setupConfiguration.ErrorDumpDirectory) use 8-space indentation
to match the surrounding process block style and lines 92-99.
In @tests/Integration/Commands/Get-SqlDscRSLogPath.Integration.Tests.ps1:
- Around line 32-86: Tests hard-code absolute SSRS/PBIRS log paths which are
brittle; update assertions in the Get-SqlDscRSLogPath tests to be resilient by
removing the literal equality checks and instead assert $result/$logPath is not
null or empty, Test-Path -Path $result is true, that the returned path ends with
'\LogFiles' (string endswith check), and that Get-ChildItem -Path $logPath
-Filter '*.log' returns non-empty $logFiles; apply these changes for both
InstanceName 'SSRS' and 'PBIRS' cases and in the pipeline tests that call
Get-SqlDscRSConfiguration | Get-SqlDscRSLogPath so the tests only verify
existence, expected suffix, and presence of *.log files rather than exact
installation roots.
In @tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1:
- Around line 47-68: Remove or redact the service account when logging in the
BeforeAll block: do not include $script:serviceAccount in the Write-Verbose
message generated by Write-Verbose, or replace it with a masked value (e.g.,
"<redacted>" or last 4 chars only) before logging; update the Write-Verbose call
in the Describe 'Post.DatabaseRights.RS' BeforeAll (where $script:instanceName,
$script:databaseName and $script:serviceAccount are referenced) so only
non-sensitive info is output while $script:serviceAccount is omitted or masked.
- Around line 70-120: The test has a cross-It dependency on
$script:databaseRightsScript (generated by the It using
Request-SqlDscRSDatabaseRightsScript and consumed by the later It that calls
Invoke-SqlDscQuery), which makes the suite flaky; fix by either (A) moving the
Request-SqlDscRSDatabaseRightsScript call and
Connect-SqlDscDatabaseEngine/Disconnect-SqlDscDatabaseEngine into the same It
that executes the script so generation and execution are atomic, or (B) generate
the script once in a BeforeAll block (assigning its output to
$script:databaseRightsScript) and keep only assertions/execution in the
individual Its; while doing this replace hard-coded 'localhost' with
Get-ComputerName for ServerName/Connect-SqlDscDatabaseEngine parameters and
ensure unused cmdlet outputs are explicitly assigned to $null (e.g., results of
Restart-SqlDscRSService or New-SqlDscLogin) to match intent.
In @tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1:
- Around line 47-65: The test is currently writing the Reporting Services
service account ($script:serviceAccount) to verbose output; remove or redact the
sensitive identifier in the Write-Verbose call inside the BeforeAll block by
changing the message to only include non-sensitive info (e.g., "Instance:
$script:instanceName") or a masked value, and keep obtaining
$script:serviceAccount from Get-SqlDscRSConfiguration for test use without
printing it; update the Write-Verbose invocation accordingly and ensure no other
logging in this scope outputs $script:serviceAccount.
🧹 Nitpick comments (4)
source/en-US/SqlServerDsc.strings.psd1 (1)
771-777: Consider shortening/splitting the very long..._UrlReservationWarningmessage.
Embedding a full command line makes the localized string very long (and potentially >120 chars), and harder to translate/maintain. Consider: (1) keep the warning short + (2) emit a follow-upWrite-Informationwith the example command (still localized), or point to docs/examples.Also applies to: 814-826
tests/Integration/Commands/Get-SqlDscRSLogPath.Integration.Tests.ps1 (1)
42-49: Prefer-ErrorAction 'Stop'forGet-ChildItemin integration tests.
UsingSilentlyContinuecan hide real failures (ACL/IO issues) and turns them into a generic assertion failure.Also applies to: 70-77
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1 (1)
110-159: DiagnosticItblock lacks assertions.This
Itblock outputs diagnostic information but contains noShouldassertions. While useful for troubleshooting, anItblock without assertions will always pass, which may mask underlying issues or create confusion in test results.Consider either:
- Adding a simple assertion (e.g.,
$true | Should -BeTrue) to make the intent explicit- Moving diagnostic output to a
BeforeAll/AfterAllblock if it's purely for logging♻️ Suggested minimal assertion
It 'Should output diagnostic information for troubleshooting' { # Get RS log path $logPath = $script:configuration | Get-SqlDscRSLogPath -ErrorAction 'Stop' + + # This test outputs diagnostic information for troubleshooting + $logPath | Should -Not -BeNullOrEmpty -Because 'the log path should be retrievable for diagnostics' Write-Verbose -Message "Reporting Services log path: $logPath" -Verbosetests/Integration/Commands/Set-SqlDscRSServiceAccount.Integration.Tests.ps1 (1)
41-167: Significant code duplication across Context blocks.Four Context blocks contain nearly identical code, differing only in the instance name (
SSRSvsPBIRS) and tags. Consider using data-driven tests with-ForEachto reduce duplication and improve maintainability.♻️ Suggested refactor using -ForEach
BeforeDiscovery { # ... existing dependency resolution ... $script:testCases = @( @{ Tag = 'Integration_SQL2017_RS' InstanceName = 'SSRS' Description = 'SQL Server Reporting Services (SQL 2017)' } @{ Tag = 'Integration_SQL2019_RS' InstanceName = 'SSRS' Description = 'SQL Server Reporting Services (SQL 2019)' } @{ Tag = 'Integration_SQL2022_RS' InstanceName = 'SSRS' Description = 'SQL Server Reporting Services (SQL 2022)' } @{ Tag = 'Integration_PowerBI' InstanceName = 'PBIRS' Description = 'Power BI Report Server' } ) } Describe 'Set-SqlDscRSServiceAccount' { Context 'When setting service account for <Description>' -Tag @($Tag) -ForEach $script:testCases { BeforeAll { $computerName = Get-ComputerName $script:serviceAccountName = '{0}\svc-RS' -f $computerName $script:serviceAccountPassword = ConvertTo-SecureString -String 'yig-C^Equ3' -AsPlainText -Force $script:serviceAccountCredential = [System.Management.Automation.PSCredential]::new($script:serviceAccountName, $script:serviceAccountPassword) $script:configuration = Get-SqlDscRSConfiguration -InstanceName $InstanceName -ErrorAction 'Stop' $script:originalServiceAccount = $script:configuration | Get-SqlDscRSServiceAccount -ErrorAction 'Stop' } It 'Should have the original service account set' { $script:originalServiceAccount | Should -Not -BeNullOrEmpty Write-Verbose -Message "Original service account: $script:originalServiceAccount" -Verbose } It 'Should change the service account to svc-RS' { $script:configuration | Set-SqlDscRSServiceAccount -Credential $script:serviceAccountCredential -RestartService -SuppressUrlReservationWarning -Force -ErrorAction 'Stop' } It 'Should have the new service account set after the change' { $configuration = Get-SqlDscRSConfiguration -InstanceName $InstanceName -ErrorAction 'Stop' $result = $configuration | Get-SqlDscRSServiceAccount -ErrorAction 'Stop' $result | Should -BeExactly $script:serviceAccountName Write-Verbose -Message "New service account after change: $result" -Verbose } } }
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
…mat for remote connections and add corresponding tests
…r events and unique provider names from the Application log
…ons with integration and unit tests
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: 8
🤖 Fix all issues with AI agents
In @CHANGELOG.md:
- Around line 271-280: The "Changed" section lists three bullets: details about
Set-SqlDscRSUrlReservation’s new Recreate parameter set and a separate
"Prerequisites Integration Tests" CI detail; consolidate to at most two bullets
by merging the Recreate description into a single concise bullet for
Set-SqlDscRSUrlReservation (mention the new Recreate parameter set and
RecreateExisting behavior and that it omits Application/UrlString) and either
fold the "svc-RS local Windows user" note into an existing test-related bullet
or remove it as CI-only; update the bullets referencing
Set-SqlDscRSUrlReservation, Recreate, RecreateExisting, and svc-RS accordingly
so the changelog follows the ≤2-items guideline.
In @source/Public/New-SqlDscRSEncryptionKey.ps1:
- Around line 123-130: The ThrowTerminatingError call in
New-SqlDscRSEncryptionKey constructs an ErrorRecord via
[System.Management.Automation.ErrorRecord]::new(...); replace that direct
instantiation with the shared New-ErrorRecord helper from DscResource.Common:
build the same message using
$script:localizedData.New_SqlDscRSEncryptionKey_FailedToGenerate -f
$instanceName, $_.Exception.Message and pass the same error id 'NSRSEK0001',
ErrorCategory InvalidOperation, and $Configuration into New-ErrorRecord, then
pass its result to $PSCmdlet.ThrowTerminatingError to match the project pattern.
In @source/Public/Remove-SqlDscRSEncryptionKey.ps1:
- Around line 146-153: Replace the direct creation of an ErrorRecord with the
New-ErrorRecord helper: construct the error using New-ErrorRecord passing the
formatted message
($script:localizedData.Remove_SqlDscRSEncryptionKey_FailedToRemove -f
$instanceName, $_.Exception.Message), the error id 'RRSEK0001', the category
[System.Management.Automation.ErrorCategory]::InvalidOperation and the target
object $Configuration, then pass the returned ErrorRecord into
$PSCmdlet.ThrowTerminatingError instead of using
[System.Management.Automation.ErrorRecord]::new(...).
In
@tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1:
- Around line 48-68: The Write-Verbose call inside the BeforeAll block (the line
using Write-Verbose -Message "Instance: ...") currently includes the -Verbose
switch which forces output; remove the -Verbose parameter so it uses normal
verbosity control (i.e., call Write-Verbose with the same message but without
the -Verbose flag) and, if always-on logging is truly required, replace with an
appropriate Write-Information call elsewhere after validating no sensitive data
is emitted.
In @tests/Unit/Public/New-SqlDscRSEncryptionKey.Tests.ps1:
- Around line 123-137: The mock for Invoke-RsCimMethod throws an exception
mentioning DeleteEncryptionKey(), which mismatches the command under test;
update the Mock -CommandName Invoke-RsCimMethod -MockWith block so the thrown
error message references ReencryptSecureInformation (or a generic
ReencryptSecureInformation() failure) to match New-SqlDscRSEncryptionKey's
expected CIM method call and the test's error expectations.
- Around line 66-169: Replace occurrences of " { ... } | Should -Not -Throw " by
invoking New-SqlDscRSEncryptionKey and assigning its (unused) output to $null;
specifically change the calls in the "When creating new encryption key
successfully" test, the "When creating new encryption key with Force" test, and
the "When passing configuration as parameter" test to use "$null =
$mockCimInstance | New-SqlDscRSEncryptionKey -Confirm:$false" (or with -Force /
-Configuration as appropriate) instead of Should -Not -Throw, so exceptions
still fail the test but unused outputs are explicitly discarded; keep existing
Should -Invoke checks and leave the PassThru and error/WhatIf tests unchanged.
In @tests/Unit/Public/Request-SqlDscRSDatabaseRightsScript.Tests.ps1:
- Around line 178-260: Replace disallowed "Should -Not -Throw" usages by
invoking Request-SqlDscRSDatabaseRightsScript directly and assigning its
(unused) output to $null (e.g. $null = $mockCimInstance |
Request-SqlDscRSDatabaseRightsScript -DatabaseName ... -UserName ... -IsRemote [
-UseSqlAuthentication ]) and keep the subsequent Invoke-RsCimMethod assertions;
additionally, for the invalid-username tests (those that currently assert a
throw) add explicit negative assertions that Invoke-RsCimMethod was not called
(use Should -Not -Invoke -CommandName Invoke-RsCimMethod with a ParameterFilter
matching MethodName 'GenerateDatabaseRightsScript') to prove validation
short-circuits.
🧹 Nitpick comments (9)
source/Public/Remove-SqlDscRSEncryptionKey.ps1 (2)
83-83: Consider more specific OutputType declaration.The
[OutputType([System.Object])]is generic. Since the function conditionally returns the Configuration object (only when-PassThruis specified), consider using a more specific type like[Microsoft.Management.Infrastructure.CimInstance]or documenting that the return is optional.♻️ Suggested refinement
- [OutputType([System.Object])] + [OutputType([Microsoft.Management.Infrastructure.CimInstance])]
105-108: Verify Force parameter pattern implementation.The condition
-and -not $Confirmdoesn't check whether the user explicitly passed-Confirm. This could suppress confirmation even when the user explicitly requested it with-Confirm:$true.♻️ Recommended pattern from coding guidelines
- if ($Force.IsPresent -and -not $Confirm) + if ($Force.IsPresent -and -not $PSBoundParameters.ContainsKey('Confirm')) { $ConfirmPreference = 'None' }This ensures that an explicit
-Confirmparameter from the user is respected.tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1 (1)
100-108: Make the “one result per application” assumption explicit.Given you already assert
$resultscount equals unique application count, consider addingShould -HaveCount 1for$siteResultbefore checking.Accessible/.StatusCodeto avoid array-shape surprises.tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1 (3)
76-83: RemoveShould -Not -Throwwrapper and invoke command directly.Per coding guidelines, avoid
Should -Not -Throw. Instead, invoke the command directly and verify the mock invocation separately. This pattern is repeated in multiple tests.♻️ Suggested refactor
It 'Should remove encrypted content without errors' { - { $mockCimInstance | Remove-SqlDscRSEncryptionKey -Confirm:$false } | Should -Not -Throw + $null = $mockCimInstance | Remove-SqlDscRSEncryptionKey -Confirm:$false Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter { $MethodName -eq 'DeleteEncryptionKey' -and $Arguments.InstallationID -eq 'Test-Installation-ID' } -Exactly -Times 1 }
120-124: RemoveShould -Not -Throwwrapper.Same issue as above — invoke the command directly.
♻️ Suggested refactor
It 'Should remove encrypted content without confirmation' { - { $mockCimInstance | Remove-SqlDscRSEncryptionKey -Force } | Should -Not -Throw + $null = $mockCimInstance | Remove-SqlDscRSEncryptionKey -Force Should -Invoke -CommandName Invoke-RsCimMethod -Exactly -Times 1 }
171-175: RemoveShould -Not -Throwwrapper.Same issue — invoke the command directly per guidelines.
♻️ Suggested refactor
It 'Should remove encrypted content' { - { Remove-SqlDscRSEncryptionKey -Configuration $mockCimInstance -Confirm:$false } | Should -Not -Throw + $null = Remove-SqlDscRSEncryptionKey -Configuration $mockCimInstance -Confirm:$false Should -Invoke -CommandName Invoke-RsCimMethod -Exactly -Times 1 }CHANGELOG.md (3)
10-14: Changelog entry is a bit long; consider tightening + adding an issue link (if one exists).
This is readable, but it’s more verbose than most entries in this file. Also, if there’s a tracking issue, please add it using the required format.Proposed tighter wording
-- Added public command `Get-SqlDscRSLogPath` to get the log file folder path - for SQL Server Reporting Services or Power BI Report Server. Returns the - ErrorDumpDirectory from the instance's setup configuration, which can be - used with `Get-ChildItem` and `Get-Content` to access service logs, portal - logs, and memory dumps. +- Added public command `Get-SqlDscRSLogPath` to retrieve the log path for SQL Server + Reporting Services or Power BI Report Server (from the instance setup configuration).
197-201: Add an issue reference (if available) and keep entry brief.
Good coverage of what was added, but consider shortening to “service-account management” and (if you have one) include the issue link in the required format.Example wording
-- Added public commands `Get-SqlDscRSServiceAccount` and - `Set-SqlDscRSServiceAccount` to get and set the Windows service account for - SQL Server Reporting Services or Power BI Report Server. `Set-SqlDscRSServiceAccount` - wraps the `SetWindowsServiceIdentity` CIM method and supports updating encryption - key backups. +- Added public commands `Get-SqlDscRSServiceAccount` and `Set-SqlDscRSServiceAccount` + for managing the Windows service account for SQL Server Reporting Services or + Power BI Report Server.
216-219: Avoid time-estimates in CHANGELOG; keep it to the behavioral change.
The “~15 minutes” detail is likely to age poorly / be environment-specific.Suggested tweak
- SqlServerDsc - Split the `Test_HQRM` pipeline job into two parallel jobs (`Test_QA` and - `Test_HQRM`) to reduce overall pipeline execution time by approximately - 15 minutes. + `Test_HQRM`).
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
Show resolved
Hide resolved
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
…abaseRightsScript function
…ation during removal
…ng for deleting encrypted information
…oval and error handling of encrypted information
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 (4)
source/Public/Remove-SqlDscRSEncryptionKey.ps1 (2)
82-101: AlignConfigurationtype +[OutputType()]with the contract (and/or validate required properties).
Right now the help says “CimInstance” and output is “CimInstance (PassThru)”, but the function is typed/output asObjectand then immediately assumesInstanceName/InstallationIDmembers exist. This will fail late with non-obvious errors if a wrong object is passed.Proposed direction (pick one)
Option A (stricter, clearer contract): accept CimInstance + output CimInstance
- [OutputType([System.Object])] + [OutputType([Microsoft.Management.Infrastructure.CimInstance])] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] - [System.Object] + [Microsoft.Management.Infrastructure.CimInstance] $Configuration,Option B (keep Object for testability): add explicit validation before member access
- $instanceName = $Configuration.InstanceName + if ($null -eq $Configuration.InstanceName -or $null -eq $Configuration.InstallationID) + { + $PSCmdlet.ThrowTerminatingError( + [System.Management.Automation.ErrorRecord]::new( + 'Configuration must contain InstanceName and InstallationID.', + 'RRSEK0003', + [System.Management.Automation.ErrorCategory]::InvalidData, + $Configuration + ) + ) + } + + $instanceName = $Configuration.InstanceNameAlso applies to: 110-111, 171-174
134-142: Replace directErrorRecordconstructor withNew-ErrorRecordandNew-InvalidOperationExceptionhelpers.Both locations (lines 134-142 and 159-167) should use the standardized error handling pattern consistent with other commands in the repository:
$errorMessage = $script:localizedData.Remove_SqlDscRSEncryptionKey_FailedToRemove -f $instanceName, $_.Exception.Message $errorRecord = New-ErrorRecord -Exception (New-InvalidOperationException -Message $errorMessage -ErrorRecord $_ -PassThru) -ErrorId 'RRSEK0001' -ErrorCategory 'InvalidOperation' -TargetObject $Configuration $PSCmdlet.ThrowTerminatingError($errorRecord)Using
New-InvalidOperationExceptionwith-ErrorRecord $_preserves the original exception as an inner exception for better debugging, andNew-ErrorRecordis the standardized helper from DscResource.Common required by repository guidelines.tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1 (2)
218-235: Avoid try/catch in the “called before failing” test; assert throw + invocation in one go.
You can make this both simpler and guideline-aligned by asserting the throw and the prior invocation in the sameItwithout swallowing exceptions.Possible rewrite
- It 'Should have called DeleteEncryptionKey before failing' { - try - { - $mockCimInstance | Remove-SqlDscRSEncryptionKey -IncludeEncryptedInformation -Confirm:$false - } - catch - { - # Expected to throw - } + It 'Should have called DeleteEncryptionKey before failing' { + { $mockCimInstance | Remove-SqlDscRSEncryptionKey -IncludeEncryptedInformation -Confirm:$false } | + Should -Throw -ErrorId 'RRSEK0002,Remove-SqlDscRSEncryptionKey' Should -Invoke -CommandName Invoke-RsCimMethod -ParameterFilter { $MethodName -eq 'DeleteEncryptionKey' } -Exactly -Times 1 }
38-44: Make env-var cleanup tolerant.
Remove-Item env:SqlServerDscCIcan throw if the variable is already unset; consider-ErrorAction SilentlyContinueto keep teardown resilient.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
source/Public/Remove-SqlDscRSEncryptionKey.ps1source/en-US/SqlServerDsc.strings.psd1tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (13)
source/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)
source/**/*.ps1: Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages in PowerShell scripts
Use localized string keys from $script:localizedData, not hardcoded strings, in diagnostic messages
Reference localized strings using the syntax: Write-Verbose -Message ($script:localizedData.KeyName -f $value1)Localize all strings using string keys; remove any orphaned string keys
Files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
⚙️ CodeRabbit configuration file
source/**/*.ps1: # Localization GuidelinesRequirements
- Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
- Use localized string keys, not hardcoded strings
- Assume
$script:localizedDatais availableString Files
- Commands/functions:
source/en-US/{MyModuleName}.strings.psd1- Class resources:
source/en-US/{ResourceClassName}.strings.psd1Key Naming Patterns
- Format:
Verb_FunctionName_Action(underscore separators), e.g.Get_Database_ConnectingToDatabaseString Format
ConvertFrom-StringData @' KeyName = Message with {0} placeholder. (PREFIX0001) '@String IDs
- Format:
(PREFIX####)- PREFIX: First letter of each word in class or function name (SqlSetup → SS, Get-SqlDscDatabase → GSDD)
- Number: Sequential from 0001
Usage
Write-Verbose -Message ($script:localizedData.KeyName -f $value1)
Files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
source/Public/*.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Public commands should be located in
source/Public/{CommandName}.ps1
Files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1source/en-US/SqlServerDsc.strings.psd1
**/Public/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Public commands must follow the naming format
{Verb}-SqlDsc{Noun}
Files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1tests/Unit/Public/Remove-SqlDscRSEncryptionKey.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- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.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:
source/Public/Remove-SqlDscRSEncryptionKey.ps1tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1source/en-US/SqlServerDsc.strings.psd1
{**/*.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 as inline code with a 1‑line description...
Files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1source/en-US/SqlServerDsc.strings.psd1
**/*.[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 insideDescribeblocks
Assertions only inItblocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
InsideItblocks, assign unused return objects to$null(unless part of pipeline)
Tested entity must be called from within theItblocks
Keep results and assertions in sameItblock
Avoid try-catch-finally for cleanup, useAfterAllorAfterEach
Avoid unnecessary remove/recreate cycles
OneDescribeblock per file matching the tested entity name
Contextdescriptions start with 'When'
Itdescriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
Public commands: Never useInModuleScope(unless retrieving localized strings or creating an object using an internal class)
Private functions/class resources: Always useInModuleScope
Each class method = separateContextblock
Each scenario = separateContextblock
Use nestedContextblocks for complex scenarios
Mocking inBeforeAll(BeforeEachonly when required)
Setup/teardown inBeforeAll,BeforeEach/AfterAll,AfterEachclose to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase:Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach
Use-BeTrue/-BeFalsenever-Be $true/-Be $false
Never useAssert-MockCalled, useShould -Invokeinstead
NoShould -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 useMockinsideInModuleScope-block
Never useparam()inside-MockWithscriptblock...
Files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.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 or creating an object using an internal class)- 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 usage- Spacing between blocks, arrange, act, and assert for readability
Syntax 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, `...
Files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
tests/Unit/Public/*.[Tt]ests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)
Public commands:
tests/Unit/Public/{Name}.Tests.ps1
Files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
tests/Unit/**/*.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Unit tests should be located in
tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
Files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.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: Test with localized strings usingInModuleScope -ScriptBlock { $script:localizedData.Key }in Pester unit tests
Mock files using the$TestDrivevariable (path to the test drive) in Pester unit tests
All public commands require parameter set validation tests in unit tests
Use the exact Pester test setup block withBeforeDiscovery,BeforeAll, andAfterAllblocks beforeDescribein unit tests, includingDscResource.Testmodule import and PSDefaultParameterValues configuration
Use parameter set validation test template withGet-CommandandParameterSetsproperty, supporting both single and multiple parameter sets via-ForEacharray in Pester unit tests
Use parameter properties test template withGet-Commandto validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests
Files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.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 -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:ModuleName') ...
Files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
**/tests/Unit/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Unit/**/*.ps1: Unit tests must use SMO stub types from SMO.cs, never mock SMO types
Unit tests must add$env:SqlServerDscCI = $trueinBeforeAllblock and remove inAfterAllblock
Load SMO stub types from SMO.cs in unit test files usingAdd-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"
Files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
source/en-US/*.strings.psd1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)
source/en-US/*.strings.psd1: Store command/function localized strings in source/en-US/{MyModuleName}.strings.psd1 files
Store class resource localized strings in source/en-US/{ResourceClassName}.strings.psd1 files
Use Key Naming Pattern format: Verb_FunctionName_Action with underscore separators (e.g., Get_Database_ConnectingToDatabase)
Format localized strings using ConvertFrom-StringData with placeholder syntax: KeyName = Message with {0} placeholder. (PREFIX0001)
Prefix string IDs with an acronym derived from the first letter of each word in the class or function name (e.g., SqlSetup → SS, Get-SqlDscDatabase → GSDD), followed by sequential numbers starting from 0001
Files:
source/en-US/SqlServerDsc.strings.psd1
**/*.psd1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
Don't use
NestedModulesfor shared commands withoutRootModulein module manifest
Files:
source/en-US/SqlServerDsc.strings.psd1
🧠 Learnings (38)
📚 Learning: 2025-10-12T12:10:48.625Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2303
File: tests/Integration/Commands/PostInstallationConfiguration.Integration.Tests.ps1:127-143
Timestamp: 2025-10-12T12:10:48.625Z
Learning: For the SqlServerDsc module integration tests, ForceEncryption should not be enabled on the SQL Server instance (DSCSQLTEST) because the module needs to test both encrypted and non-encrypted connection scenarios in CI.
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : For state-changing functions, use `SupportsShouldProcess` attribute with `ConfirmImpact` set to 'Low', 'Medium', or 'High' depending on risk
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Avoid `ConvertTo-SecureString -AsPlainText` in production code
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Export functions using the `*-TargetResource` pattern
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : For error handling, use `New-ErrorRecord` instead of `[System.Management.Automation.ErrorRecord]::new(...)`
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : For error handling, use `New-Exception` instead of `[System.Exception]::new(...)`
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use `New-InvalidOperationException` for invalid operation errors instead of `throw` in MOF-based DSC resources
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use `New-InvalidDataException` for invalid data errors instead of `throw` in MOF-based DSC resources
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use `New-ArgumentException` for argument-related errors instead of `throw` in MOF-based DSC resources
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-08-17T18:25:52.891Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: source/Public/New-SqlDscLogin.ps1:218-225
Timestamp: 2025-08-17T18:25:52.891Z
Learning: PowerShell's System.Management.Automation.ErrorRecord constructor accepts a string as the first parameter and automatically converts it to an exception object internally. No need to manually wrap strings in System.Exception when creating ErrorRecord objects in PowerShell.
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use `New-InvalidResultException` for invalid result errors instead of `throw` in MOF-based DSC resources
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Use `Write-Error` for non-terminating errors with `-Message` (localized string), `-Category` (relevant error category), `-ErrorId` (unique ID), and `-TargetObject` (object causing error)
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Use `$PSCmdlet.ThrowTerminatingError()` for terminating errors (except for classes), use relevant error category, in try-catch include exception with localized message
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use `New-NotImplementedException` for not implemented errors instead of `throw` in MOF-based DSC resources
Applied to files:
source/Public/Remove-SqlDscRSEncryptionKey.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact Pester test setup block with `BeforeDiscovery`, `BeforeAll`, and `AfterAll` blocks before `Describe` in unit tests, including `DscResource.Test` module import and PSDefaultParameterValues configuration
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions and classes must have unit tests
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration tests must cover all scenarios and code paths
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Private/*.[Tt]ests.ps1 : Private functions: `tests/Unit/Private/{Name}.Tests.ps1`
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : All public commands require parameter set validation tests in unit tests
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use parameter set validation test template with `Get-Command` and `ParameterSets` property, supporting both single and multiple parameter sets via `-ForEach` array in Pester unit tests
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.759Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.759Z
Learning: Integration tests for MOF-based DSC resources (located in source/DSCResources/**) should use the Initialize-TestEnvironment pattern with -ResourceType 'Mof', not the BeforeDiscovery/BeforeAll pattern. The BeforeDiscovery/BeforeAll pattern is for class-based resources only.
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use `$PSDefaultParameterValues` only for Pester commands (`Describe`, `Context`, `It`, `Mock`, `Should`, `InModuleScope`)
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Applied to files:
tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
📚 Learning: 2025-12-10T20:07:36.848Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2367
File: source/en-US/SqlServerDsc.strings.psd1:489-498
Timestamp: 2025-12-10T20:07:36.848Z
Learning: Do not renumber localization keys to make them sequential when gaps exist in error codes (e.g., RSDD0001 vs RSDD0003). Preserve existing keys. QA tests should already guard against missing or extra localization string keys, so avoid altering the numbering just to achieve contiguity. If modifications touch localization strings, ensure tests reflect the current keys and document any intentional gaps.
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-10-04T21:33:23.022Z
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 85
File: source/en-US/UpdateServicesDsc.strings.psd1:1-2
Timestamp: 2025-10-04T21:33:23.022Z
Learning: In UpdateServicesDsc (and similar DSC modules), the module-level localization file (source/en-US/<ModuleName>.strings.psd1) can be empty when DSC resources have their own localization files in source/DSCResources/<ResourceName>/en-US/DSC_<ResourceName>.strings.psd1. Automated tests verify localization completeness for resources. Don't flag empty module-level localization files as issues when resources have separate localization.
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use localized strings for all messages including Write-Verbose, Write-Error, and other messaging commands
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/en-US/DSC_*.strings.psd1 : In `.strings.psd1` files, use underscores as word separators in localized string key names for multi-word keys
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Import localized strings using `Get-LocalizedData` at the module top level
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:58:42.327Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-11-27T17:58:42.327Z
Learning: Applies to source/**/*.ps1 : Use localized string keys from $script:localizedData, not hardcoded strings, in diagnostic messages
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:58:42.327Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-11-27T17:58:42.327Z
Learning: Applies to source/en-US/*.strings.psd1 : Prefix string IDs with an acronym derived from the first letter of each word in the class or function name (e.g., SqlSetup → SS, Get-SqlDscDatabase → GSDD), followed by sequential numbers starting from 0001
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/en-US/DSC_*.strings.psd1 : Name localized strings file as `DSC_<ResourceName>.strings.psd1` in the `en-US` folder
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:58:42.327Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-11-27T17:58:42.327Z
Learning: Applies to source/en-US/*.strings.psd1 : Store class resource localized strings in source/en-US/{ResourceClassName}.strings.psd1 files
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:58:42.327Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-localization.instructions.md:0-0
Timestamp: 2025-11-27T17:58:42.327Z
Learning: Applies to source/en-US/*.strings.psd1 : Use Key Naming Pattern format: Verb_FunctionName_Action with underscore separators (e.g., Get_Database_ConnectingToDatabase)
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` verbose messages must start with "Setting the desired state of..."
Applied to files:
source/en-US/SqlServerDsc.strings.psd1
⏰ 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: PSScriptAnalyzer
🔇 Additional comments (1)
source/en-US/SqlServerDsc.strings.psd1 (1)
794-795: This string should not include an error ID suffix. TheInvalidUserNameFormatstring is used withNew-ArgumentException, which throws a .NETArgumentExceptionrather than a PowerShell error record with anErrorId. Error IDs in this codebase are passed to the-ErrorIdparameter ofNew-ErrorRecord, not embedded in localization string values. Strings used only for exceptions (like this one) do not require error ID suffixes.Likely an incorrect or invalid review 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: 2
🤖 Fix all issues with AI agents
In @azure-pipelines.yml:
- Line 572: The test 'Get-SqlDscRSLogPath.Integration.Tests.ps1' is currently
scheduled before initialization and must run after RS is initialized; move its
entry in azure-pipelines.yml from Group 3 to Group 4 (or any later group) so it
runs after 'Initialize-SqlDscRS.Integration.Tests.ps1' and thus after log files
are created; update the group ordering where the test filename appears to place
it in the same or a subsequent group as the initializer.
In @tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1:
- Around line 64-66: The TODO comment incorrectly references
'Integration_SQL2019_RS' while the -Tag array on the Describe block already
includes that tag; change the TODO to reference the missing tag
'Integration_SQL2017_RS' so it matches the skipped SQL Server 2017 tests and
intent. Locate the Describe 'Post.Reinitialize.RS' block and update the comment
text (the TODO above the Describe) to read "Re-add tag 'Integration_SQL2017_RS'
when fixed" so the comment matches the tag set and test coverage.
🧹 Nitpick comments (2)
tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1 (1)
63-65: Verify-IncludeEncryptedInformationparameter test coverage.The
-IncludeEncryptedInformationparameter is only used in the SQL Server 2017 context (which is skipped). The SQL 2019, 2022, and PowerBI contexts don't test this parameter variation. Consider adding a test case for this parameter in one of the active contexts to ensure integration coverage.tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1 (1)
129-190: Consider moving diagnostic output outside ofItblock.This
Itblock contains no assertions and exists purely for diagnostic output. While the verbose diagnostic information is valuable for CI troubleshooting, using anItblock without assertions deviates from typical Pester test patterns.Consider moving this diagnostic logic to an
AfterAllblock within the Context, which would still output the information when tests complete but wouldn't appear as a "test" in results.♻️ Suggested refactor
- It 'Should output diagnostic information for troubleshooting' { + AfterAll { # Get RS log path $logPath = $script:configuration | Get-SqlDscRSLogPath -ErrorAction 'Stop' # ... rest of diagnostic output code ... }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
azure-pipelines.ymltests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (8)
**/*.[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 insideDescribeblocks
Assertions only inItblocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
InsideItblocks, assign unused return objects to$null(unless part of pipeline)
Tested entity must be called from within theItblocks
Keep results and assertions in sameItblock
Avoid try-catch-finally for cleanup, useAfterAllorAfterEach
Avoid unnecessary remove/recreate cycles
OneDescribeblock per file matching the tested entity name
Contextdescriptions start with 'When'
Itdescriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
Public commands: Never useInModuleScope(unless retrieving localized strings or creating an object using an internal class)
Private functions/class resources: Always useInModuleScope
Each class method = separateContextblock
Each scenario = separateContextblock
Use nestedContextblocks for complex scenarios
Mocking inBeforeAll(BeforeEachonly when required)
Setup/teardown inBeforeAll,BeforeEach/AfterAll,AfterEachclose to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase:Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach
Use-BeTrue/-BeFalsenever-Be $true/-Be $false
Never useAssert-MockCalled, useShould -Invokeinstead
NoShould -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 useMockinsideInModuleScope-block
Never useparam()inside-MockWithscriptblock...
Files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.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 or creating an object using an internal class)- 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 usage- Spacing between blocks, arrange, act, and assert for readability
Syntax 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, `...
Files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)
Integration tests for commands should be located in
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1Location for command integration tests:
tests/Integration/Commands/{CommandName}.Integration.Tests.ps1
Files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}
📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)
**/*.{ps1,psm1,psd1}: Use descriptive names (3+ characters, no abbreviations) for functions, parameters, variables, and classes
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase naming
Variables: Use camelCase naming
Keywords: Use lower-case
Classes: Use PascalCase naming
Include scope for script/global/environment variables:$script:,$global:,$env:
Use 4 spaces for indentation (no tabs)
Use one space around operators:$a = 1 + 2
Use one space between type and variable:[String] $name
Use one space between keyword and parenthesis:if ($condition)
No spaces on empty lines
Limit lines to 120 characters
Place newline before opening brace (except variable assignments)
Place one newline after opening brace
Place two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed:'text'vs"text $variable"
For single-line arrays use:@('one', 'two', 'three')
For multi-line arrays: place each element on separate line with proper indentation
Do not use the unary comma operator (,) in return statements to force an array
For empty hashtables use:@{}
For hashtables: place each property on separate line with proper indentation and use PascalCase for property names
Single-line comments: use# Commentformat (capitalized, on own line)
Multi-line comments: use<# Comment #>format (opening and closing brackets on own line with indented text)
No commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords 4 spaces, text 8 spaces
Include examples in comment-based help for all parameter sets and combinations
INPUTS section in comment-based help: List each pipeline-accepted type as inline code with a 1-line description, repeat keyword for each input type, specifyNone.if there are no inp...
Files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.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: Integration tests must use real environment only - no mocking allowed
Integration tests must cover all scenarios and code paths
UseGet-ComputerNamefor computer names in CI environments within integration tests
Avoid usingExpectedMessageparameter forShould -Throwassertions in integration tests
Call commands with-Forceparameter where applicable in integration tests to avoid prompting
Use-ErrorAction 'Stop'on commands in integration tests so failures surface immediately
Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.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 -ErrorAction 'Stop' }
Files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
**/tests/Integration/**/*.ps1
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
**/tests/Integration/**/*.ps1: Integration tests must useConnect-SqlDscDatabaseEnginefor SQL Server DB session with correct CI credentials
Integration tests must useDisconnect-SqlDscDatabaseEngineafterConnect-SqlDscDatabaseEngine
Files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.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- Classes:
source/Classes/{DependencyGroupNumber}.{ClassName}.ps1- Enums:
source/Enum/{DependencyGroupNumber}.{EnumName}.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/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
{**/*.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 as inline code with a 1‑line description...
Files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
azure-pipelines.yml
📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)
Integration test script files must be added to a group within the test stage in ./azure-pipelines.yml based on required dependencies
Files:
azure-pipelines.yml
🧠 Learnings (47)
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration test files must include the required setup block with SuppressMessageAttribute, BeforeDiscovery block for DscResource.Test module import, and BeforeAll block for module initialization
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Unit/**/*.ps1 : Unit tests must add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for command integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Integration tests must cover all scenarios and code paths
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-11-27T18:00:35.078Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T18:00:35.078Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Integration tests for commands should be located in `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use `Get-ComputerName` for computer names in CI environments within integration tests
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Never output sensitive data/secrets in any output stream
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Inside `$PSCmdlet.ShouldProcess`-block, avoid using `Write-Verbose`
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Avoid `ConvertTo-SecureString -AsPlainText` in production code
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Inside `It` blocks, assign unused return objects to `$null` (unless part of pipeline)
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Keep results and assertions in same `It` block
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Assertions only in `It` blocks
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Tested entity must be called from within the `It` blocks
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use `BeforeEach` and `AfterEach` sparingly
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : PascalCase: `Describe`, `Context`, `It`, `Should`, `BeforeAll`, `BeforeEach`, `AfterAll`, `AfterEach`
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-12-30T15:15:36.079Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:36.079Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact Pester test setup block with `BeforeDiscovery`, `BeforeAll`, and `AfterAll` blocks before `Describe` in unit tests, including `DscResource.Test` module import and PSDefaultParameterValues configuration
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.759Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.759Z
Learning: Integration tests for MOF-based DSC resources (located in source/DSCResources/**) should use the Initialize-TestEnvironment pattern with -ResourceType 'Mof', not the BeforeDiscovery/BeforeAll pattern. The BeforeDiscovery/BeforeAll pattern is for class-based resources only.
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
📚 Learning: 2025-10-11T08:18:26.062Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:18:26.062Z
Learning: In unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), when DscResource.Test module dependency is not found during BeforeDiscovery setup, the error message should instruct users to run ".\build.ps1 -Tasks noop" (not "build") because the noop task is designed for quick test environment setup. The build task is more extensive and unnecessary when tests run in a separate process, as the module should already be built before running tests.
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define `-ForEach` variables in `BeforeDiscovery` (close to usage)
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mocking in `BeforeAll` (`BeforeEach` only when required)
Applied to files:
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
📚 Learning: 2025-10-12T12:10:48.625Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2303
File: tests/Integration/Commands/PostInstallationConfiguration.Integration.Tests.ps1:127-143
Timestamp: 2025-10-12T12:10:48.625Z
Learning: For the SqlServerDsc module integration tests, ForceEncryption should not be enabled on the SQL Server instance (DSCSQLTEST) because the module needs to test both encrypted and non-encrypted connection scenarios in CI.
Applied to files:
tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1azure-pipelines.yml
📚 Learning: 2025-12-30T15:15:25.261Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-12-30T15:15:25.261Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use `-ErrorAction 'Stop'` on commands in integration tests so failures surface immediately
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Use `Write-Verbose` for: High-level execution flow only; User-actionable information
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Avoid `Write-Host` and use `Write-Verbose`, `Write-Information`, etc. instead
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-09-06T19:18:18.857Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 0
File: :0-0
Timestamp: 2025-09-06T19:18:18.857Z
Learning: When a PowerShell command uses PSCmdlet.ShouldProcess and is called with -Verbose, the description message from ShouldProcess is automatically output as a verbose message. Therefore, there is no need to use Write-Verbose before or inside PSCmdlet.ShouldProcess blocks as PSCmdlet.ShouldProcess already provides the required verbose message through its description parameter.
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never test verbose messages, debug messages or parameter binding behavior
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.508Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-11-27T17:59:01.508Z
Learning: Applies to source/DSCResources/**/*.psm1 : Each DSC resource function must include at least one `Write-Verbose` statement
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-08-17T10:48:15.384Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2136
File: source/suffix.ps1:24-24
Timestamp: 2025-08-17T10:48:15.384Z
Learning: In source/suffix.ps1, the Write-Verbose message in the catch block for Import-SqlDscPreferredModule does not need localization because the exception message from Import-SqlDscPreferredModule is already localized by that command, making it an edge case exception to the localization guidelines.
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Don't redefine reserved parameters (Verbose, Debug, etc.)
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Use `Write-Debug` for: Internal diagnostics; Variable values/traces; Developer-focused details
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Use `Write-Warning` for: Non-fatal issues requiring attention; Deprecated functionality usage; Configuration problems that don't block execution
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : For state-changing functions, use `SupportsShouldProcess` attribute with `ConfirmImpact` set to 'Low', 'Medium', or 'High' depending on risk
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Use `Write-Information` for: User-facing status updates; Important operational messages; Non-error state changes
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-12-24T18:09:36.332Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-12-24T18:09:36.332Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Avoid `Write-Output` and use `return` instead
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths
Applied to files:
tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Applies to azure-pipelines.yml : Integration test script files must be added to a group within the test stage in ./azure-pipelines.yml based on required dependencies
Applied to files:
azure-pipelines.yml
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
Repo: dsccommunity/ActiveDirectoryDsc PR: 741
File: azure-pipelines.yml:104-104
Timestamp: 2025-08-10T15:11:52.897Z
Learning: In the ActiveDirectoryDsc project, HQRM (High Quality Resource Module) tests must run in PowerShell 5 (Windows PowerShell) using `pwsh: false` in the Azure Pipelines configuration, while unit tests can run in PowerShell 7 (PowerShell Core) with `pwsh: true`. This differentiation is intentional due to HQRM's specific requirements and dependencies on Windows PowerShell.
Applied to files:
azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Run QA tests using `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
Applied to files:
azure-pipelines.yml
📚 Learning: 2025-11-27T17:59:27.205Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-11-27T17:59:27.205Z
Learning: Applies to tests/Unit/Classes/*.[Tt]ests.ps1 : Class resources: `tests/Unit/Classes/{Name}.Tests.ps1`
Applied to files:
azure-pipelines.yml
📚 Learning: 2026-01-01T11:57:15.298Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2026-01-01T11:57:15.298Z
Learning: Run tests with coverage using `Invoke-PesterJob -Path '{tests filepath}' -EnableSourceLineMapping -FilterCodeCoverageResult '{pattern}'`
Applied to files:
azure-pipelines.yml
⏰ 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: PSScriptAnalyzer
🔇 Additional comments (7)
tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1 (1)
1-97: LGTM!The integration test file follows the required structure with proper setup blocks, module import, and test organization. Tests correctly use
-Forceand-ErrorAction 'Stop'to surface failures immediately. The SQL Server 2017 skip with detailed TODO explanation is well-documented.tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1 (1)
68-96: LGTM!The active integration tests for SQL 2019, SQL 2022, and Power BI follow the correct structure with
-Forceand-ErrorAction 'Stop'. The test organization and tagging are appropriate.tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1 (1)
66-127: LGTM!The test setup correctly determines the RS instance based on CI category using
Test-ContinuousIntegrationTaskCategory, usesGet-ComputerNamefor cross-platform compatibility, and all validation tests have proper assertions with descriptive-Becausemessages.tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1 (1)
86-105: LGTM!The re-initialization test flow is well-structured: reinitialize instance → verify initialization status → restart service. All commands correctly use
-Forceand-ErrorAction 'Stop'per integration test guidelines.azure-pipelines.yml (3)
119-180: LGTM: QA and HQRM test separation.The separation of QA and HQRM tests into distinct jobs improves pipeline organization and visibility. The HQRM job correctly uses
pwsh: falsefor Windows PowerShell execution as required.Based on learnings, HQRM tests must run in PowerShell 5 (Windows PowerShell).
570-585: LGTM: New service account management test scripts properly grouped.The new Group 6 test scripts align with the PR objectives for RS service account management:
- Service account Get/Set operations
- Post-validation for database rights, encryption keys, URL reservations
- Re-initialization and service account change validation
The test ordering is logical: these tests run after RS initialization (Group 5) and before repair operations (Group 8), allowing proper validation of service account changes on an initialized instance.
Based on learnings and coding guidelines, integration test scripts are properly grouped by required dependencies.
Also applies to: 665-681
499-499: This dependency change is correct and should be approved.The RS/BI integration test stages can safely depend only on
Buildrather thanIntegration_Test_Commands_SqlServer. The Prerequisites.RSDB.Integration.Tests.ps1 runs within Group 0 of the RS stage and sets up a self-contained SQL Server RSDB instance for Reporting Services database requirements. This prerequisite has no dependency on the Integration_Test_Commands_SqlServer stage outputs. The test grouping within the RS stage (Groups 0-9) properly reflects required dependencies, allowing safe parallelization between the SQL Server and RS/BI test stages.
tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
…ation tests for SQL Server 2017 compatibility
…erver Reporting Services log files
…eporting Services
Pull Request (PR) description
Get-SqlDscRSServiceAccountandSet-SqlDscRSServiceAccountto get and set the Windows service account forSQL Server Reporting Services or Power BI Report Server.
Set-SqlDscRSServiceAccountwraps the
SetWindowsServiceIdentityCIM method and supports updating encryptionkey backups.
Set-SqlDscRSUrlReservationRecreateExistingto remove and re-add all specified URLreservations even if they already exist. This is useful after changing the
Windows service account, as URL reservations are tied to a specific service
account and must be recreated to use the new account.
svc-RSlocal Windows user for Reporting Services service accountintegration testing.
This Pull Request (PR) fixes the following issues
None.
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