Skip to content

Conversation

@johlju
Copy link
Member

@johlju johlju commented Jan 16, 2026

Pull Request (PR) description

  • Added public command Set-SqlDscRSSmtpConfiguration to configure SMTP
    settings for Reporting Services email delivery. Wraps the SetEmailConfiguration
    CIM method.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

Walkthrough

Adds a new public command Set-SqlDscRSSmtpConfiguration to configure Reporting Services SMTP via the SetEmailConfiguration CIM method, standardizes error handling across many RS cmdlets (replacing InvalidOperationException wrapping with generic Exception objects and trimming inline exception details), updates localization strings, and adds unit and integration tests.

Changes

Cohort / File(s) Summary
New SMTP Configuration Feature
source/Public/Set-SqlDscRSSmtpConfiguration.ps1, tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.Tests.ps1, tests/Integration/Commands/Set-SqlDscRSSmtpConfiguration.Integration.Tests.ps1
New Set-SqlDscRSSmtpConfiguration command wrapping SetEmailConfiguration on MSReportServer_ConfigurationSetting. Supports ShouldProcess, -Force, -PassThru; includes parameter validation, error handling (SSRSSC0001), unit tests (mocked CIM), and integration tests.
Error Handling Refactor (many RS cmdlets)
source/Public/*Get-SqlDscRS*.ps1, source/Public/*Add-SqlDscRS*.ps1, source/Public/*Remove-SqlDscRS*.ps1, source/Public/*Set-SqlDscRS*.ps1, source/Public/Initialize-SqlDscRS.ps1, source/Public/New-SqlDscRSEncryptionKey.ps1, source/Public/Request-SqlDscRS*.ps1, source/Public/Restart-SqlDscRSService.ps1, source/Public/Test-SqlDscRSAccessible.ps1
Replaces inline New-InvalidOperationException usage with separate New-Exception objects passed to New-ErrorRecord; removes inclusion of inner exception messages from formatted localized strings; preserves ErrorId/ErrorCategory/ThrowTerminatingError behavior and retains original error record via -ErrorRecord where appropriate.
Localization String Updates
source/en-US/SqlServerDsc.strings.psd1
Removes {1} placeholders (inner exception detail) from many RS-related messages, adds new string group entries for Set-SqlDscRSSmtpConfiguration (ShouldProcess, captions, failure text), and adjusts wording/formatting for several messages.
Pipeline & Test Config
azure-pipelines.yml
Adds the new integration test to multiple integration test groups/stages (Group 7 entries).
Unit Test Adjustments
tests/Unit/Public/Get-SqlDscRSConfiguration.Tests.ps1
Renamed two test descriptions to clarify parameter validation intent (no functional change).
Changelog
CHANGELOG.md
Documents addition of Set-SqlDscRSSmtpConfiguration and notes its wrapping of SetEmailConfiguration.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/Script
    participant Cmd as Set-SqlDscRSSmtpConfiguration
    participant SP as ShouldProcess
    participant CIM as Invoke-RsCimMethod
    participant Config as MSReportServer_ConfigurationSetting
    participant ErrorHandler as Error Handler

    User->>Cmd: Invoke with Configuration, SmtpServer, SenderEmailAddress
    Cmd->>SP: Check ShouldProcess (or -Force)
    alt Confirmed or -Force
        SP-->>Cmd: Proceed
        Cmd->>CIM: Invoke SetEmailConfiguration(SendUsingSMTPServer=1, SMTPServer, SenderEmailAddress)
        CIM->>Config: Execute CIM method
        alt Success
            Config-->>CIM: Return success
            CIM-->>Cmd: Return result
            Cmd-->>User: Return Configuration if -PassThru
        else Failure
            Config-->>CIM: Throw exception
            CIM-->>ErrorHandler: Capture error
            ErrorHandler->>ErrorHandler: Wrap in New-Exception and New-ErrorRecord (SSRSSC0001)
            ErrorHandler-->>Cmd: Terminate with error
            Cmd-->>User: Terminating error
        end
    else Declined
        SP-->>Cmd: Cancel
        Cmd-->>User: No action taken
    end
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 concisely describes the main change: adding a new command Set-SqlDscRSSmtpConfiguration.
Description check ✅ Passed The description is directly related to the changeset, explaining the addition of the new command and its purpose of configuring SMTP settings for Reporting Services.
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.



📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c351834 and ad78585.

📒 Files selected for processing (4)
  • azure-pipelines.yml
  • source/Public/Restart-SqlDscRSService.ps1
  • tests/Integration/Commands/Set-SqlDscRSSmtpConfiguration.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.Tests.ps1
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/Integration/Commands/Set-SqlDscRSSmtpConfiguration.Integration.Tests.ps1
  • source/Public/Restart-SqlDscRSService.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.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 (49)
📓 Common learnings
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2411
File: tests/Integration/Commands/Set-SqlDscRSSmtpConfiguration.Integration.Tests.ps1:26-32
Timestamp: 2026-01-16T13:28:29.138Z
Learning: The requirement to use `Connect-SqlDscDatabaseEngine` and `Disconnect-SqlDscDatabaseEngine` in integration tests only applies when the tests actually interact with or require a SQL Server Database Engine instance. Tests that work with other components (like Reporting Services configuration via CIM methods) without database interaction do not require these commands.
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.
📚 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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.Tests.ps1
📚 Learning: 2026-01-16T13:36:13.522Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2411
File: tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.Tests.ps1:26-35
Timestamp: 2026-01-16T13:36:13.522Z
Learning: In unit test PowerShell scripts (PS1) under tests/Unit, only suggest loading SMO stub types (using Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs") when the tested command/function/class actually uses SMO types. Do not suggest loading SMO stubs for tests that use CIM, WMI, or other APIs.

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.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 `param()` inside Pester blocks when using `-ForEach`

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.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 : `-ForEach` allowed on `Context` and `It` blocks

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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 : Load SMO stub types from SMO.cs in unit test files using `Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"`

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.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/Stubs/SMO.cs : When unit tests test classes or commands containing SMO types, ensure they are properly stubbed in SMO.cs

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.Tests.ps1
📚 Learning: 2025-10-11T08:35:56.141Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2300
File: tests/Unit/DSC_SqlAGDatabase.Tests.ps1:22-22
Timestamp: 2025-10-11T08:35:56.141Z
Learning: In DSC Community projects, when writing error messages for missing DscResource.Test module dependency in unit test files (tests/[Uu]nit/**/*.[Tt]ests.ps1), the policy is: new code should instruct users to run ".\build.ps1 -Tasks noop" for quick test environment setup; existing code using ".\build.ps1 -Tasks build" is acceptable but slower since it also builds the project. The `noop` task is preferred as it assumes the module is already built before running tests, especially when tests run in a separate process.

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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/Unit/Public/Set-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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 : Mock variables prefix: 'mock'

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.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-SqlDscRSSmtpConfiguration.Tests.ps1
  • azure-pipelines.yml
📚 Learning: 2026-01-16T13:28:29.138Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2411
File: tests/Integration/Commands/Set-SqlDscRSSmtpConfiguration.Integration.Tests.ps1:26-32
Timestamp: 2026-01-16T13:28:29.138Z
Learning: The requirement to use `Connect-SqlDscDatabaseEngine` and `Disconnect-SqlDscDatabaseEngine` in integration tests only applies when the tests actually interact with or require a SQL Server Database Engine instance. Tests that work with other components (like Reporting Services configuration via CIM methods) without database interaction do not require these commands.

Applied to files:

  • tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.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: Always prefer SMO over T-SQL for SQL Server interaction

Applied to files:

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

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

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

  • azure-pipelines.yml
📚 Learning: 2026-01-16T13:36:13.522Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2411
File: tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.Tests.ps1:26-35
Timestamp: 2026-01-16T13:36:13.522Z
Learning: Applies to **/tests/Unit/**/*.ps1: Only suggest loading SMO stub types (via `Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"`) in unit test files when the command/function/class being tested actually uses SMO types. Do not suggest loading SMO stubs for commands that use other technologies like CIM, WMI, or other APIs.

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/Integration/Resources/*.Integration.Tests.ps1 : Location for resource integration tests: `tests/Integration/Resources/{ResourceName}.Integration.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: Applies to **/tests/Integration/**/*.ps1 : Integration tests must use `Disconnect-SqlDscDatabaseEngine` after `Connect-SqlDscDatabaseEngine`

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
⏰ 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 (9)
azure-pipelines.yml (1)

597-600: LGTM: SMTP integration test wired into RS/BI stages.

Good to see the new integration test included consistently across the Reporting Services and BI Report Server command stages.

Also applies to: 700-703, 789-792

tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.Tests.ps1 (8)

1-44: LGTM: test harness setup is tidy.

Setup/teardown blocks are clear and self-contained.


66-219: LGTM: parameter attribute validation is thorough.

The attribute checks cover mandatory, pipeline, type, and position as expected.


222-247: Happy-path SMTP configuration tests look good.

Mocks and invocation assertions are clear.


249-264: PassThru behavior is well covered.


266-279: Force path coverage looks good.


282-295: Failure path assertion is appropriate.


298-311: WhatIf branch correctly avoids CIM calls.


314-329: Configuration-parameter path is covered.

✏️ Tip: You can disable this entire section by setting review_details to false in your review 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.

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 94.69027% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 94%. Comparing base (10871a9) to head (ad78585).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
source/Public/Test-SqlDscRSAccessible.ps1 33% 4 Missing ⚠️
source/Public/Restart-SqlDscRSService.ps1 0% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #2411   +/-   ##
=====================================
  Coverage     94%     94%           
=====================================
  Files        217     218    +1     
  Lines      10926   10981   +55     
=====================================
+ Hits       10305   10358   +53     
- Misses       621     623    +2     
Flag Coverage Δ
unit 94% <94%> (+<1%) ⬆️
Files with missing lines Coverage Δ
...ource/Public/Add-SqlDscRSSslCertificateBinding.ps1 100% <100%> (ø)
source/Public/Add-SqlDscRSUrlReservation.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSConfigFile.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSConfiguration.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSExecutionLog.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSIPAddress.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSLogPath.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSPackage.ps1 100% <100%> (ø)
source/Public/Get-SqlDscRSSslCertificate.ps1 100% <100%> (ø)
...ource/Public/Get-SqlDscRSSslCertificateBinding.ps1 100% <100%> (ø)
... and 15 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johlju johlju marked this pull request as ready for review January 16, 2026 12:34
@johlju johlju requested a review from a team as a code owner January 16, 2026 12:34
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: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
source/Public/Restart-SqlDscRSService.ps1 (1)

133-140: Missing -Exception parameter in catch block.

Per coding guidelines, catch blocks using Write-Error should pass the original exception using -Exception. This preserves the original exception context for debugging and is consistent with other error handling in this PR.

Proposed fix
         catch
         {
             $errorMessage = $script:localizedData.Restart_SqlDscRSService_ServiceNotFound -f $targetServiceName

-            Write-Error -Message $errorMessage -Category ObjectNotFound -ErrorId 'RSRSRS0001' -TargetObject $targetServiceName
+            Write-Error -Message $errorMessage -Category ObjectNotFound -ErrorId 'RSRSRS0001' -TargetObject $targetServiceName -Exception $_.Exception

             return
         }
🤖 Fix all issues with AI agents
In `@azure-pipelines.yml`:
- Line 581: Add the missing integration test file
Set-SqlDscRSSmtpConfiguration.Integration.Tests.ps1 to the BI Report Server
stage in azure-pipelines.yml by inserting it into Group 3 immediately after
Restart-SqlDscRSService.Integration.Tests.ps1 so the BI Report Server stage has
the same coverage as the Reporting Services stage.

In
`@tests/Integration/Commands/Set-SqlDscRSSmtpConfiguration.Integration.Tests.ps1`:
- Around line 40-44: The It blocks call Set-SqlDscRSSmtpConfiguration and emit
unused output; suppress this by capturing the command output into $null in each
It block (e.g., replace direct invocation of Set-SqlDscRSSmtpConfiguration with
assignment to $null) for the tests at the locations referencing the
Set-SqlDscRSSmtpConfiguration calls so all It blocks (including the ones at the
other indicated ranges) remain quiet and follow Pester guidance.
- Around line 26-32: Add setup/teardown for the SQL engine connection inside the
existing BeforeAll/AfterAll blocks: in BeforeAll (where Import-Module is called)
invoke Connect-SqlDscDatabaseEngine to establish the DB session and ensure
errors stop the run, and in AfterAll call Disconnect-SqlDscDatabaseEngine to
close the session; keep the existing note about not using -Force/unloading
module, and ensure Connect-SqlDscDatabaseEngine is called before tests run and
Disconnect-SqlDscDatabaseEngine runs after all tests to comply with integration
test rules.

In `@tests/Unit/Public/Set-SqlDscRSSmtpConfiguration.Tests.ps1`:
- Around line 75-77: The tests are leaking command output because the
Set-SqlDscRSSmtpConfiguration calls (invoked on $mockCimInstance) are not
capturing their return values; change each invocation in the It blocks to assign
the command result to $null (for example, replace standalone "$mockCimInstance |
Set-SqlDscRSSmtpConfiguration ..." with "$null = $mockCimInstance |
Set-SqlDscRSSmtpConfiguration ...") so output is not written to the pipeline;
apply this same pattern to the other It blocks mentioned (the calls around the
119-121, 152-153, and 168-169 ranges) where the result is not asserted.
- Around line 4-24: The test data currently passed via -ForEach should be
declared inside the BeforeDiscovery block and referenced from the It block:
create a descriptive array variable (e.g. $testCases or $cases) inside
BeforeDiscovery, populate it with the data used by the -ForEach, and then remove
-ForEach from the It block and reference that array variable in the It block (or
use ForEach-Object over that variable) so the test becomes Pester data-driven
correctly; update the BeforeDiscovery, It and any additional occurrences noted
(lines ~48-52 equivalents) to use the new $testCases variable and remove inline
-ForEach usage.
- Around line 46-65: The test currently only asserts the parameter set string
for Set-SqlDscRSSmtpConfiguration; add a new Context that uses Get-Command -Name
'Set-SqlDscRSSmtpConfiguration' and inspects the ParameterSets/Parameters to
assert each parameter's attributes (e.g., Mandatory, ValueFromPipeline,
Position, and Type) for Configuration, SmtpServer, SenderEmailAddress, PassThru,
Force, WhatIf and Confirm; follow the existing Get-Command template pattern (use
ParameterSets, ParameterListAsString, and individual parameter property checks)
and add Should assertions verifying the expected Mandatory and ValueFromPipeline
flags and any specific Position or ParameterSet membership for those parameters.
- Around line 26-35: The BeforeAll block needs to load the SMO stub types before
importing the module and setting PSDefaultParameterValues; add a step inside the
BeforeAll (before Import-Module and the PSDefaultParameterValues assignments) to
load the SMO stubs (e.g., use Add-Type -Path 'SMO.cs' or equivalent to
compile/load the SMO.cs stubs), so that the tests have the SMO types available
when $script:moduleName is imported and when mocks/Shoulds run.

@johlju johlju merged commit 70c5846 into dsccommunity:main Jan 16, 2026
51 checks passed
@johlju johlju deleted the f/add-rs-smtpaddress branch January 16, 2026 17:04
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