Skip to content

Conversation

@johlju
Copy link
Member

@johlju johlju commented Jan 8, 2026

Pull Request (PR) description

  • 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.
  • Set-SqlDscRSUrlReservation
    • Added parameter RecreateExisting to remove and re-add all specified URL
      reservations 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.
  • Prerequisites Integration Tests
    • Added svc-RS local Windows user for Reporting Services service account
      integration testing.

This Pull Request (PR) fixes the following issues

None.

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@johlju johlju requested a review from a team as a code owner January 8, 2026 10:08
@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Reviewing files that changed from the base of the PR and between 6b0e79f and 4223ca2.

📒 Files selected for processing (14)
  • CHANGELOG.md
  • source/Public/New-SqlDscRSEncryptionKey.ps1
  • source/Public/Remove-SqlDscRSEncryptionKey.ps1
  • source/WikiSource/Change-Report-Server-Service-Account.md
  • source/WikiSource/Setting-up-a-SQL-Server-AlwaysOn-Availability-Groups.md
  • source/WikiSource/Setting-up-a-SQL-Server-Failover-Cluster.md
  • source/WikiSource/Troubleshooting-Report-Server.md
  • tests/Integration/Commands/Get-SqlDscRSLogPath.Integration.Tests.ps1
  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscRSEncryptionKey.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
  • tests/Unit/Public/Request-SqlDscRSDatabaseRightsScript.Tests.ps1
 ______________________________________________________________________________________________________
< What one programmer can do in one month, two programmers can do in two months. - Frederick P. Brooks >
 ------------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

Walkthrough

Adds 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

Cohort / File(s) Summary
Service-account cmdlets & tests
source/Public/Get-SqlDscRSServiceAccount.ps1, source/Public/Set-SqlDscRSServiceAccount.ps1, tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1, tests/Integration/Commands/Set-SqlDscRSServiceAccount.Integration.Tests.ps1, tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
Added Get/Set cmdlets to read and set RS/PBIRS Windows service account via MSReportServer_ConfigurationSetting (wraps SetWindowsServiceIdentity). Set supports PSCredential, built-in accounts, RestartService, PassThru, Force, ShouldProcess, and emits URL-reservation warnings; includes unit and integration tests.
URL reservation changes & tests
source/Public/Set-SqlDscRSUrlReservation.ps1, tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1, tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
Added -RecreateExisting with new Recreate parameter set (default remains Set). Recreate mode removes and re-adds all existing URL reservations (optionally propagating LCID); updated ShouldProcess messages, examples, and tests (WhatIf/PassThru covered).
Log-path helper & tests
source/Public/Get-SqlDscRSLogPath.ps1, tests/Unit/Public/Get-SqlDscRSLogPath.Tests.ps1, tests/Integration/Commands/Get-SqlDscRSLogPath.Integration.Tests.ps1
New Get-SqlDscRSLogPath returns ErrorDumpDirectory from setup configuration; throws terminating errors when missing; supports pipeline Configuration input; covered by unit and integration tests.
Encryption-key management & tests
source/Public/New-SqlDscRSEncryptionKey.ps1, source/Public/Remove-SqlDscRSEncryptionKey.ps1, tests/Unit/Public/New-SqlDscRSEncryptionKey.Tests.ps1, tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1, tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1, tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
Added New-/Remove-SqlDscRSEncryptionKey to rotate and delete SSRS encryption keys via CIM methods (ShouldProcess/Force/PassThru) with comprehensive unit and integration tests.
DB-rights username validation & tests
source/Public/Request-SqlDscRSDatabaseRightsScript.ps1, tests/Unit/Public/Request-SqlDscRSDatabaseRightsScript.Tests.ps1, tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
Runtime validation enforcing DOMAIN\user format for remote Windows-auth database-rights scenarios; SQL-auth path bypasses validation. Added unit and integration tests exercising valid/invalid formats and invocation flows.
Localization / strings
source/en-US/SqlServerDsc.strings.psd1
Added localized strings for log-paths, service-account flows, URL-reservation recreation, encryption-key operations, and DB-rights validation messages.
CI / Pipeline & changelog
azure-pipelines.yml, CHANGELOG.md
Split QA/HQRM jobs (added Test_QA and Test_HQRM), adjusted artifact downloads and HQRM job placement, broadened integration-stage dependencies, and appended many RS/HQRM-related tests across stages.
Help/docs update
source/Public/Get-SqlDscRSConfiguration.ps1, CHANGELOG.md
Updated help text for Get-SqlDscRSConfiguration to list additional MSReportServer_ConfigurationSetting properties and references; changelog updated.
Integration prerequisites
tests/Integration/Commands/Prerequisites.Integration.Tests.ps1
Added creation/verification of local user svc-RS required by integration tests.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding service account management capabilities for Reporting Services with new commands and parameters.
Description check ✅ Passed The description is directly related to the changeset, detailing the new public commands, parameter additions, and test updates that align with the implemented changes across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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 PtrToStringAuto can 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 $PSDefaultParameterValues for 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 -ForEach to reduce duplication across Context blocks.

The four Context blocks (SQL2017_RS, SQL2019_RS, SQL2022_RS, PowerBI) contain nearly identical logic with only the instance name and tag differing. Using -ForEach with 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.
Copy link

@coderabbitai coderabbitai bot left a 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: Avoid Should -Not -Throw and invoke the command directly

Current pattern:

  • Wraps Set-SqlDscRSUrlReservation in a scriptblock and asserts with Should -Not -Throw, which goes against the Pester/DSC guidelines for tests.
  • Also does not explicitly discard the (unused) return object from Set-SqlDscRSUrlReservation inside the It block.

Refactor to call the command directly and assign the unused result to $null so the test naturally fails if an exception is thrown and aligns with the guidelines. As per coding guidelines, tests should not use Should -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

📥 Commits

Reviewing files that changed from the base of the PR and between 8b8a28e and f161621.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • azure-pipelines.yml
  • source/Public/Set-SqlDscRSUrlReservation.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • tests/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 inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
Tested entity must be called from within the It blocks
Keep results and assertions in same It block
Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
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 Context block
Each scenario = separate Context block
Use nested Context blocks for complex scenarios
Mocking in BeforeAll (BeforeEach only when required)
Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse never -Be $true/-Be $false
Never use Assert-MockCalled, use Should -Invoke instead
No Should -Not -Throw - invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside InModuleScope-block
Never use param() inside -MockWith scriptblock...

Files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core 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 Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions 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 Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
  • Spacing between blocks, arrange, act, and assert for readability

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, `...

Files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • tests/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.ps1

Location 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 # Comment format (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, specify None. if there are no inp...

Files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • source/Public/Set-SqlDscRSUrlReservation.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/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
Use Get-ComputerName for computer names in CI environments within integration tests
Avoid using ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter 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 Guidelines

Requirements

  • 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-ComputerName for computer names in CI
  • Avoid ExpectedMessage for Should -Throw assertions
  • Only run integration tests in CI unless explicitly instructed.
  • Call commands with -Force parameter where applicable (avoids prompting).
  • Use -ErrorAction 'Stop' on commands so failures surface immediately

Required 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 use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials
Integration tests must use Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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.ps1
  • source/Public/Set-SqlDscRSUrlReservation.ps1
  • CHANGELOG.md
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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
  • source/Public/Set-SqlDscRSUrlReservation.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/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 Guidelines

Requirements

  • Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
  • Use localized string keys, not hardcoded strings
  • Assume $script:localizedData is available

String Files

  • Commands/functions: source/en-US/{MyModuleName}.strings.psd1
  • Class resources: source/en-US/{ResourceClassName}.strings.psd1

Key Naming Patterns

  • Format: Verb_FunctionName_Action (underscore separators), e.g. Get_Database_ConnectingToDatabase

String 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.ps1
  • tests/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.md

Always 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)
Disable MD013 rule 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 using inline code in Markdown documentation
Format resource/module/product names using italic in Markdown documentation
Format commands/files/paths using inline code in 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 MD013 rule 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 NestedModules for shared commands without RootModule in 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 using InModuleScope -ScriptBlock { $script:localizedData.Key } in Pester unit tests
Mock files using the $TestDrive variable (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 with BeforeDiscovery, BeforeAll, and AfterAll blocks before Describe in unit tests, including DscResource.Test module import and PSDefaultParameterValues configuration
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
Use parameter properties test template with Get-Command to 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 $TestDrive variable (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 = $true in BeforeAll block and remove in AfterAll block
Load SMO stub types from SMO.cs in unit test files using Add-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.ps1
  • CHANGELOG.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.ps1
  • CHANGELOG.md
  • 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 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
  • 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 : 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.ps1
  • tests/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.ps1
  • 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/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`

Applied to files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • CHANGELOG.md
  • 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/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • 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 : 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.ps1
  • tests/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.md
  • tests/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 correct

The BeforeDiscovery and BeforeAll blocks 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-structured

The comparison logic between $script:urlReservationsBefore and $urlReservationsAfter and the accessibility checks via Test-SqlDscRSAccessible -Detailed cover 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-placed

The “Added” entry for Get-SqlDscRSServiceAccount / Set-SqlDscRSServiceAccount succinctly explains purpose, scope, and key implementation detail (SetWindowsServiceIdentity + encryption key backups) and fits the existing style in the section.


262-271: Set-SqlDscRSUrlReservation Recreate mode and prerequisites entries look good

The “Changed” entries accurately document the new Recreate parameter set, its behavior, and the added svc-RS prerequisite 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_Action format
  • 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 -RecreateExisting cannot be combined with -Application or -UrlString
  • ConfirmImpact = '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 $PSBoundParameters before 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-Debug for diagnostic messages (appropriate for current/desired URL logging)
  • Computes the diff between current and desired URLs using Where-Object with -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, and AfterAll blocks. The CI environment variable is correctly set and removed, and PSDefaultParameterValues are properly configured.


46-81: LGTM!

The parameter set validation tests correctly verify both the Set and Recreate parameter sets, as well as confirming Set is the default. This follows the required template for parameter set validation.


417-546: LGTM!

The remaining test contexts for RecreateExisting mode 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

Copy link
Member Author

@johlju johlju left a 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @johlju).

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (9ce6479) to head (6b0e79f).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##            main   #2402    +/-   ##
======================================
  Coverage     94%     94%            
======================================
  Files        200     205     +5     
  Lines      10455   10570   +115     
======================================
+ Hits        9840    9955   +115     
  Misses       615     615            
Flag Coverage Δ
unit 94% <100%> (+<1%) ⬆️
Files with missing lines Coverage Δ
source/Public/Get-SqlDscRSConfiguration.ps1 100% <ø> (ø)
source/Public/Get-SqlDscRSLogPath.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSServiceAccount.ps1 100% <100%> (ø)
source/Public/New-SqlDscRSEncryptionKey.ps1 100% <100%> (ø)
source/Public/Remove-SqlDscRSEncryptionKey.ps1 100% <100%> (ø)
...ce/Public/Request-SqlDscRSDatabaseRightsScript.ps1 100% <100%> (ø)
source/Public/Set-SqlDscRSServiceAccount.ps1 100% <100%> (ø)
source/Public/Set-SqlDscRSUrlReservation.ps1 100% <100%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a 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: Avoid Should -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 -ForEach array for testing multiple parameter sets. While the current approach with separate It blocks 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

📥 Commits

Reviewing files that changed from the base of the PR and between e7d4cc1 and d84e3ec.

📒 Files selected for processing (4)
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • tests/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 inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
Tested entity must be called from within the It blocks
Keep results and assertions in same It block
Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
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 Context block
Each scenario = separate Context block
Use nested Context blocks for complex scenarios
Mocking in BeforeAll (BeforeEach only when required)
Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse never -Be $true/-Be $false
Never use Assert-MockCalled, use Should -Invoke instead
No Should -Not -Throw - invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside InModuleScope-block
Never use param() inside -MockWith scriptblock...

Files:

  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core 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 Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions 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 Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
  • Spacing between blocks, arrange, act, and assert for readability

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, `...

Files:

  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • tests/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.ps1
  • 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-SqlDscRSUrlReservation.Tests.ps1
  • tests/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 # Comment format (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, specify None. if there are no inp...

Files:

  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • tests/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 using InModuleScope -ScriptBlock { $script:localizedData.Key } in Pester unit tests
Mock files using the $TestDrive variable (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 with BeforeDiscovery, BeforeAll, and AfterAll blocks before Describe in unit tests, including DscResource.Test module import and PSDefaultParameterValues configuration
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
Use parameter properties test template with Get-Command to validate individual parameter attributes (e.g., Mandatory flag) in Pester unit tests

Files:

  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
  • 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 $TestDrive variable (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/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.ps1
  • 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 = $true in BeforeAll block and remove in AfterAll block
Load SMO stub types from SMO.cs in unit test files using Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"

Files:

  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • tests/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.ps1

Location 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
Use Get-ComputerName for computer names in CI environments within integration tests
Avoid using ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter 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 Guidelines

Requirements

  • 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-ComputerName for computer names in CI
  • Avoid ExpectedMessage for Should -Throw assertions
  • Only run integration tests in CI unless explicitly instructed.
  • Call commands with -Force parameter where applicable (avoids prompting).
  • Use -ErrorAction 'Stop' on commands so failures surface immediately

Required 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 use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials
Integration tests must use Disconnect-SqlDscDatabaseEngine after Connect-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.ps1
  • 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 : All public commands require parameter set validation tests in unit tests

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
  • 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-SqlDscRSUrlReservation.Tests.ps1
  • 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 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.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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 : 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.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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 : 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
  • 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-SqlDscRSUrlReservation.Tests.ps1
  • 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-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.ps1
  • 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 : 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.ps1
  • 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} : `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
  • 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/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • tests/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.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSUrlReservation.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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 : 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.ps1
  • 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/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.ps1
  • 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 : All public commands and class-based resources must have integration tests

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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 : 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.ps1
  • 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 : 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.ps1
  • tests/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:

  • BeforeDiscovery block with DscResource.Test module import
  • BeforeAll with $env:SqlServerDscCI = $true (line 29)
  • AfterAll properly removes the environment variable (line 43)
  • $PSDefaultParameterValues correctly configured for Pester commands

46-64: LGTM!

Parameter set validation follows the required template pattern with Get-Command and -ForEach array.


66-95: Good test structure with separated concerns.

The context correctly separates the invocation test from the return value test into distinct It blocks, following good testing practices.


179-181: Good error handling test pattern.

Using Should -Throw -ErrorId to 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:

  • BeforeDiscovery with DscResource.Test module import and fallback
  • BeforeAll imports 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-ComputerName per 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
  • -Because parameters 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 = $true in BeforeAll and proper cleanup in AfterAll.


349-415: Comprehensive RecreateExisting tests.

The new tests thoroughly cover the RecreateExisting parameter set:

  • Multiple applications with proper remove/re-add verification
  • Uses -Scope It on Should -Invoke where multiple It blocks 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)

Copy link

@coderabbitai coderabbitai bot left a 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 test

Functionally this section is accurate, but two minor polish points:

  1. 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 the Set-SqlDscRSUrlReservation bullet (as an extra sub-bullet) to keep this as a single logical change related to RS URL reservations/service accounts.

  2. 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 $null for 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 inside It blocks 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

📥 Commits

Reviewing files that changed from the base of the PR and between d84e3ec and 087eff7.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • azure-pipelines.yml
  • tests/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 inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
Tested entity must be called from within the It blocks
Keep results and assertions in same It block
Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
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 Context block
Each scenario = separate Context block
Use nested Context blocks for complex scenarios
Mocking in BeforeAll (BeforeEach only when required)
Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse never -Be $true/-Be $false
Never use Assert-MockCalled, use Should -Invoke instead
No Should -Not -Throw - invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside InModuleScope-block
Never use param() inside -MockWith scriptblock...

Files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core 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 Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions 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 Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
  • Spacing between blocks, arrange, act, and assert for readability

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock: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.ps1

Location 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 # Comment format (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, specify None. 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
Use Get-ComputerName for computer names in CI environments within integration tests
Avoid using ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter 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 Guidelines

Requirements

  • 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-ComputerName for computer names in CI
  • Avoid ExpectedMessage for Should -Throw assertions
  • Only run integration tests in CI unless explicitly instructed.
  • Call commands with -Force parameter where applicable (avoids prompting).
  • Use -ErrorAction 'Stop' on commands so failures surface immediately

Required 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 use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials
Integration tests must use Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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.ps1
  • CHANGELOG.md
  • azure-pipelines.yml
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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.md

Always 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)
Disable MD013 rule 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 using inline code in Markdown documentation
Format resource/module/product names using italic in Markdown documentation
Format commands/files/paths using inline code in 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 MD013 rule 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.ps1
  • 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 **/*.[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
  • 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/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
  • azure-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.ps1
  • 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 : 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
  • 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 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting

Applied to files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • 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 : Integration tests must cover all scenarios and code paths

Applied to files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • 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/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`

Applied to files:

  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • 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: 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.ps1
  • CHANGELOG.md
  • 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 **/*.[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.ps1
  • CHANGELOG.md
  • azure-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.ps1
  • 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 **/*.[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.md
  • azure-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.md
  • azure-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 clear

The Added entry correctly describes the new Get-SqlDscRSServiceAccount / Set-SqlDscRSServiceAccount commands 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 written

The SqlServerDsc/pipeline bullet is concise, specific about splitting Test_HQRM into Test_QA and Test_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_HQRM to Test_QA accurately 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_HQRM job is correctly configured with pwsh: 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, BeforeDiscovery for DscResource.Test module resolution, and BeforeAll for module import. The comment explaining why -Force is 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 -Because messages provide clear failure context. While the nested loop could potentially be simplified, the current implementation is readable and correct.

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 087eff7 and e8062d9.

📒 Files selected for processing (4)
  • azure-pipelines.yml
  • tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Post.UrlReservationRecreate.RS.Integration.Tests.ps1
  • tests/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 inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
Tested entity must be called from within the It blocks
Keep results and assertions in same It block
Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
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 Context block
Each scenario = separate Context block
Use nested Context blocks for complex scenarios
Mocking in BeforeAll (BeforeEach only when required)
Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse never -Be $true/-Be $false
Never use Assert-MockCalled, use Should -Invoke instead
No Should -Not -Throw - invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside InModuleScope-block
Never use param() inside -MockWith scriptblock...

Files:

  • tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core 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 Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions 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 Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
  • Spacing between blocks, arrange, act, and assert for readability

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, `...

Files:

  • tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
  • tests/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.ps1

Location 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 # Comment format (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, specify None. if there are no inp...

Files:

  • tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
  • tests/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
Use Get-ComputerName for computer names in CI environments within integration tests
Avoid using ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter 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 Guidelines

Requirements

  • 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-ComputerName for computer names in CI
  • Avoid ExpectedMessage for Should -Throw assertions
  • Only run integration tests in CI unless explicitly instructed.
  • Call commands with -Force parameter where applicable (avoids prompting).
  • Use -ErrorAction 'Stop' on commands so failures surface immediately

Required 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 use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials
Integration tests must use Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • azure-pipelines.yml
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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
  • tests/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 using InModuleScope -ScriptBlock { $script:localizedData.Key } in Pester unit tests
Mock files using the $TestDrive variable (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 with BeforeDiscovery, BeforeAll, and AfterAll blocks before Describe in unit tests, including DscResource.Test module import and PSDefaultParameterValues configuration
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
Use parameter properties test template with Get-Command to 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 $TestDrive variable (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 = $true in BeforeAll block and remove in AfterAll block
Load SMO stub types from SMO.cs in unit test files using Add-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.ps1
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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 : 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
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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: 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
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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: 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
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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/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
  • 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 **/*.[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
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • 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 : 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
  • tests/Unit/Public/Set-SqlDscRSServiceAccount.Tests.ps1
  • azure-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.ps1
  • 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/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
  • 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 : Integration tests must cover all scenarios and code paths

Applied to files:

  • tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
  • azure-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.ps1
  • tests/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.ps1
  • 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 : 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.ps1
  • 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 **/*.[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 -WhatIf behaviors
  • Error handling for CIM method failures
  • URL reservation warning with -SuppressUrlReservationWarning
  • -RestartService integration with Restart-SqlDscRSService
tests/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-SqlDscDatabaseEngine with proper Disconnect-SqlDscDatabaseEngine in finally block
  • Uses -Force on Restart-SqlDscRSService to avoid prompts
  • Uses -ErrorAction 'Stop' for immediate failure surfacing
azure-pipelines.yml (2)

151-179: HQRM job correctly configured with Windows PowerShell.

The new Test_HQRM job correctly uses pwsh: 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:

  1. Service account is changed (Set-SqlDscRSServiceAccount)
  2. Service account is verified (Get-SqlDscRSServiceAccount)
  3. Database rights are granted (Post.DatabaseRights.RS)
  4. URL reservations are recreated (Post.UrlReservationRecreate.RS)
  5. 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

Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between e8062d9 and 72ec4ca.

📒 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 inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
Tested entity must be called from within the It blocks
Keep results and assertions in same It block
Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
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 Context block
Each scenario = separate Context block
Use nested Context blocks for complex scenarios
Mocking in BeforeAll (BeforeEach only when required)
Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse never -Be $true/-Be $false
Never use Assert-MockCalled, use Should -Invoke instead
No Should -Not -Throw - invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside InModuleScope-block
Never use param() inside -MockWith scriptblock...

Files:

  • tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core 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 Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions 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 Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
  • Spacing between blocks, arrange, act, and assert for readability

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock: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.ps1

Location 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 # Comment format (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, specify None. 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
Use Get-ComputerName for computer names in CI environments within integration tests
Avoid using ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter 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 Guidelines

Requirements

  • 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-ComputerName for computer names in CI
  • Avoid ExpectedMessage for Should -Throw assertions
  • Only run integration tests in CI unless explicitly instructed.
  • Call commands with -Force parameter where applicable (avoids prompting).
  • Use -ErrorAction 'Stop' on commands so failures surface immediately

Required 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 use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials
Integration tests must use Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Post.DatabaseRights.RS.Integration.Tests.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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 Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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 -Force is 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 -Force to apply changes
  • Uses proper connection management with Connect-SqlDscDatabaseEngine and Disconnect-SqlDscDatabaseEngine in try/finally blocks
  • Applies -ErrorAction 'Stop' throughout for immediate failure detection

The sequential test structure appropriately reflects the logical dependencies between script generation, execution, and service restart.

Based on learnings, the test correctly uses Connect-SqlDscDatabaseEngine and Disconnect-SqlDscDatabaseEngine for database session management in integration tests.

Also applies to: 101-103

Copy link

@coderabbitai coderabbitai bot left a 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 ..._UrlReservationWarning message.
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-up Write-Information with 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' for Get-ChildItem in integration tests.
Using SilentlyContinue can 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: Diagnostic It block lacks assertions.

This It block outputs diagnostic information but contains no Should assertions. While useful for troubleshooting, an It block without assertions will always pass, which may mask underlying issues or create confusion in test results.

Consider either:

  1. Adding a simple assertion (e.g., $true | Should -BeTrue) to make the intent explicit
  2. Moving diagnostic output to a BeforeAll/AfterAll block 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" -Verbose
tests/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 (SSRS vs PBIRS) and tags. Consider using data-driven tests with -ForEach to 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
        }
    }
}

…mat for remote connections and add corresponding tests
Copy link

@coderabbitai coderabbitai bot left a 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 -PassThru is 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 $Confirm doesn'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 -Confirm parameter 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 $results count equals unique application count, consider adding Should -HaveCount 1 for $siteResult before checking .Accessible / .StatusCode to avoid array-shape surprises.

tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1 (3)

76-83: Remove Should -Not -Throw wrapper 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: Remove Should -Not -Throw wrapper.

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: Remove Should -Not -Throw wrapper.

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`).

Copy link

@coderabbitai coderabbitai bot left a 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: Align Configuration type + [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 as Object and then immediately assumes InstanceName / InstallationID members 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.InstanceName

Also applies to: 110-111, 171-174


134-142: Replace direct ErrorRecord constructor with New-ErrorRecord and New-InvalidOperationException helpers.

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-InvalidOperationException with -ErrorRecord $_ preserves the original exception as an inner exception for better debugging, and New-ErrorRecord is 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 same It without 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:SqlServerDscCI can throw if the variable is already unset; consider -ErrorAction SilentlyContinue to keep teardown resilient.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 527ba0e and 7724eb7.

📒 Files selected for processing (3)
  • source/Public/Remove-SqlDscRSEncryptionKey.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/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 Guidelines

Requirements

  • Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
  • Use localized string keys, not hardcoded strings
  • Assume $script:localizedData is available

String Files

  • Commands/functions: source/en-US/{MyModuleName}.strings.psd1
  • Class resources: source/en-US/{ResourceClassName}.strings.psd1

Key Naming Patterns

  • Format: Verb_FunctionName_Action (underscore separators), e.g. Get_Database_ConnectingToDatabase

String 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 # Comment format (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, specify None. if there are no inp...

Files:

  • source/Public/Remove-SqlDscRSEncryptionKey.ps1
  • tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
  • source/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.ps1
  • tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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.ps1
  • tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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.ps1
  • tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1
  • source/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 inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
Tested entity must be called from within the It blocks
Keep results and assertions in same It block
Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
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 Context block
Each scenario = separate Context block
Use nested Context blocks for complex scenarios
Mocking in BeforeAll (BeforeEach only when required)
Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse never -Be $true/-Be $false
Never use Assert-MockCalled, use Should -Invoke instead
No Should -Not -Throw - invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside InModuleScope-block
Never use param() inside -MockWith scriptblock...

Files:

  • tests/Unit/Public/Remove-SqlDscRSEncryptionKey.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core 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 Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions 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 Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
  • Spacing between blocks, arrange, act, and assert for readability

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock: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 using InModuleScope -ScriptBlock { $script:localizedData.Key } in Pester unit tests
Mock files using the $TestDrive variable (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 with BeforeDiscovery, BeforeAll, and AfterAll blocks before Describe in unit tests, including DscResource.Test module import and PSDefaultParameterValues configuration
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
Use parameter properties test template with Get-Command to 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 $TestDrive variable (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 = $true in BeforeAll block and remove in AfterAll block
Load SMO stub types from SMO.cs in unit test files using Add-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 NestedModules for shared commands without RootModule in 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.ps1
  • tests/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. The InvalidUserNameFormat string is used with New-ArgumentException, which throws a .NET ArgumentException rather than a PowerShell error record with an ErrorId. Error IDs in this codebase are passed to the -ErrorId parameter of New-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.

Copy link

@coderabbitai coderabbitai bot left a 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 -IncludeEncryptedInformation parameter test coverage.

The -IncludeEncryptedInformation parameter 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 of It block.

This It block contains no assertions and exists purely for diagnostic output. While the verbose diagnostic information is valuable for CI troubleshooting, using an It block without assertions deviates from typical Pester test patterns.

Consider moving this diagnostic logic to an AfterAll block 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7724eb7 and 6b0e79f.

📒 Files selected for processing (5)
  • azure-pipelines.yml
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/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 inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
Tested entity must be called from within the It blocks
Keep results and assertions in same It block
Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should', must not contain 'when'
Mock variables prefix: 'mock'
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 Context block
Each scenario = separate Context block
Use nested Context blocks for complex scenarios
Mocking in BeforeAll (BeforeEach only when required)
Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
Spacing between blocks, arrange, act, and assert for readability
PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse never -Be $true/-Be $false
Never use Assert-MockCalled, use Should -Invoke instead
No Should -Not -Throw - invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside InModuleScope-block
Never use param() inside -MockWith scriptblock...

Files:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core 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 Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions 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 Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage
  • Spacing between blocks, arrange, act, and assert for readability

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, `...

Files:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/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.ps1

Location for command integration tests: tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Files:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/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 # Comment format (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, specify None. if there are no inp...

Files:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/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
Use Get-ComputerName for computer names in CI environments within integration tests
Avoid using ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter 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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1

⚙️ CodeRabbit configuration file

tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1: # Integration Tests Guidelines

Requirements

  • 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-ComputerName for computer names in CI
  • Avoid ExpectedMessage for Should -Throw assertions
  • Only run integration tests in CI unless explicitly instructed.
  • Call commands with -Force parameter where applicable (avoids prompting).
  • Use -ErrorAction 'Stop' on commands so failures surface immediately

Required 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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/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 use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials
Integration tests must use Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • 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 pwsh session): ./build.ps1 -Tasks noop
  • Build project before running tests: ./build.ps1 -Tasks build
  • Always run tests in new pwsh session: Invoke-Pester -Path @({test paths}) -Output Detailed

File 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.ps1

Requirements

  • 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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • azure-pipelines.yml
{**/*.ps1,**/*.psm1,**/*.psd1}

⚙️ CodeRabbit configuration file

{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell Guidelines

Naming

  • 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.ps1 format (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 array

Hashtables

  • 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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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: 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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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: 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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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: 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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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 **/*.[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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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 : Call commands with `-Force` parameter where applicable in integration tests to avoid prompting

Applied to files:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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/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.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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/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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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 : Integration tests must cover all scenarios and code paths

Applied to files:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • azure-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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/Integration/Commands/New-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • 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:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • azure-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.ps1
  • 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} : Inside `$PSCmdlet.ShouldProcess`-block, avoid using `Write-Verbose`

Applied to files:

  • tests/Integration/Commands/Post.Reinitialize.RS.Integration.Tests.ps1
  • 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 `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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/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.ps1
  • tests/Integration/Commands/Remove-SqlDscRSEncryptionKey.Integration.Tests.ps1
  • tests/Integration/Commands/Post.ServiceAccountChange.RS.Integration.Tests.ps1
  • tests/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.ps1
  • tests/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.ps1
  • tests/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.ps1
  • 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:

  • 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 -Force and -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 -Force and -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, uses Get-ComputerName for cross-platform compatibility, and all validation tests have proper assertions with descriptive -Because messages.

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 -Force and -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: false for 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 Build rather than Integration_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant