Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 17, 2025

  • Analyze the problem statement and understand the missing integration test
  • Examine existing Remove-SqlDscTraceFlag command and related trace flag commands
  • Study integration test patterns from similar Remove commands
  • Create comprehensive integration test file with 6 test cases covering:
    • Single trace flag removal using ServerName/InstanceName parameters
    • Multiple trace flag removal using ServerName/InstanceName parameters
    • Handling of non-existent trace flags (should not error)
    • Preserving other trace flags when removing specific ones
    • Single trace flag removal using ServiceObject parameter
    • Multiple trace flag removal using ServiceObject parameter
  • Add integration test to Group 8 in azure-pipelines.yml for proper CI execution
  • Update CHANGELOG.md with entry for the new integration test
  • Update tests/Integration/Commands/README.md to document the new integration test
  • Fix parameter binding error in Add-SqlDscTraceFlag and Remove-SqlDscTraceFlag by using Remove-CommonParameter
  • Add proper blank line at end of integration test file according to style guidelines
  • Validate syntax and build success

The integration test ensures Remove-SqlDscTraceFlag command reliability by testing all parameter sets and edge cases, addressing issue #2239. Fixed parameter binding error that was causing integration test failures by replacing manual parameter removal with the proper Remove-CommonParameter function from DscResource.Common. File formatting now follows project style guidelines with proper line endings.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


This change is Reviewable

@johlju
Copy link
Member

johlju commented Sep 17, 2025

@copilot try again, must have been temporary glitch that made your work progress fail

Copy link
Contributor Author

Copilot AI commented Sep 17, 2025

@copilot try again, must have been temporary glitch that made your work progress fail

I've successfully created the missing integration test for Remove-SqlDscTraceFlag. The integration test includes comprehensive coverage with 6 test cases testing both parameter sets (ServerName/InstanceName and ServiceObject), edge cases, and proper trace flag management. The test has been added to Group 8 in the pipeline and the build validates successfully. Commit: 93ba4c2

Copilot AI changed the title [WIP] Integration test missing for Remove-SqlDscTraceFlag Add integration test for Remove-SqlDscTraceFlag Sep 17, 2025
@johlju
Copy link
Member

johlju commented Sep 17, 2025

@copilot also update the README.md file under tests/Integration/Commands

Copy link
Contributor Author

Copilot AI commented Sep 17, 2025

@copilot also update the README.md file under tests/Integration/Commands

I've updated the README.md file under tests/Integration/Commands to include the new Remove-SqlDscTraceFlag integration test in the dependency table with run order 8, depending on run order 1 (Install-SqlDscServer), using the DSCSQLTEST instance. Commit: 22bfdd9

@codecov
Copy link

codecov bot commented Sep 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (371314d) to head (d769033).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #2245   +/-   ##
====================================
  Coverage    94%     94%           
====================================
  Files       149     149           
  Lines      9163    9163           
====================================
  Hits       8687    8687           
  Misses      476     476           
Flag Coverage Δ
unit 94% <100%> (ø)
Files with missing lines Coverage Δ
source/Public/Add-SqlDscTraceFlag.ps1 96% <100%> (-1%) ⬇️
source/Public/Remove-SqlDscTraceFlag.ps1 96% <100%> (+<1%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI requested a review from johlju September 17, 2025 14:37
@coderabbitai
Copy link

coderabbitai bot commented Sep 17, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Updates documentation and CI to standardize test execution, extends integration test coverage for trace flags, fixes parameter-binding in Add-/Remove-SqlDscTraceFlag, corrects a property typo, and documents changes in the changelog. Adds a new integration test file and updates test lists and README. No public API changes.

Changes

Cohort / File(s) Summary
Guidelines
.github/instructions/SqlServerDsc-guidelines.instructions.md
Tightened guidance: mandate running PowerShell scripts from terminal at repo root; removed prior build/test step list; added coverage command example using Invoke-PesterJob with -EnableSourceLineMapping and -FilterCodeCoverageResult.
Changelog
CHANGELOG.md
Documented integration tests for Remove-SqlDscTraceFlag and Remove-SqlDscAudit; noted parameter-binding fix for Add-/Remove-SqlDscTraceFlag using Remove-CommonParameter; removed two unrelated previous “Fixed” entries.
Pipeline config
azure-pipelines.yml
Included new integration tests: Commands/Remove-SqlDscTraceFlag and Resources/DSC_SqlTraceFlag in respective test groups; no flow or API changes.
Public functions (TraceFlag)
source/Public/Add-SqlDscTraceFlag.ps1, source/Public/Remove-SqlDscTraceFlag.ps1
Reworked parameter handling to use Remove-CommonParameter over @{} + $PSBoundParameters; removed PSCmdlet.OptionalCommonParameters usage; explicitly exclude Force, TraceFlag; corrected property name TraceFLag → TraceFlag; preserved ShouldProcess and error handling.
Integration tests (Commands)
tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
New tests for Remove-SqlDscTraceFlag covering ServerName/InstanceName and ServiceObject paths; adds add-remove scenarios, non-existent flag handling, and cleanup; includes dependency bootstrap for DscResource.Test and module import.
Integration tests README
tests/Integration/Commands/README.md
Added Remove-SqlDscTraceFlag to run order; expanded SSRS/PBIRS test entries and dependencies; documentation-only.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as Caller (Tests/Users)
  participant A as Add-SqlDscTraceFlag
  participant R as Remove-SqlDscTraceFlag
  participant RC as Remove-CommonParameter
  participant S as SQL Service/Instance

  rect rgba(230,240,255,0.5)
    note over A,R: Updated parameter handling
  end

  U->>A: Invoke with params (Force, TraceFlag, ...)
  A->>RC: Sanitize PSBoundParameters
  RC-->>A: Clean hashtable (no common params)
  A->>S: Get current trace flags
  A->>S: Set desired TraceFlag(s)
  S-->>U: Result

  U->>R: Invoke with params (Force, TraceFlag, ...)
  R->>RC: Sanitize PSBoundParameters
  RC-->>R: Clean hashtable (no common params)
  R->>S: Get current trace flags
  R->>S: Remove specified TraceFlag(s)
  S-->>U: Result

  note right of R: Corrected property name<br/>TraceFlag (was TraceFLag)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Add integration test for Remove-SqlDscTraceFlag" accurately and concisely describes the primary change in the PR — the addition of a new integration test for that command — and is specific and clear enough for reviewers scanning history; ancillary fixes (parameter-binding and docs) do not make the title misleading.
Description Check ✅ Passed The pull request description is detailed and directly related to the changeset, enumerating the added integration tests, CI and README/CHANGELOG updates, the parameter-binding fix, and validation steps, and it matches the file-level summaries and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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

@johlju johlju marked this pull request as ready for review September 17, 2025 15:15
@johlju johlju requested a review from a team as a code owner September 17, 2025 15:15
Copy link
Member

@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 3 of 4 files at r5, 4 of 4 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @copilot)

@johlju
Copy link
Member

johlju commented Sep 18, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Sep 18, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

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

⚠️ Outside diff range comments (1)
tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1 (1)

1-160: Remove trailing whitespace (linter failure)

tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1 — remove trailing whitespace on lines 102 and 107.

🧹 Nitpick comments (7)
.github/instructions/SqlServerDsc-guidelines.instructions.md (1)

8-14: Fix MD032: add blank line after heading before the list.

markdownlint flagged “lists should be surrounded by blank lines.” Insert one blank line after the “## Build & Test Workflow Requirements” heading.

 ## Build & Test Workflow Requirements
- - Never use VS Code task, always use PowerShell scripts via terminal, from repository root
+
+ - Never use VS Code task, always use PowerShell scripts via terminal, from repository root
CHANGELOG.md (1)

17-18: Unify issue link formatting and code‑style for identifiers.

For consistency with lines 11–13, wrap the issue link in parentheses and format identifiers as code.

-  - Fixed parameter binding error that occurred when ErrorAction was specified both explicitly and via PSBoundParameters by using Remove-CommonParameter instead of manual parameter removal [issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)
+  - Fixed parameter binding error when `ErrorAction` was specified both explicitly and via `PSBoundParameters` by using `Remove-CommonParameter` instead of manual parameter removal ([issue #2239](https://github.com/dsccommunity/SqlServerDsc/issues/2239)).
source/Public/Add-SqlDscTraceFlag.ps1 (1)

115-124: Optional: de‑duplicate desired flags to avoid repeats.

If callers pass duplicate values (e.g., -TraceFlag 4199,4199), duplicates can flow through. Consider uniquing.

-        $desiredTraceFlags = [System.UInt32[]] $currentTraceFlags + @(
-            $TraceFlag |
-                ForEach-Object -Process {
-                    # Add only when it does not already exist.
-                    if ($_ -notin $currentTraceFlags)
-                    {
-                        $_
-                    }
-                }
-        )
+        $desiredTraceFlags = @($currentTraceFlags + $TraceFlag) |
+            Sort-Object -Unique
+        $desiredTraceFlags = [System.UInt32[]] $desiredTraceFlags
source/Public/Remove-SqlDscTraceFlag.ps1 (1)

115-127: Optional: short‑circuit when no effective change.

Skip the Set call if removal results in no difference.

         if ($currentTraceFlags)
         {
             # Must always return an array. An empty array when removing the last value.
             $desiredTraceFlags = [System.UInt32[]] @(
                 $currentTraceFlags |
                     ForEach-Object -Process {
                         # Keep values that should not be removed.
                         if ($_ -notin $TraceFlag)
                         {
                             $_
                         }
                     }
             )
+
+            if (-not (Compare-Object -ReferenceObject $currentTraceFlags -DifferenceObject $desiredTraceFlags))
+            {
+                Write-Debug -Message $script:localizedData.TraceFlag_Remove_NoChange
+                return
+            }
tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1 (3)

4-24: Fix the recovery hint to use -Tasks 'noop' (not 'build').
Guidelines say the fallback message should instruct running ResolveDependency with 'noop'.

Apply this diff:

-        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks build" first.'
+        throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'

32-41: Nit: rename 'mock' vars to 'test' to avoid confusion with mocking.**
They aren’t mocks; clearer names aid readability.


1-160: Optional: add a Describe-level AfterAll safety cleanup.
Best-effort final cleanup reduces flakiness if a prior It fails mid-way.

Happy to propose a small AfterAll that removes any of the test flags via both parameter sets.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8be55 and 8833d14.

📒 Files selected for processing (7)
  • .github/instructions/SqlServerDsc-guidelines.instructions.md (1 hunks)
  • CHANGELOG.md (1 hunks)
  • azure-pipelines.yml (1 hunks)
  • source/Public/Add-SqlDscTraceFlag.ps1 (2 hunks)
  • source/Public/Remove-SqlDscTraceFlag.ps1 (2 hunks)
  • tests/Integration/Commands/README.md (1 hunks)
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**

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

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
  • source/Public/Remove-SqlDscTraceFlag.ps1
  • source/Public/Add-SqlDscTraceFlag.ps1
  • CHANGELOG.md
  • tests/Integration/Commands/README.md
{**/*.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/Remove-SqlDscTraceFlag.Integration.Tests.ps1
  • source/Public/Remove-SqlDscTraceFlag.ps1
  • source/Public/Add-SqlDscTraceFlag.ps1
**/*.[Tt]ests.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)
  • 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

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, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModuleSc...

Files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.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/Remove-SqlDscTraceFlag.Integration.Tests.ps1
source/**/*.ps1

⚙️ CodeRabbit configuration file

source/**/*.ps1: # Localization Guidelines

Requirements

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

String Files

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

Key Naming Patterns

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

String Format

ConvertFrom-StringData @'
    KeyName = Message with {0} placeholder. (PREFIX0001)
'@

String IDs

  • Format: (PREFIX####)
  • PREFIX: First letter of each word in class or function name (SqlSetup → SS, Get-SqlDscDatabase → GSDD)
  • Number: Sequential from 0001

Usage

Write-Verbose -Message ($script:localizedData.KeyName -f $value1)

Files:

  • source/Public/Remove-SqlDscTraceFlag.ps1
  • source/Public/Add-SqlDscTraceFlag.ps1
**/*.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/Integration/Commands/README.md
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
🧠 Learnings (38)
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Add integration tests for all public commands (and resources)

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
  • tests/Integration/Commands/README.md
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to azure-pipelines.yml : Add all integration test script files to a group within the test stage in ./azure-pipelines.yml

Applied to files:

  • azure-pipelines.yml
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/Commands/*.[iI]ntegration.[tT]ests.ps1 : Place command integration tests at tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
  • tests/Integration/Commands/README.md
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to azure-pipelines.yml : Choose the appropriate integration test group number in the pipeline based on required dependencies

Applied to files:

  • azure-pipelines.yml
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : When invoking commands in integration tests, pass -Force where applicable to avoid prompts

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Place integration tests for public commands in tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Applied to files:

  • azure-pipelines.yml
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to tests/Integration/**/*.ps1 : After Connect-SqlDscDatabaseEngine, integration tests must call Disconnect-SqlDscDatabaseEngine

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to tests/Integration/**/*.ps1 : Integration tests must use Connect-SqlDscDatabaseEngine with correct CI credentials to create SQL Server DB sessions

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • tests/Integration/Commands/README.md
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Use -ErrorAction Stop on commands so failures surface immediately

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Add unit tests for all commands, functions, and resources

Applied to files:

  • azure-pipelines.yml
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/Resources/*.[iI]ntegration.[tT]ests.ps1 : Place resource integration tests at tests/Integration/Resources/{ResourceName}.Integration.Tests.ps1

Applied to files:

  • azure-pipelines.yml
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : In BeforeDiscovery, ensure DscResource.Test is available; if not loaded or not available, run build.ps1 -Tasks 'noop' (suppressing non-error streams) and Import-Module 'DscResource.Test' -Force -ErrorAction Stop

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to tests/Unit/**/*.ps1 : Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-16T16:34:44.689Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:34:44.689Z
Learning: Applies to tests/[Uu]nit/**/*.[Tt]ests.ps1 : Include the exact Pester setup block before Describe: SuppressMessage attribute with param (); BeforeDiscovery to ensure DscResource.Test is available (fallback to build.ps1 -Tasks 'noop') and Import-Module; BeforeAll to set $script:moduleName, import the module, and set PSDefaultParameterValues for InModuleScope/Mock/Should; AfterAll to remove those defaults and unload the tested module

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : At the top of each integration test file, include SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments') with an empty justification parameter and param ()

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:32:58.363Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-09-16T16:32:58.363Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using ExpectedMessage with Should -Throw assertions

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:34:27.319Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Use line endings as defined by .gitattributes policy

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:34:27.319Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1,psd1} : No trailing whitespace on any line

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:34:27.319Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1,psd1} : End files with exactly one blank line

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:34:27.319Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1,psd1} : No spaces on empty lines

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Applies to **/*.ps1 : Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to tests/Integration/**/*.ps1 : Integration tests requiring SQL Server DB must start the Windows service in BeforeAll and stop it in AfterAll

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to tests/**/*.ps1 : When referencing CI SQL instances in tests, use: Database Engine=DSCSQLTEST, Reporting Services=SSRS, Power BI Report Server=PBIRS

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • tests/Integration/Commands/README.md
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define variables for -ForEach in a separate BeforeDiscovery near usage

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Perform mocking in BeforeAll (use BeforeEach only when required)

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
📚 Learning: 2025-09-12T13:20:57.155Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-09-12T13:20:57.155Z
Learning: Applies to source/DSCResources/**/*.psm1 : Get-TargetResource: remove non-mandatory parameters that are never used

Applied to files:

  • source/Public/Remove-SqlDscTraceFlag.ps1
  • source/Public/Add-SqlDscTraceFlag.ps1
📚 Learning: 2025-09-14T19:15:59.918Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-14T19:15:59.918Z
Learning: SqlServerDsc-specific guidelines and requirements override general project guidelines and requirements

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-16T16:34:27.319Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1} : .NOTES only if critical (constraints, side effects, security, version compatibility, breaking behavior), ≤2 short sentences

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-16T16:34:27.319Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1} : Avoid global variables (exception: $global:DSCMachineStatus)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-16T16:34:27.319Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-16T16:34:27.319Z
Learning: Applies to **/*.{ps1,psm1} : No commented-out code

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to build.ps1 : Setup build and test environment once per pwsh session using: ./build.ps1 -Tasks noop

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Build the project before running tests using ./build.ps1 -Tasks build

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-14T19:16:56.215Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-09-14T19:16:56.215Z
Learning: Applies to build.ps1 : Build the project before running tests using: ./build.ps1 -Tasks build

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#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:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-16T16:35:31.909Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-16T16:35:31.909Z
Learning: Setup build and test environment once per pwsh session using ./build.ps1 -Tasks noop

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.054Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.054Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
🪛 markdownlint-cli2 (0.17.2)
.github/instructions/SqlServerDsc-guidelines.instructions.md

9-9: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

⏰ 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). (1)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
🔇 Additional comments (10)
CHANGELOG.md (1)

10-13: LGTM: Added tests entries read well and follow style.

Entries for Remove-SqlDscTraceFlag and Remove-SqlDscAudit are concise, correctly linked, and under the proper “Added” section.

tests/Integration/Commands/README.md (1)

80-87: LGTM: Matrix updated with correct dependencies.

Remove-SqlDscTraceFlag listed in run order 8, depending on Install-SqlDscServer. Matches pipeline grouping.

source/Public/Add-SqlDscTraceFlag.ps1 (2)

98-106: Good switch to Remove-CommonParameter and explicit filtering.

This prevents duplicate common-parameter binding issues and isolates the Get path cleanly.


133-136: Confirm Set-SqlDscTraceFlag parameter surface wrt Force.

$setSqlDscTraceFlagParameters still contains Force. If Set-SqlDscTraceFlag does not accept -Force, binding will error. If it does, all good. Please verify and, if needed, remove it before invocation:

 $setSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
+$null = $setSqlDscTraceFlagParameters.Remove('Force')
 $setSqlDscTraceFlagParameters.TraceFlag = $desiredTraceFlags
source/Public/Remove-SqlDscTraceFlag.ps1 (2)

98-106: Good parameter sanitization for the Get path.

Using Remove-CommonParameter plus explicit removal avoids accidental forwarding of unsupported params.


136-139: Confirm Set-SqlDscTraceFlag accepts Force; remove if not.

As in Add‑, ensure -Force is valid for Set-SqlDscTraceFlag. If not, drop it before invocation to avoid binding errors.

 $setSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters
+$null = $setSqlDscTraceFlagParameters.Remove('Force')
 $setSqlDscTraceFlagParameters.TraceFlag = $desiredTraceFlags
azure-pipelines.yml (1)

329-336: LGTM — Remove-SqlDscTraceFlag test wired into Group 8 (pre-uninstall).

Verified tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1 exists and is referenced in azure-pipelines.yml at line 335.

tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1 (3)

1-3: Header block conforms to integration test template.
SuppressMessage + empty param block look good.


26-30: Module import setup LGTM.
Imports tested module with -Force and -ErrorAction Stop.


151-157: Assertions on results look good.
Validates removal across all flags.

…en no effective change occurs; update related test and string resources.
- Modified multiple test scripts to change the error message for missing module dependencies.
- Updated the instructions to run ".\build.ps1 -ResolveDependency -Tasks noop" instead of the previous "build" task.
Copy link
Member

@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 236 of 236 files at r8, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @copilot)

@johlju johlju merged commit 52e707f into main Sep 19, 2025
40 of 43 checks passed
@johlju johlju deleted the copilot/fix-2239 branch September 19, 2025 09:33
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.

2 participants