Skip to content

Conversation

@johlju
Copy link
Member

@johlju johlju commented Nov 29, 2025

Pull Request (PR) description

  • Added public command Set-SqlDscDatabaseDefaultFileGroup to set the default
    filegroup or default FILESTREAM filegroup for a database in a SQL Server Database
    Engine instance. This command uses the SMO SetDefaultFileGroup() or
    SetDefaultFileStreamFileGroup() methods to change the default filegroup settings
    (issue #2328).

This Pull Request (PR) fixes the following issues

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 November 29, 2025 09:06
@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Walkthrough

Adds a new public PowerShell cmdlet Set-SqlDscDatabaseDefaultFileGroup to set a database's DefaultFileGroup or DefaultFileStreamFileGroup via SMO, plus localization strings, comprehensive unit and integration tests, changelog update, and CI test registration.

Changes

Cohort / File(s) Summary
New cmdlet (implementation)
source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
New public cmdlet with ServerObject+Name and DatabaseObject parameter sets; selects between SMO SetDefaultFileGroup() and SetDefaultFileStreamFileGroup(), supports ShouldProcess, Force, Refresh, PassThru, performs idempotence checks, invokes SMO methods, refreshes/returns DB object, and throws terminating errors on failure.
Localization
source/en-US/SqlServerDsc.strings.psd1
Added resource strings for DefaultFileGroup and DefaultFileStreamFileGroup messages (ShouldProcess caption/text, success/failure, idempotence, verbose messages).
Unit tests
tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
New unit tests with mocked SMO covering parameter sets, FileStream variants, success/idempotence/PassThru/Refresh scenarios, and failure paths.
Integration tests & docs
tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1, tests/Integration/Commands/README.md
New integration test suite that creates DBs/filegroups (conditional FILESTREAM), validates ServerObject/DatabaseObject/Refresh/PassThru/idempotence/error cases; README updated.
Changelog & CI
CHANGELOG.md, azure-pipelines.yml
CHANGELOG updated (formatting/reflow) to list new cmdlet; CI pipeline integration test list extended to include the new integration test script.

Sequence Diagram(s)

sequenceDiagram
  participant Caller as PowerShell caller
  participant Cmdlet as Set-SqlDscDatabaseDefaultFileGroup
  participant SMO as SMO Server/Database
  participant SQL as SQL Server

  Caller->>Cmdlet: Invoke (ServerObject+Name or DatabaseObject, target filegroup/filestream, Flags)
  Cmdlet->>SMO: Resolve or Refresh Database object (if needed)
  alt Current default matches desired
    SMO-->>Cmdlet: Current default matches
    Cmdlet-->>Caller: No-op success (optionally PassThru with refreshed object)
  else Change required
    Cmdlet->>SMO: Call SetDefaultFileGroup() or SetDefaultFileStreamFileGroup()
    SMO->>SQL: Apply change
    SQL-->>SMO: Acknowledge change
    SMO-->>Cmdlet: Updated state
    Cmdlet->>SMO: Refresh DB object (if PassThru or Refresh)
    Cmdlet-->>Caller: Success (optionally return refreshed DB object)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review focus:
    • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1: parameter validation, ShouldProcess text, selection and invocation of SMO methods, idempotence checks, error handling, PassThru/Refresh behavior.
    • Unit and integration tests: mock fidelity, conditional FILESTREAM paths, setup/cleanup and teardown correctness.

Possibly related PRs

Pre-merge checks

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: addition of a new command Set-SqlDscDatabaseDefaultFileGroup.
Description check ✅ Passed The description is directly related to the changeset, explaining the new command's purpose, methods used, issue reference, and completed checklist items.
Linked Issues check ✅ Passed All coding requirements from issue #2328 are met: new command created with ServerObject+Name and DatabaseObject parameter sets, SMO methods SetDefaultFileGroup/SetDefaultFileStreamFileGroup implemented, ShouldProcess/Force/PassThru supported, comprehensive unit and integration tests added.
Out of Scope Changes check ✅ Passed All changes are in scope: new command implementation, tests (unit and integration), localization strings, CHANGELOG update, and pipeline configuration for test execution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e400597 and 2084e75.

📒 Files selected for processing (1)
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.ps1: Format public commands as {Verb}-SqlDsc{Noun} following PowerShell naming conventions
Format private functions as {Verb}-{Noun} following PowerShell naming conventions

Files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.ps1
**/*.{ps1,psm1,psd1}

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

**/*.{ps1,psm1,psd1}: Use descriptive names with 3+ characters and no abbreviations for functions, variables, and identifiers
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase
Variables: Use camelCase
Keywords: Use lower-case
Classes: Use PascalCase
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
Try to limit lines to 120 characters
Newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed: 'text' vs "text $variable"
Single-line arrays: @('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
Empty hashtables: @{}; each property on separate line with proper indentation; use PascalCase for properties
Single-line comments: # Comment (capitalized, on own line); multi-line: <# Comment #> format with opening/closing brackets on own line
Do not include commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections
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 (one per line) with 1-line description, repeat keyword for each input type
OUTPUTS section in comment-based help: list each return type (one per line) with 1-line description, repeat keyword for each output type; must match both [OutputType()] and actual ret...

Files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.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/Set-SqlDscDatabaseDefaultFileGroup.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 (one per line) with a 1‑line description...

Files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
🧠 Learnings (12)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : Add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block of unit tests
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.
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help .OUTPUTS sections: Each distinct return type should have its own .OUTPUTS entry with a description of when that type is returned, even if the underlying implementation uses array casting. This follows official PowerShell documentation standards where you list each return type on its own line under .OUTPUTS with clear descriptions of the conditions for each type.

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help in .OUTPUTS sections: Each distinct type that can be returned should have its own .OUTPUTS entry, even if the implementation technically always returns an array. This follows official PowerShell documentation standards and helps users understand what to expect in different usage scenarios.

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-11-27T18:00:11.915Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-11-27T18:00:11.915Z
Learning: Applies to **/*.{ps1,psm1,psd1} : OUTPUTS section in comment-based help: list each return type (one per line) with 1-line description, repeat keyword for each output type; must match both `[OutputType()]` and actual returns

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-09-13T10:13:47.123Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2204
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:67-68
Timestamp: 2025-09-13T10:13:47.123Z
Learning: According to official Microsoft PowerShell documentation, both .INPUTS and .OUTPUTS keywords should be repeated for each type in comment-based help: "Repeat this keyword for each input type" and "Repeat this keyword for each output type". The guideline should instruct to repeat both keywords, not use single blocks.

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-10-03T15:27:39.511Z
Learnt from: Borgquite
Repo: dsccommunity/UpdateServicesDsc PR: 78
File: source/DSCResources/MSFT_UpdateServicesComputerTargetGroup/MSFT_UpdateServicesComputerTargetGroup.psm1:91-109
Timestamp: 2025-10-03T15:27:39.511Z
Learning: For MOF-based DSC resources in DSC Community repositories (files matching `source/DSCResources/MSFT_*/MSFT_*.psm1`), the comment-based help for `Get-TargetResource`, `Set-TargetResource`, and `Test-TargetResource` functions should NOT include `.OUTPUTS` sections, even though the general PowerShell guidelines require them. This is an established pattern in the DSC Community.

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-11-27T18:00:11.915Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-11-27T18:00:11.915Z
Learning: Applies to **/*.{ps1,psm1,psd1} : INPUTS section in comment-based help: list each pipeline-accepted type (one per line) with 1-line description, repeat keyword for each input type

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-11-27T18:00:11.915Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-11-27T18:00:11.915Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Avoid `Write-Output`; use `return` instead

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-11-27T18:00:35.054Z
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.054Z
Learning: Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-11-27T18:00:11.915Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-11-27T18:00:11.915Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Include `[OutputType({return type})]` for functions with output; use `[OutputType()]` for no output

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
📚 Learning: 2025-11-27T18:00:11.915Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-11-27T18:00:11.915Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Do not use the unary comma operator (`,`) in return statements to force an array

Applied to files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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)
source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1 (5)

1-92: LGTM! Comment-based help properly structured.

The comment-based help now correctly follows the guidelines with separate .OUTPUTS entries for each return type and includes comprehensive examples covering all parameter set combinations including DatabaseObject with DefaultFileStreamFileGroup.


93-98: LGTM! Function attributes properly configured.

The function correctly declares dual output types, implements SupportsShouldProcess, and sets appropriate ConfirmImpact level for database configuration changes.


99-141: LGTM! Parameter block follows guidelines.

The parameter declarations properly separate concerns across four parameter sets, maintain consistent ValueFromPipeline declarations, and follow all formatting and validation requirements.


143-149: LGTM! Force parameter pattern correctly implemented.

The begin block properly implements the Force parameter pattern per coding guidelines.


151-266: LGTM! Process block correctly handles pipeline input and implements all requirements.

The process block properly:

  • Handles multiple pipeline inputs without early termination (line 263 outputs without return)
  • Implements idempotence checking
  • Uses localized strings for all messages
  • Follows ShouldProcess pattern correctly
  • Handles errors with $PSCmdlet.ThrowTerminatingError()
  • Refreshes database object before returning when PassThru is specified
  • Uses Write-Debug appropriately inside ShouldProcess block per guidelines

The past pipeline/PassThru issue has been successfully resolved.


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

🧹 Nitpick comments (3)
tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1 (1)

60-131: Consider adding parameter set validation tests.

Per coding guidelines, all public commands require parameter set validation tests. The current tests cover functional scenarios but are missing the standard parameter set validation pattern.

Add parameter set validation tests after the Describe block opening. Example:

Context 'When validating parameter sets' {
    It 'Should have the correct parameters in parameter set <ExpectedParameterSetName>' -ForEach @(
        @{
            ExpectedParameterSetName = 'ServerObjectSet'
            ExpectedParameters = '[-ServerObject] <Server> [-Name] <string> [-DefaultFileGroup] <string> [-Refresh] [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
        }
        @{
            ExpectedParameterSetName = 'ServerObjectSetFileStream'
            ExpectedParameters = '[-ServerObject] <Server> [-Name] <string> [-DefaultFileStreamFileGroup] <string> [-Refresh] [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
        }
        @{
            ExpectedParameterSetName = 'DatabaseObjectSet'
            ExpectedParameters = '[-DatabaseObject] <Database> [-DefaultFileGroup] <string> [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
        }
        @{
            ExpectedParameterSetName = 'DatabaseObjectSetFileStream'
            ExpectedParameters = '[-DatabaseObject] <Database> [-DefaultFileStreamFileGroup] <string> [-Force] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]'
        }
    ) {
        $result = (Get-Command -Name 'Set-SqlDscDatabaseDefaultFileGroup').ParameterSets |
            Where-Object -FilterScript { $_.Name -eq $ExpectedParameterSetName } |
            Select-Object -Property @(
                @{ Name = 'ParameterSetName'; Expression = { $_.Name } },
                @{ Name = 'ParameterListAsString'; Expression = { $_.ToString() } }
            )
        $result.ParameterSetName | Should -Be $ExpectedParameterSetName
        $result.ParameterListAsString | Should -Be $ExpectedParameters
    }
}
tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (2)

108-134: Differentiate FILESTREAM support from generic creation failures in the catch block

Right now any failure in the FILESTREAM database creation (including directory or permission issues) is treated as “FILESTREAM is not enabled” and simply sets $script:fileStreamSupported = $false. That can silently hide real problems and skip coverage even when FILESTREAM is actually available.

Consider tightening this by either:

  • Inspecting the exception message/number to only flip $script:fileStreamSupported for the known “FILESTREAM disabled” error, and rethrowing for other failures, or
  • Logging the full exception details in the verbose message so unexpected issues are easier to diagnose.

This keeps the skip behavior focused on true lack of FILESTREAM support while still surfacing genuine environmental problems.


34-36: Remove unused $script:mockComputerName or use it for clarity

$script:mockComputerName = Get-ComputerName is never referenced in the rest of the file. Dropping it (or wiring it into assertions/logging if you intended to use it) will simplify the setup block and avoid suppressed “declared but not used” warnings.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed34b01 and b2a68d8.

📒 Files selected for processing (7)
  • CHANGELOG.md (2 hunks)
  • azure-pipelines.yml (1 hunks)
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1 (1 hunks)
  • source/en-US/SqlServerDsc.strings.psd1 (1 hunks)
  • tests/Integration/Commands/README.md (1 hunks)
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (19)
**/*.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:

  • tests/Integration/Commands/README.md
  • 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:

  • tests/Integration/Commands/README.md
  • CHANGELOG.md
**

⚙️ 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/README.md
  • azure-pipelines.yml
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • CHANGELOG.md
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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
**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.ps1: Format public commands as {Verb}-SqlDsc{Noun} following PowerShell naming conventions
Format private functions as {Verb}-{Noun} following PowerShell naming conventions

Files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
**/*.[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-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.Tests.ps1
**/*.{ps1,psm1,psd1}

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

**/*.{ps1,psm1,psd1}: Use descriptive names with 3+ characters and no abbreviations for functions, variables, and identifiers
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase
Variables: Use camelCase
Keywords: Use lower-case
Classes: Use PascalCase
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
Try to limit lines to 120 characters
Newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed: 'text' vs "text $variable"
Single-line arrays: @('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
Empty hashtables: @{}; each property on separate line with proper indentation; use PascalCase for properties
Single-line comments: # Comment (capitalized, on own line); multi-line: <# Comment #> format with opening/closing brackets on own line
Do not include commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections
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 (one per line) with 1-line description, repeat keyword for each input type
OUTPUTS section in comment-based help: list each return type (one per line) with 1-line description, repeat keyword for each output type; must match both [OutputType()] and actual ret...

Files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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 }
Mock files using the $TestDrive variable (path to the test drive)
All public commands require parameter set validation tests
Use the exact setup block with BeforeDiscovery, BeforeAll, and AfterAll blocks including DscResource.Test module import and PSDefaultParameterValues configuration
Parameter set validation tests should use Get-Command with Where-Object filtering and Should assertions to verify ParameterSetName and ParameterListAsString
Parameter property tests should verify mandatory parameter attributes using Get-Command Parameters and Should -BeTrue assertions

Files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.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 -Force -ErrorAction 'Stop'

    $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:moduleName
    $PSDefaultParameterValues['Mock:ModuleName'] = $script:moduleName
    $PSDefaultParameterValues['Should:ModuleName'] = $script:moduleName
}

AfterAll {
    $PSDefaultParameterValues.Remove('InModuleScope:ModuleName')
    $PSDefaultParameterValues.Remove('Mock:ModuleNam...

Files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.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 (one per line) with a 1‑line description...

Files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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
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/Integration/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

Integration tests: use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials, and always follow with Disconnect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)

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

Integration tests for commands should be located in tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
tests/Integration/**/*.Integration.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)

tests/Integration/**/*.Integration.Tests.ps1: Integration tests must not use mocking - use real environment only
Integration tests must cover all scenarios and code paths
Use Get-ComputerName for computer names in CI environments
Avoid ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter where applicable to avoid prompting
Use -ErrorAction 'Stop' on commands so failures surface immediately
Integration tests must include the required setup block with BeforeDiscovery that imports DscResource.Test module and BeforeAll that imports the module being tested

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.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 -Force -ErrorAction 'Stop'
}

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.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-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.ps1
🧠 Learnings (50)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`

Applied to files:

  • tests/Integration/Commands/README.md
  • azure-pipelines.yml
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.054Z
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.054Z
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/README.md
  • azure-pipelines.yml
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:20.390Z
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.390Z
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/Integration/Commands/README.md
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : Add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block of unit tests

Applied to files:

  • tests/Integration/Commands/README.md
  • azure-pipelines.yml
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-08-28T15:44:12.628Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The SqlServerDsc repository uses RequiredModules.psd1 to specify Pester with Version = 'latest' and AllowPrerelease = $true, ensuring the latest Pester version (well beyond 5.4) is available, which supports Should -Invoke syntax and other modern Pester features.

Applied to files:

  • tests/Integration/Commands/README.md
📚 Learning: 2025-11-27T17:57:47.608Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-27T17:57:47.608Z
Learning: SqlServerDsc-specific guidelines and requirements override general project guidelines and requirements

Applied to files:

  • tests/Integration/Commands/README.md
📚 Learning: 2025-11-27T17:58:02.401Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.401Z
Learning: Applies to **/resources/**/*.ps1 : Add `InstanceName`, `ServerName`, and `Credential` to `$this.ExcludeDscProperties` in Database Engine resources

Applied to files:

  • tests/Integration/Commands/README.md
  • CHANGELOG.md
  • source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:58:02.401Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.401Z
Learning: Applies to **/*.ps1 : Format public commands as `{Verb}-SqlDsc{Noun}` following PowerShell naming conventions

Applied to files:

  • tests/Integration/Commands/README.md
  • source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
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-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests

Applied to files:

  • azure-pipelines.yml
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 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: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Integration tests must cover all scenarios and code paths

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Integration tests must include the required setup block with BeforeDiscovery that imports DscResource.Test module and BeforeAll that imports the module being tested

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for Commands integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/Resources/*.Integration.Tests.ps1 : Location for Resources integration tests: `tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1`

Applied to files:

  • azure-pipelines.yml
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Call commands with `-Force` parameter where applicable to avoid prompting

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to tests/Unit/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`

Applied to files:

  • azure-pipelines.yml
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions and classes must have unit tests

Applied to files:

  • azure-pipelines.yml
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths

Applied to files:

  • azure-pipelines.yml
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : When unit tests test classes or commands containing SMO types like `[Microsoft.SqlServer.Management.Smo.*]`, ensure they are properly stubbed in SMO.cs

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : In unit tests: use SMO stub types from SMO.cs, never mock SMO types

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : Load SMO stub types in unit test files using `Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"`

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T18:00:20.925Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-11-27T18:00:20.925Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : All public commands require parameter set validation tests

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-08-18T13:50:53.789Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.498Z
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.498Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use `New-ObjectNotFoundException` for object not found errors instead of `throw` in MOF-based DSC resources

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.724Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.724Z
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-SqlDscDatabaseDefaultFileGroup.Tests.ps1
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.498Z
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.498Z
Learning: Applies to source/DSCResources/**/*.psm1 : Use `New-NotImplementedException` for not implemented errors instead of `throw` in MOF-based DSC resources

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never add an empty `-MockWith` block

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Mock` inside `InModuleScope`-block

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Set `$PSDefaultParameterValues` for `Mock:ModuleName`, `Should:ModuleName`, `InModuleScope:ModuleName`

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit `-MockWith` when returning `$null`

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Assert-MockCalled`, use `Should -Invoke` instead

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 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.498Z
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.498Z
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:59:01.498Z
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.498Z
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.498Z
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.498Z
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:58:42.320Z
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.320Z
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.320Z
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.320Z
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.498Z
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.498Z
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:58:42.320Z
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.320Z
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.498Z
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.498Z
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:59:01.498Z
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.498Z
Learning: Applies to source/DSCResources/**/*.psm1 : Create an `en-US` folder in each DSC resource directory for localized strings

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T17:59:01.498Z
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.498Z
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-11-27T18:00:11.915Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-11-27T18:00:11.915Z
Learning: Applies to **/*.{ps1,psm1,psd1} : `$PSCmdlet.ShouldProcess` must use required pattern: localized messages for description, confirmation, and caption

Applied to files:

  • source/en-US/SqlServerDsc.strings.psd1
📚 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:

  • source/en-US/SqlServerDsc.strings.psd1
📚 Learning: 2025-11-27T18:00:20.925Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-11-27T18:00:20.925Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact setup block with BeforeDiscovery, BeforeAll, and AfterAll blocks including DscResource.Test module import and PSDefaultParameterValues configuration

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : One `Describe` block per file matching the tested entity name

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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

@codecov
Copy link

codecov bot commented Nov 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (752efb6) to head (2084e75).

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #2354   +/-   ##
====================================
  Coverage    94%     94%           
====================================
  Files       164     165    +1     
  Lines      9563    9603   +40     
====================================
+ Hits       9070    9110   +40     
  Misses      493     493           
Flag Coverage Δ
unit 94% <100%> (+<1%) ⬆️
Files with missing lines Coverage Δ
...urce/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1 100% <100%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…es for DefaultFileGroup and DefaultFileStreamFileGroup handling
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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2a68d8 and 0735b68.

📒 Files selected for processing (1)
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.ps1: Format public commands as {Verb}-SqlDsc{Noun} following PowerShell naming conventions
Format private functions as {Verb}-{Noun} following PowerShell naming conventions

Files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.ps1
**/*.{ps1,psm1,psd1}

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

**/*.{ps1,psm1,psd1}: Use descriptive names with 3+ characters and no abbreviations for functions, variables, and identifiers
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase
Variables: Use camelCase
Keywords: Use lower-case
Classes: Use PascalCase
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
Try to limit lines to 120 characters
Newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed: 'text' vs "text $variable"
Single-line arrays: @('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
Empty hashtables: @{}; each property on separate line with proper indentation; use PascalCase for properties
Single-line comments: # Comment (capitalized, on own line); multi-line: <# Comment #> format with opening/closing brackets on own line
Do not include commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections
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 (one per line) with 1-line description, repeat keyword for each input type
OUTPUTS section in comment-based help: list each return type (one per line) with 1-line description, repeat keyword for each output type; must match both [OutputType()] and actual ret...

Files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.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/Set-SqlDscDatabaseDefaultFileGroup.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 (one per line) with a 1‑line description...

Files:

  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`
⏰ 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/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1 (1)

81-178: Cmdlet structure, parameter sets, localization, and ShouldProcess usage look correct

The cmdlet binding, parameter sets, Force pattern in begin, localized messages, and ShouldProcess implementation all align with the documented patterns:

  • Public name and file placement follow {Verb}-SqlDsc{Noun} and source/Public/{Command}.ps1.
  • Parameter sets cleanly separate ServerObject vs DatabaseObject and DefaultFileGroup vs DefaultFileStreamFileGroup.
  • Force handling uses the recommended ConfirmPreference = 'None' approach.
  • All diagnostic strings (ShouldProcess, debug, error) are localized via $script:localizedData.
  • The ShouldProcess call uses the required description/confirmation/caption message pattern.

No changes needed here from my side.
As per coding guidelines.

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

♻️ Duplicate comments (1)
tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (1)

49-126: Hard-coded version-specific SQL Server paths break cross-version compatibility.

The CREATE/ALTER DATABASE statements use hard-coded paths containing MSSQL16.DSCSQLTEST, which is SQL Server 2022-specific. Tests tagged for SQL2017, SQL2019, and SQL2022 will fail on SQL 2017 (MSSQL14) and SQL 2019 (MSSQL15).

Resolve the instance's default data path dynamically in BeforeAll using SERVERPROPERTY('InstanceDefaultDataPath'), store it in a script variable, and interpolate it into all FILENAME values instead of hard-coding version-specific directory structures.

Based on learnings, integration tests must work across all tagged SQL Server versions.

🧹 Nitpick comments (1)
tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (1)

132-132: Consider Write-Information for user-facing status messages in tests.

Lines 132 and 139 use Write-Verbose -Verbose for user-facing status messages. Per guidelines, Write-Information is preferred for user-facing status updates and operational messages, while Write-Verbose is for high-level execution flow.

However, Write-Verbose -Verbose is a common pattern in integration tests for ensuring CI visibility, so this is an optional refinement.

Also applies to: 139-139

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0735b68 and 96666a1.

📒 Files selected for processing (1)
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.ps1: Format public commands as {Verb}-SqlDsc{Noun} following PowerShell naming conventions
Format private functions as {Verb}-{Noun} following PowerShell naming conventions

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
**/tests/Integration/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

Integration tests: use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials, and always follow with Disconnect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)

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

Integration tests for commands should be located in tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
tests/Integration/**/*.Integration.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)

tests/Integration/**/*.Integration.Tests.ps1: Integration tests must not use mocking - use real environment only
Integration tests must cover all scenarios and code paths
Use Get-ComputerName for computer names in CI environments
Avoid ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter where applicable to avoid prompting
Use -ErrorAction 'Stop' on commands so failures surface immediately
Integration tests must include the required setup block with BeforeDiscovery that imports DscResource.Test module and BeforeAll that imports the module being tested

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
**/*.[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/Set-SqlDscDatabaseDefaultFileGroup.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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
**/*.{ps1,psm1,psd1}

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

**/*.{ps1,psm1,psd1}: Use descriptive names with 3+ characters and no abbreviations for functions, variables, and identifiers
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase
Variables: Use camelCase
Keywords: Use lower-case
Classes: Use PascalCase
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
Try to limit lines to 120 characters
Newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed: 'text' vs "text $variable"
Single-line arrays: @('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
Empty hashtables: @{}; each property on separate line with proper indentation; use PascalCase for properties
Single-line comments: # Comment (capitalized, on own line); multi-line: <# Comment #> format with opening/closing brackets on own line
Do not include commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections
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 (one per line) with 1-line description, repeat keyword for each input type
OUTPUTS section in comment-based help: list each return type (one per line) with 1-line description, repeat keyword for each output type; must match both [OutputType()] and actual ret...

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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/Set-SqlDscDatabaseDefaultFileGroup.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 (one per line) with a 1‑line description...

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.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 -Force -ErrorAction 'Stop'
}

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
🧠 Learnings (20)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : Add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block of unit tests

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Integration tests must cover all scenarios and code paths

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Call commands with `-Force` parameter where applicable to avoid prompting

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Integration tests must include the required setup block with BeforeDiscovery that imports DscResource.Test module and BeforeAll that imports the module being tested

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:20.925Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-11-27T18:00:20.925Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact setup block with BeforeDiscovery, BeforeAll, and AfterAll blocks including DscResource.Test module import and PSDefaultParameterValues configuration

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.054Z
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.054Z
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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for Commands integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-08-09T19:29:36.323Z
Learnt from: johlju
Repo: dsccommunity/DscResource.Test PR: 167
File: source/Private/Test-FileContainsClassResource.ps1:44-56
Timestamp: 2025-08-09T19:29:36.323Z
Learning: In the DscResource.Test repository, DSC resource attributes are consistently written as `[DscResource(...)]` rather than using variations like `[DscResourceAttribute()]` or fully qualified names like `[Microsoft.PowerShell.DesiredStateConfiguration.DscResource()]`. The Test-FileContainsClassResource function should focus on detecting the standard `[DscResource(...)]` pattern that is actually used in the codebase.

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-08-22T12:39:02.400Z
Learnt from: ChristophHannappel
Repo: dsccommunity/SharePointDsc PR: 1457
File: .vscode/launch.json:43-44
Timestamp: 2025-08-22T12:39:02.400Z
Learning: The SharePointDsc repository uses "tests" (lowercase) for the test directory, not "Tests" (uppercase). Launch configurations and other path references should use the correct lowercase "tests" folder name.

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:11.915Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-11-27T18:00:11.915Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Avoid hardcoded computer names; use cross-platform `Get-ComputerName` instead of `$env:COMPUTERNAME`

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.724Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.724Z
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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : When unit tests test classes or commands containing SMO types like `[Microsoft.SqlServer.Management.Smo.*]`, ensure they are properly stubbed in SMO.cs

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-08-18T13:50:53.789Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : One `Describe` block per file matching the tested entity name

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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 (3)
tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (3)

1-30: LGTM! Required setup block follows integration test guidelines.

The BeforeDiscovery and BeforeAll blocks correctly implement the required pattern for integration tests, including proper DscResource.Test module import with error handling and module import.


142-162: LGTM! Proper cleanup with conditional logic and disconnect.

The AfterAll block correctly:

  • Uses AfterAll for cleanup (not try-catch-finally)
  • Conditionally includes FILESTREAM database based on support detection
  • Removes test databases with -Force and proper error handling
  • Calls Disconnect-SqlDscDatabaseEngine as required

Based on learnings, integration tests must disconnect using Disconnect-SqlDscDatabaseEngine.


164-295: LGTM! Comprehensive test coverage across all scenarios.

The test contexts thoroughly cover all scenarios and code paths:

  • Both parameter sets (ServerObject + Name, DatabaseObject)
  • Both filegroup types (DefaultFileGroup, DefaultFileStreamFileGroup)
  • Pipeline input, Refresh, and PassThru parameters
  • Error handling for non-existent databases and filegroups
  • Idempotence verification
  • Conditional FILESTREAM tests with proper -Skip logic

All tests follow integration test guidelines: no mocking, proper error handling with -ErrorAction 'Stop', -Force parameter usage, and correct Pester v5 syntax with Context descriptions starting with "When" and It descriptions starting with "Should".

Based on learnings, integration tests must cover all scenarios and code paths.

- Added examples for setting the default FILESTREAM filegroup using a database object.
- Clarified output descriptions in the function documentation.
- Introduced parameter set validation tests to ensure correct parameters are defined for different sets.
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

♻️ Duplicate comments (1)
tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (1)

49-125: Hard-coded version-specific SQL Server paths will break cross-version compatibility.

The tests hard-code MSSQL16.DSCSQLTEST paths (SQL Server 2022 specific), but the test is tagged for SQL2017, SQL2019, and SQL2022. This will cause failures when running against SQL Server 2017 (MSSQL14.) or 2019 (MSSQL15.), or any non-default installation path.

Query SERVERPROPERTY('InstanceDefaultDataPath') once in BeforeAll, store the result in $script:defaultDataPath, and interpolate it into all FILENAME clauses instead of hard-coding version-specific paths.

🧹 Nitpick comments (1)
tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1 (1)

92-444: Consider using Mock with Should -Invoke for more robust method verification.

The tests use script-scoped variables ($script:setDefaultFileGroupCalled) with manually added ScriptMethod members to verify SMO method calls. While functional, this approach could be more robust by using Pester's Mock command with Should -Invoke assertions, which provides built-in verification of call counts, parameters, and better failure messages.

Based on learnings, SMO stub objects can be verified with Should -Invoke for more robust testing.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25a764a and 0ecd07b.

📒 Files selected for processing (3)
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1 (1 hunks)
  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1 (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/Public/Set-SqlDscDatabaseDefaultFileGroup.ps1
🧰 Additional context used
📓 Path-based instructions (12)
**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.ps1: Format public commands as {Verb}-SqlDsc{Noun} following PowerShell naming conventions
Format private functions as {Verb}-{Noun} following PowerShell naming conventions

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
**/tests/Integration/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

Integration tests: use Connect-SqlDscDatabaseEngine for SQL Server DB session with correct CI credentials, and always follow with Disconnect-SqlDscDatabaseEngine

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
tests/Integration/Commands/*.Integration.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)

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

Integration tests for commands should be located in tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
tests/Integration/**/*.Integration.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md)

tests/Integration/**/*.Integration.Tests.ps1: Integration tests must not use mocking - use real environment only
Integration tests must cover all scenarios and code paths
Use Get-ComputerName for computer names in CI environments
Avoid ExpectedMessage parameter for Should -Throw assertions in integration tests
Call commands with -Force parameter where applicable to avoid prompting
Use -ErrorAction 'Stop' on commands so failures surface immediately
Integration tests must include the required setup block with BeforeDiscovery that imports DscResource.Test module and BeforeAll that imports the module being tested

Files:

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

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

**/*.{ps1,psm1,psd1}: Use descriptive names with 3+ characters and no abbreviations for functions, variables, and identifiers
Functions: Use PascalCase with Verb-Noun format using approved verbs
Parameters: Use PascalCase
Variables: Use camelCase
Keywords: Use lower-case
Classes: Use PascalCase
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
Try to limit lines to 120 characters
Newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed: 'text' vs "text $variable"
Single-line arrays: @('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
Empty hashtables: @{}; each property on separate line with proper indentation; use PascalCase for properties
Single-line comments: # Comment (capitalized, on own line); multi-line: <# Comment #> format with opening/closing brackets on own line
Do not include commented-out code
Always add comment-based help to all functions and scripts with SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections
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 (one per line) with 1-line description, repeat keyword for each input type
OUTPUTS section in comment-based help: list each return type (one per line) with 1-line description, repeat keyword for each output type; must match both [OutputType()] and actual ret...

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.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 (one per line) with a 1‑line description...

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.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 -Force -ErrorAction 'Stop'
}

Files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.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 }
Mock files using the $TestDrive variable (path to the test drive)
All public commands require parameter set validation tests
Use the exact setup block with BeforeDiscovery, BeforeAll, and AfterAll blocks including DscResource.Test module import and PSDefaultParameterValues configuration
Parameter set validation tests should use Get-Command with Where-Object filtering and Should assertions to verify ParameterSetName and ParameterListAsString
Parameter property tests should verify mandatory parameter attributes using Get-Command Parameters and Should -BeTrue assertions

Files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.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 -Force -ErrorAction 'Stop'

    $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:moduleName
    $PSDefaultParameterValues['Mock:ModuleName'] = $script:moduleName
    $PSDefaultParameterValues['Should:ModuleName'] = $script:moduleName
}

AfterAll {
    $PSDefaultParameterValues.Remove('InModuleScope:ModuleName')
    $PSDefaultParameterValues.Remove('Mock:ModuleNam...

Files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.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-SqlDscDatabaseDefaultFileGroup.Tests.ps1
🧠 Learnings (30)
📓 Common learnings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.401Z
Learning: Applies to **/*.ps1 : Format public commands as `{Verb}-SqlDsc{Noun}` following PowerShell naming conventions
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.498Z
Learning: Applies to source/DSCResources/**/*.psm1 : Create an `en-US` folder in each DSC resource directory for localized strings
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : Add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block of unit tests
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/Integration/**/*.ps1 : Integration tests: use `Connect-SqlDscDatabaseEngine` for SQL Server DB session with correct CI credentials, and always follow with `Disconnect-SqlDscDatabaseEngine`

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Integration tests must cover all scenarios and code paths

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : Add `$env:SqlServerDscCI = $true` in `BeforeAll` block and remove in `AfterAll` block of unit tests

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Call commands with `-Force` parameter where applicable to avoid prompting

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.054Z
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.054Z
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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Location for Commands integration tests: `tests/Integration/Commands/{CommandName}.Integration.Tests.ps1`

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:31.900Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Integration tests must include the required setup block with BeforeDiscovery that imports DscResource.Test module and BeforeAll that imports the module being tested

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:20.925Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-11-27T18:00:20.925Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Use the exact setup block with BeforeDiscovery, BeforeAll, and AfterAll blocks including DscResource.Test module import and PSDefaultParameterValues configuration

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-08-09T19:29:36.323Z
Learnt from: johlju
Repo: dsccommunity/DscResource.Test PR: 167
File: source/Private/Test-FileContainsClassResource.ps1:44-56
Timestamp: 2025-08-09T19:29:36.323Z
Learning: In the DscResource.Test repository, DSC resource attributes are consistently written as `[DscResource(...)]` rather than using variations like `[DscResourceAttribute()]` or fully qualified names like `[Microsoft.PowerShell.DesiredStateConfiguration.DscResource()]`. The Test-FileContainsClassResource function should focus on detecting the standard `[DscResource(...)]` pattern that is actually used in the codebase.

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-08-22T12:39:02.400Z
Learnt from: ChristophHannappel
Repo: dsccommunity/SharePointDsc PR: 1457
File: .vscode/launch.json:43-44
Timestamp: 2025-08-22T12:39:02.400Z
Learning: The SharePointDsc repository uses "tests" (lowercase) for the test directory, not "Tests" (uppercase). Launch configurations and other path references should use the correct lowercase "tests" folder name.

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:00:11.915Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-11-27T18:00:11.915Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Avoid hardcoded computer names; use cross-platform `Get-ComputerName` instead of `$env:COMPUTERNAME`

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.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/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T18:00:35.054Z
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.054Z
Learning: Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T18:56:46.724Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 1622
File: tests/Integration/DSC_SqlDatabase.Integration.Tests.ps1:1-30
Timestamp: 2025-11-27T18:56:46.724Z
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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : When unit tests test classes or commands containing SMO types like `[Microsoft.SqlServer.Management.Smo.*]`, ensure they are properly stubbed in SMO.cs

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-08-18T13:50:53.789Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.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/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : One `Describe` block per file matching the tested entity name

Applied to files:

  • tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1
📚 Learning: 2025-11-27T17:58:02.402Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : In unit tests: use SMO stub types from SMO.cs, never mock SMO types

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T18:00:20.925Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-11-27T18:00:20.925Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : All public commands require parameter set validation tests

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to tests/Unit/Public/*.[Tt]ests.ps1 : Public commands: `tests/Unit/Public/{Name}.Tests.ps1`

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions and classes must have unit tests

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:01.498Z
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.498Z
Learning: Applies to source/DSCResources/**/*.psm1 : `Set-TargetResource` and `Test-TargetResource` must have identical parameters

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-10-10T14:01:42.703Z
Learnt from: dan-hughes
Repo: dsccommunity/UpdateServicesDsc PR: 86
File: tests/Unit/MSFT_UpdateServicesServer.Tests.ps1:6-45
Timestamp: 2025-10-10T14:01:42.703Z
Learning: For script-based (MOF) DSC resources in UpdateServicesDsc, unit tests should use Initialize-TestEnvironment with variables $script:dscModuleName and $script:dscResourceName, and set -ResourceType 'Mof'. This differs from class-based resource tests which use the simpler $script:moduleName template without Initialize-TestEnvironment.

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T18:00:20.925Z
Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-11-27T18:00:20.925Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Parameter set validation tests should use Get-Command with Where-Object filtering and Should assertions to verify ParameterSetName and ParameterListAsString

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mocking in `BeforeAll` (`BeforeEach` only when required)

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1
📚 Learning: 2025-11-27T17:59:27.192Z
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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Set `$PSDefaultParameterValues` for `Mock:ModuleName`, `Should:ModuleName`, `InModuleScope:ModuleName`

Applied to files:

  • tests/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.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/Unit/Public/Set-SqlDscDatabaseDefaultFileGroup.Tests.ps1 (2)

1-58: LGTM! Test setup follows required pattern.

The setup blocks correctly implement the required BeforeDiscovery/BeforeAll/AfterAll pattern, set $env:SqlServerDscCI = $true, load SMO stubs, configure PSDefaultParameterValues, and clean up properly.


61-90: LGTM! Parameter set validation tests follow guidelines.

The parameter set validation tests correctly use the required pattern with Get-Command, Where-Object filtering, and Should assertions to verify all four parameter sets.

tests/Integration/Commands/Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1 (3)

1-30: LGTM! Integration test setup follows required pattern.

The setup blocks correctly implement the required BeforeDiscovery/BeforeAll pattern for integration tests and properly omit $env:SqlServerDscCI (which is only for unit tests).


33-161: LGTM! Connection handling and cleanup follow best practices.

The tests correctly use Connect-SqlDscDatabaseEngine with proper credentials, clean up test databases in AfterAll, and properly disconnect with Disconnect-SqlDscDatabaseEngine.


163-294: LGTM! Test coverage is comprehensive and follows guidelines.

The test contexts cover all scenarios: ServerObject and DatabaseObject parameter sets, pipeline input, Refresh, PassThru, FILESTREAM (with conditional skip), idempotence, and error cases. Tests use -Force and -ErrorAction 'Stop' appropriately, and Context/It descriptions follow naming conventions.

@johlju
Copy link
Member Author

johlju commented Nov 29, 2025

@coderabbitai you said "Based on learnings, SMO stub objects can be verified with Should -Invoke for more robust testing.", that is not true - SMO stub types cannot be mocked using Mock and that also means it is not possible to use Should -Incoke on them.

@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Tip

For best results, initiate chat on the files or code changes.

@johlju, you're absolutely correct, and I apologize for the confusion. SMO stub types cannot be mocked using Mock, which means Should -Invoke cannot be used to verify method calls on them, since Should -Invoke is specifically for verifying mocked calls.

I notice there are contradictory learnings in the knowledge base:

  • Two duplicate learnings (IDs: bbdcd735-db6f-41e9-96ec-468e8156cab9 and 8903e675-08a3-46c1-87b9-bf5f5b0e93eb) suggest SMO stub objects can be verified with Should -Invoke
  • This contradicts the guideline that SMO types should never be mocked

Would you like me to remove these incorrect learnings from the knowledge base?


🧠 Learnings used
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : In unit tests: use SMO stub types from SMO.cs, never mock SMO types

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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Assert-MockCalled`, use `Should -Invoke` instead

Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : When unit tests test classes or commands containing SMO types like `[Microsoft.SqlServer.Management.Smo.*]`, ensure they are properly stubbed in SMO.cs

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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Mock` inside `InModuleScope`-block

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.

Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-11-27T17:58:31.900Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Integration tests must not use mocking - use real environment only

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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit `-MockWith` when returning `$null`

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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never add an empty `-MockWith` block

@johlju
Copy link
Member Author

johlju commented Nov 29, 2025

I notice there are contradictory learnings in the knowledge base:

  • Two duplicate learnings (IDs: bbdcd735-db6f-41e9-96ec-468e8156cab9 and 8903e675-08a3-46c1-87b9-bf5f5b0e93eb) suggest SMO stub objects can be verified with Should -Invoke
  • This contradicts the guideline that SMO types should never be mocked

Would you like me to remove these incorrect learnings from the knowledge base?

Yes, remove contradicting learnings.

@johlju
Copy link
Member Author

johlju commented Nov 29, 2025

I notice there are contradictory learnings in the knowledge base:

  • Two duplicate learnings (IDs: bbdcd735-db6f-41e9-96ec-468e8156cab9 and 8903e675-08a3-46c1-87b9-bf5f5b0e93eb) suggest SMO stub objects can be verified with Should -Invoke
  • This contradicts the guideline that SMO types should never be mocked

Would you like me to remove these incorrect learnings from the knowledge base?

@coderabbitai Yes, remove contradicting learnings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 29, 2025

Tip

For best results, initiate chat on the files or code changes.

@johlju, I've removed both contradictory learnings from the knowledge base. The incorrect learnings that suggested SMO stub objects can be verified with Should -Invoke have been deleted, ensuring the knowledge base now correctly reflects that SMO types should never be mocked in unit tests.


⛔ Learnings removed
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

🧠 Learnings used
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

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.

Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : In unit tests: use SMO stub types from SMO.cs, never mock SMO types

Learnt from: CR
Repo: dsccommunity/SqlServerDsc PR: 0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-11-27T17:58:02.402Z
Learning: Applies to **/tests/**/*.tests.ps1 : When unit tests test classes or commands containing SMO types like `[Microsoft.SqlServer.Management.Smo.*]`, ensure they are properly stubbed in SMO.cs

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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Assert-MockCalled`, use `Should -Invoke` instead

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.192Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use `Mock` inside `InModuleScope`-block

@johlju
Copy link
Member Author

johlju commented Nov 30, 2025

This fails with, I do not know why - maybe the property will not be set or something else need to happen for this to work:

Running tests from 'D:\a\1\s\tests\Integration\Commands\Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1'
VERBOSE: Impersonate credential 'SqlAdmin' with login type 'WindowsUser'. (SQLCOMMON0056)
VERBOSE: Connected to SQL instance 'runnervmz4wi3\DSCSQLTEST'. (SQLCOMMON0018)
VERBOSE: FILESTREAM is not enabled on this instance. Skipping FILESTREAM tests.
VERBOSE: Original default filegroup of database 'SqlDscTestSetDefaultFG_146522837' is ''.
Describing Set-SqlDscDatabaseDefaultFileGroup
 Context When setting default filegroup using ServerObject parameter set
##[error]    [-] Should set default filegroup to UserDataFileGroup successfully 83ms (79ms|4ms)
##[error]     Expected 'UserDataFileGroup', but got $null.
##[error]     at $resultDb.DefaultFileGroup | Should -Be 'UserDataFileGroup', D:\a\1\s\tests\Integration\Commands\Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1:176
##[error]     at Invoke-Assertion, D:\a\1\s\output\RequiredModules\Pester\6.0.0\Pester.psm1:11391
##[error]     at Should<End>, D:\a\1\s\output\RequiredModules\Pester\6.0.0\Pester.psm1:11330
##[error]     at <ScriptBlock>, D:\a\1\s\tests\Integration\Commands\Set-SqlDscDatabaseDefaultFileGroup.Integration.Tests.ps1:176

@johlju johlju added help wanted The issue is up for grabs for anyone in the community. needs review The pull request needs a code review. labels Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted The issue is up for grabs for anyone in the community. needs review The pull request needs a code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set-SqlDscDatabaseDefaultFileGroup: Add new command

1 participant