Skip to content

New-SqlDscDatabase: Add more properties#2356

Merged
johlju merged 18 commits intodsccommunity:mainfrom
johlju:fix/issue-#2190
Dec 1, 2025
Merged

New-SqlDscDatabase: Add more properties#2356
johlju merged 18 commits intodsccommunity:mainfrom
johlju:fix/issue-#2190

Conversation

@johlju
Copy link
Copy Markdown
Member

@johlju johlju commented Nov 30, 2025

Pull Request (PR) description

  • New-SqlDscDatabase
    • Added comprehensive set of settable database properties that were previously
      only available in `Set-SqlDscDatabaseProperty
      (issue #2190).

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 30, 2025 17:49
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 30, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds New-SqlDscDatabase with many creation-time parameters mapping SMO Database properties; converts many boolean database-property parameters across New-/Set-/Test-SqlDscDatabase to SwitchParameter or SMO enum types, updates comparison/conversion logic, extends SMO stubs, and updates unit and integration tests.

Changes

Cohort / File(s) Summary
Cmdlet: New-SqlDscDatabase
source/Public/New-SqlDscDatabase.ps1
Added ~60 new Database parameter-set parameters (SwitchParameter, int, long/double, string, enum). Applies provided PSBoundParameters to the SMO Database object in the Database creation branch before Create. Added PSAvoidUsingPlainTextForPassword suppression for RemoteDataArchiveCredential; adjusted IsLedger to a SwitchParameter.
Cmdlet: Set-SqlDscDatabaseProperty
source/Public/Set-SqlDscDatabaseProperty.ps1
Converted many boolean parameters to System.Management.Automation.SwitchParameter and several flags to Microsoft.SqlServer.Management.Smo.DatabaseScopedConfigurationOnOff. Added runtime conversion of SwitchParameter → boolean prior to SMO assignment and updated help text with SQL Server version prerequisites.
Cmdlet: Test-SqlDscDatabaseProperty
source/Public/Test-SqlDscDatabaseProperty.ps1
Converted many boolean parameters to SwitchParameter; changed several properties (e.g., DelayedDurability, DB-scoped flags) to SMO enum types. Added SwitchParameter-to-boolean conversion for comparisons and updated examples/help to use colon-syntax for explicit false.
Unit tests + SMO stub
tests/Unit/Public/New-SqlDscDatabase.Tests.ps1, tests/Unit/Public/Set-SqlDscDatabaseProperty.Tests.ps1, tests/Unit/Public/Test-SqlDscDatabaseProperty.Tests.ps1, tests/Unit/Stubs/SMO.cs
Extended SMO stub with new enum DatabaseScopedConfigurationOnOff; added mocked SMO properties; updated unit tests to assert new New-SqlDscDatabase parameters, switch-style semantics, enum-typed properties, and adjusted IsLedger usage.
Integration tests
tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1, tests/Integration/Commands/Set-SqlDscDatabaseProperty.Integration.Tests.ps1, tests/Integration/Commands/Test-SqlDscDatabaseProperty.Integration.Tests.ps1
Added integration tests creating databases with new properties (switches, ints, enums, mixed combos); updated invocation syntax to use switches/enum values; adapted tests that previously assumed boolean TestValue for properties now handled via enum paths.
Changelog
CHANGELOG.md
Documented New-SqlDscDatabase addition and Set-/Test-SqlDscDatabaseProperty typing changes aligning parameters to SMO types and PowerShell switch semantics.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing extra attention:
    • source/Public/New-SqlDscDatabase.ps1 — parameter attributes/sets, creation-only constraints, PSBoundParameters → SMO assignments and type coercion.
    • source/Public/Set-SqlDscDatabaseProperty.ps1 & source/Public/Test-SqlDscDatabaseProperty.ps1 — SwitchParameter-to-boolean conversion and DatabaseScopedConfigurationOnOff handling.
    • tests/Unit/Stubs/SMO.cs — new enum definition and parity with runtime SMO types.
    • Unit/integration tests — adjusted invocation syntax, cleanup, and enum-based assertions.

Possibly related PRs

Pre-merge checks

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'New-SqlDscDatabase: Add more properties' clearly identifies the primary change—adding properties to the New-SqlDscDatabase function—which aligns with the changeset focusing on parameter additions and type refinements.
Description check ✅ Passed The PR description is related to the changeset, explaining that comprehensive settable database properties were added to New-SqlDscDatabase that were previously only in Set-SqlDscDatabaseProperty, with direct reference to issue #2190.
Linked Issues check ✅ Passed The PR implements the core coding objective from issue #2190 by exposing settable properties as parameters on New-SqlDscDatabase, adding boolean, integer, enum, and string parameters (e.g., BrokerEnabled, MaxDop, PageVerify, UserAccess), with corresponding property-setting logic during database creation.
Out of Scope Changes check ✅ Passed All changes are in scope: parameter additions to New-SqlDscDatabase, type corrections to align with SMO types, corresponding updates to Set-SqlDscDatabaseProperty and Test-SqlDscDatabaseProperty for consistency, updated tests, and a CHANGELOG entry—all supporting the objective of exposing additional database properties at creation time.
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 a5a2ace and 5b25222.

📒 Files selected for processing (1)
  • tests/Unit/Public/New-SqlDscDatabase.Tests.ps1 (3 hunks)

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.

Comment thread source/Public/New-SqlDscDatabase.ps1 Fixed
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
tests/Unit/Public/New-SqlDscDatabase.Tests.ps1 (2)

77-85: Mocked SMO properties and new behavior tests for additional database options look consistent.

The extra Add-Member properties on the mocked Microsoft.SqlServer.Management.Smo.Database object (AutoClose, AutoShrink, PageVerify, ReadOnly, MaxDop, TargetRecoveryTime, ContainmentType, DelayedDurability) line up with the new parameters exercised in the three added It blocks. This gives good coverage that New-SqlDscDatabase actually flows boolean, integer, and enum-style properties onto the created database object.

Two small follow‑ups to consider:

  • Ensure the SMO stubs in SMO.cs also declare these properties so the tests are aligned with the stub type surface and not only with PS-added note properties.
  • Given CatalogCollation is creation‑only, it may be worth adding a focused test that verifies it is applied at creation time (e.g., asserted on the mock before or immediately after the Create() call) to guard against accidental regressions in that special case.

Based on learnings, please double-check that the SMO stub types in SMO.cs expose the same property set and that CatalogCollation is covered by at least one behavioral test.

Also applies to: 132-159


222-267: Parameter-set validation for the Database set is pragmatic and mostly aligned with guidelines.

The updated 'Parameter validation' context now:

  • Verifies that the Database parameter set exists and has the expected core parameters (including CatalogCollation, IsLedger, FileGroup).
  • Separately checks that representative Boolean/Integer/String/Enum property parameters (e.g., AutoClose, MaxDop, ContainmentType) are present in the Database parameter set.

This is a reasonable compromise versus asserting the full ParameterListAsString, which would be unwieldy given the large number of properties. The Snapshot parameter set still uses the full string check, so the pattern is covered where it’s tractable.

If you want to make this explicit for future maintainers, consider adding a short comment above this test explaining that we intentionally validate by parameter membership instead of ParameterListAsString due to the size of the Database parameter set.

tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1 (1)

92-202: Good coverage for new properties; align cleanup with -ErrorAction 'Stop'

The new integration tests do a nice job exercising boolean (AutoClose, AutoShrink, ReadOnly), integer (TargetRecoveryTime), enum (PageVerify, UserAccess), and mixed properties during creation and verifying both the returned SMO object and the actual database.

One small consistency tweak: in the finally blocks of the new tests you call:

$null = Remove-SqlDscDatabase -DatabaseObject $dbToRemove -Force

whereas other cleanup paths in this file use -ErrorAction 'Stop'. To follow the integration-test guidelines and fail fast when cleanup cannot remove the test DB, consider:

-                    $null = Remove-SqlDscDatabase -DatabaseObject $dbToRemove -Force
+                    $null = Remove-SqlDscDatabase -DatabaseObject $dbToRemove -Force -ErrorAction 'Stop'

for each finally block.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 752efb6 and 72abc88.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • source/Public/New-SqlDscDatabase.ps1 (3 hunks)
  • tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1 (1 hunks)
  • tests/Unit/Public/New-SqlDscDatabase.Tests.ps1 (3 hunks)
🧰 Additional context used
📓 Path-based instructions (16)
**/*.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/New-SqlDscDatabase.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscDatabase.Tests.ps1
  • source/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscDatabase.Tests.ps1
  • source/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.Integration.Tests.ps1
  • CHANGELOG.md
  • tests/Unit/Public/New-SqlDscDatabase.Tests.ps1
  • source/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscDatabase.Tests.ps1
  • source/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.Integration.Tests.ps1
CHANGELOG.md

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

CHANGELOG.md: Always update the Unreleased section in CHANGELOG.md
Use Keep a Changelog format in CHANGELOG.md
Describe notable changes briefly in CHANGELOG.md, ≤2 items per change type
Reference issues using format issue #<issue_number> in CHANGELOG.md
No empty lines between list items in same section of CHANGELOG.md
Skip adding entry if same change already exists in Unreleased section of CHANGELOG.md
No duplicate sections or items in Unreleased section of CHANGELOG.md

Always update CHANGELOG.md Unreleased section

Files:

  • CHANGELOG.md

⚙️ CodeRabbit configuration file

CHANGELOG.md: # Changelog Guidelines

  • Always update the Unreleased section in CHANGELOG.md
  • Use Keep a Changelog format
  • Describe notable changes briefly, ≤2 items per change type
  • Reference issues using format issue #<issue_number>
  • No empty lines between list items in same section
  • Skip adding entry if same change already exists in Unreleased section
  • No duplicate sections or items in Unreleased section

Files:

  • CHANGELOG.md
**/*.md

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

**/*.md: Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
Use 2 spaces for indentation in Markdown files
Use '1.' for all items in ordered lists (1/1/1 numbering style)
Disable MD013 rule by adding a comment for tables/code blocks exceeding 80 characters
Empty lines required before/after code blocks and headings (except before line 1)
Escape backslashes in file paths only (not in code blocks)
Code blocks must specify language identifiers
Format parameters using bold in Markdown documentation
Format values and literals using inline code in Markdown documentation
Format resource/module/product names using italic in Markdown documentation
Format commands/files/paths using inline code in Markdown documentation

Files:

  • CHANGELOG.md

⚙️ CodeRabbit configuration file

**/*.md: # Markdown Style Guidelines

  • Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
  • Use 2 spaces for indentation
  • Use '1.' for all items in ordered lists (1/1/1 numbering style)
  • Disable MD013 rule by adding a comment for tables/code blocks exceeding 80 characters
  • Empty lines required before/after code blocks and headings (except before line 1)
  • Escape backslashes in file paths only (not in code blocks)
  • Code blocks must specify language identifiers

Text Formatting

  • Parameters: bold
  • Values/literals: inline code
  • Resource/module/product names: italic
  • Commands/files/paths: inline code

Files:

  • CHANGELOG.md
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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.ps1
🧠 Learnings (27)
📚 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/New-SqlDscDatabase.Integration.Tests.ps1
  • CHANGELOG.md
  • tests/Unit/Public/New-SqlDscDatabase.Tests.ps1
  • source/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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 : Parameter property tests should verify mandatory parameter attributes using Get-Command Parameters and Should -BeTrue assertions

Applied to files:

  • tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1
  • tests/Unit/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.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 : Avoid `ExpectedMessage` parameter for `Should -Throw` assertions in integration tests

Applied to files:

  • tests/Integration/Commands/New-SqlDscDatabase.Integration.Tests.ps1
📚 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:

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

  • CHANGELOG.md
  • tests/Unit/Public/New-SqlDscDatabase.Tests.ps1
  • source/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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: After changing SMO stub types in SMO.cs, run tests in a new PowerShell session for changes to take effect

Applied to files:

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

Applied to files:

  • tests/Unit/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.Tests.ps1
📚 Learning: 2025-09-25T16:38:08.867Z
Learnt from: johlju
Repo: dsccommunity/ActiveDirectoryDsc PR: 741
File: tests/Integration/MSFT_ADReadOnlyDomainControllerAccount.Integration.Tests.ps1:102-104
Timestamp: 2025-09-25T16:38:08.867Z
Learning: Test-DscConfiguration cmdlet returns string values 'True' or 'False', not boolean values. Therefore, Should -Be 'True' is correct, and Should -BeTrue would be incorrect for this cmdlet.

Applied to files:

  • tests/Unit/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.Tests.ps1
📚 Learning: 2025-08-16T13:22:15.230Z
Learnt from: johlju
Repo: dsccommunity/SqlServerDsc PR: 2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:78-93
Timestamp: 2025-08-16T13:22:15.230Z
Learning: In PowerShell unit tests for parameter validation in SqlServerDsc, accessing parameter attributes directly like `$cmd.Parameters['ParameterName'].Attributes.Mandatory` works correctly because PowerShell automatically iterates through the array and returns the property values. Additional filtering to ParameterAttribute is not necessary when the parameter structure is known and controlled.

Applied to files:

  • tests/Unit/Public/New-SqlDscDatabase.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/New-SqlDscDatabase.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/New-SqlDscDatabase.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 : Unused mandatory parameters in `Set-TargetResource` and `Test-TargetResource` should include "Not used in <function_name>" in the help comment

Applied to files:

  • tests/Unit/Public/New-SqlDscDatabase.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 : `Get-TargetResource` should only include parameters needed to retrieve actual current state values

Applied to files:

  • tests/Unit/Public/New-SqlDscDatabase.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} : Parameters should use full type name

Applied to files:

  • tests/Unit/Public/New-SqlDscDatabase.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). (2)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
  • GitHub Check: PSScriptAnalyzer

Comment thread CHANGELOG.md Outdated
Comment thread source/Public/New-SqlDscDatabase.ps1
Comment thread source/Public/New-SqlDscDatabase.ps1
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 30, 2025

Codecov Report

❌ Patch coverage is 56.46259% with 64 lines in your changes missing coverage. Please review.
✅ Project coverage is 94%. Comparing base (752efb6) to head (4606b94).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
source/Public/New-SqlDscDatabase.ps1 55% 64 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##           main   #2356    +/-   ##
=====================================
- Coverage    94%     94%    -1%     
=====================================
  Files       164     164            
  Lines      9563    9709   +146     
=====================================
+ Hits       9070    9152    +82     
- Misses      493     557    +64     
Flag Coverage Δ
unit 94% <56%> (-1%) ⬇️
Files with missing lines Coverage Δ
source/Public/Set-SqlDscDatabaseProperty.ps1 98% <100%> (+<1%) ⬆️
source/Public/Test-SqlDscDatabaseProperty.ps1 93% <100%> (+<1%) ⬆️
source/Public/New-SqlDscDatabase.ps1 66% <55%> (-24%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

johlju and others added 13 commits November 30, 2025 20:15
…n properties in New-SqlDscDatabase and Set-SqlDscDatabaseProperty
…se SwitchParameter for better PowerShell practices and update related tests for default values.
…ameter for boolean properties and enhance related tests for consistency and clarity.
…an properties and update related tests for consistency
…DatabaseProperty tests to use colon syntax for boolean properties
Copy link
Copy Markdown

@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

♻️ Duplicate comments (1)
source/Public/Set-SqlDscDatabaseProperty.ps1 (1)

575-578: Standardize MaxSizeInBytes type with New-/Test- commands

MaxSizeInBytes is typed as [System.Double] here, while the corresponding parameter in Test-SqlDscDatabaseProperty is [System.Int64]. For a size-in-bytes value this discrepancy is surprising and may lead to precision issues and a confusing API surface across the three commands. Consider aligning this to an integer type consistent with both SMO and the Test cmdlet, similar to the suggestion on New-SqlDscDatabase.

Confirm the .NET type of `Microsoft.SqlServer.Management.Smo.Database.MaxSizeInBytes` and ensure Set-/New-/Test-SqlDscDatabaseProperty all use the same parameter type for this property.
🧹 Nitpick comments (3)
tests/Integration/Commands/Test-SqlDscDatabaseProperty.Integration.Tests.ps1 (1)

90-92: Reclassifying these properties to the non-Boolean test path looks correct

By dropping TestValue on ParameterSniffing, LegacyCardinalityEstimation, QueryOptimizerHotfixes, and DelayedDurability, these cases no longer participate in the boolean $true/$false loop (Where-Object { $_.TestValue }) and instead are exercised by the non-Boolean tests (Where-Object { -not $_.TestValue }), which pass the actual SMO value (including enums) through to Test-SqlDscDatabaseProperty. This matches the intent if these parameters are now enum/DB-scoped configuration style rather than simple booleans, and I don’t see a functional problem.

As a small clarity tweak, you might consider moving these four entries out from under the “Boolean properties” comment or adding a note that they are logically toggle-like but tested via the non-Boolean path now.

Also applies to: 101-101

tests/Unit/Public/New-SqlDscDatabase.Tests.ps1 (1)

221-265: Parameter validation uses sample-based approach.

The parameter validation tests check for the existence of core parameters and sample parameters from each property type category. This approach validates the pattern but may not catch if individual parameters are accidentally omitted.

If more comprehensive validation is desired, consider checking all expected parameters rather than just samples. However, the current sample-based approach is acceptable for validating that the parameter set structure is correct and parameters of each type are present.

source/Public/Test-SqlDscDatabaseProperty.ps1 (1)

462-464: Update .PARAMETER UserAccess help text to use actual enum member names

The .PARAMETER UserAccess help references MULTI_USER, RESTRICTED_USER, SINGLE_USER, but the parameter accepts Microsoft.SqlServer.Management.Smo.DatabaseUserAccess enum which has members: Multiple, Single, and Restricted. Update the help text to use the actual enum member names to prevent confusion and binding surprises.

Comment thread CHANGELOG.md
Copy link
Copy Markdown
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@johlju reviewed 8 of 11 files at r2, 3 of 3 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @johlju)

@johlju johlju merged commit 9bf5f46 into dsccommunity:main Dec 1, 2025
3 of 7 checks passed
@johlju johlju deleted the fix/issue-#2190 branch December 1, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New-SqlDscDatabase: Add missing settable properties

2 participants