-
Notifications
You must be signed in to change notification settings - Fork 227
Add integration test for Remove-SqlDscTraceFlag #2245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@copilot try again, must have been temporary glitch that made your work progress fail |
Co-authored-by: johlju <[email protected]>
I've successfully created the missing integration test for |
|
@copilot also update the README.md file under tests/Integration/Commands |
Co-authored-by: johlju <[email protected]>
I've updated the README.md file under tests/Integration/Commands to include the new |
tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2245 +/- ##
====================================
Coverage 94% 94%
====================================
Files 149 149
Lines 9163 9163
====================================
Hits 8687 8687
Misses 476 476
🚀 New features to boost your workflow:
|
…raceFlag Co-authored-by: johlju <[email protected]>
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughUpdates 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
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Pre-merge checks✅ Passed checks (3 passed)
Comment |
tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
tests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
Co-authored-by: johlju <[email protected]>
johlju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johlju reviewed 3 of 4 files at r5, 4 of 4 files at r7, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @copilot)
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this 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 rootCHANGELOG.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[]] $desiredTraceFlagssource/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
📒 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 GuidelinesTerminology
- 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
pwshsession):./build.ps1 -Tasks noop- Build project before running tests:
./build.ps1 -Tasks build- Always run tests in new
pwshsession:Invoke-Pester -Path @({test paths}) -Output DetailedFile 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.ps1Requirements
- 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.ymltests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1source/Public/Remove-SqlDscTraceFlag.ps1source/Public/Add-SqlDscTraceFlag.ps1CHANGELOG.mdtests/Integration/Commands/README.md
{**/*.ps1,**/*.psm1,**/*.psd1}
⚙️ CodeRabbit configuration file
{**/*.ps1,**/*.psm1,**/*.psd1}: # PowerShell GuidelinesNaming
- 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.ps1format (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 arrayHashtables
- 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.ps1source/Public/Remove-SqlDscTraceFlag.ps1source/Public/Add-SqlDscTraceFlag.ps1
**/*.[Tt]ests.ps1
⚙️ CodeRabbit configuration file
**/*.[Tt]ests.ps1: # Tests GuidelinesCore 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
Describeblocks- Assertions only in
Itblocks- Never test verbose messages, debug messages or parameter binding behavior
- Pass all mandatory parameters to avoid prompts
Requirements
- Inside
Itblocks, assign unused return objects to$null(unless part of pipeline)- Tested entity must be called from within the
Itblocks- Keep results and assertions in same
Itblock- Avoid try-catch-finally for cleanup, use
AfterAllorAfterEach- Avoid unnecessary remove/recreate cycles
Naming
- One
Describeblock per file matching the tested entity nameContextdescriptions start with 'When'Itdescriptions 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
Contextblock- Each scenario = separate
Contextblock- Use nested
Contextblocks for complex scenarios- Mocking in
BeforeAll(BeforeEachonly when required)- Setup/teardown in
BeforeAll,BeforeEach/AfterAll,AfterEachclose to usageSyntax Rules
- PascalCase:
Describe,Context,It,Should,BeforeAll,BeforeEach,AfterAll,AfterEach- Use
-BeTrue/-BeFalsenever-Be $true/-Be $false- Never use
Assert-MockCalled, useShould -Invokeinstead- No
Should -Not -Throw- invoke commands directly- Never add an empty
-MockWithblock- Omit
-MockWithwhen returning$null- Set
$PSDefaultParameterValuesforMock:ModuleName,Should:ModuleName,InModuleScope:ModuleName- Omit
-ModuleNameparameter on Pester commands- Never use
Mockinside `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 GuidelinesRequirements
- 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-ComputerNamefor computer names in CI- Avoid
ExpectedMessageforShould -Throwassertions- Only run integration tests in CI unless explicitly instructed.
- Call commands with
-Forceparameter where applicable (avoids prompting).- Use
-ErrorAction Stopon commands so failures surface immediatelyRequired 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 GuidelinesRequirements
- Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
- Use localized string keys, not hardcoded strings
- Assume
$script:localizedDatais availableString Files
- Commands/functions:
source/en-US/{MyModuleName}.strings.psd1- Class resources:
source/en-US/{ResourceClassName}.strings.psd1Key Naming Patterns
- Format:
Verb_FunctionName_Action(underscore separators), e.g.Get_Database_ConnectingToDatabaseString 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.ps1source/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
MD013rule 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.mdtests/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.ymltests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1tests/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.ymltests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1tests/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.ymltests/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.ymltests/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.ymltests/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.ymltests/Integration/Commands/Remove-SqlDscTraceFlag.Integration.Tests.ps1.github/instructions/SqlServerDsc-guidelines.instructions.mdtests/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.ymltests/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.mdtests/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.ps1source/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-SqlDscTraceFlaglisted 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.
$setSqlDscTraceFlagParametersstill containsForce. IfSet-SqlDscTraceFlagdoes 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 = $desiredTraceFlagssource/Public/Remove-SqlDscTraceFlag.ps1 (2)
98-106: Good parameter sanitization for the Get path.Using
Remove-CommonParameterplus explicit removal avoids accidental forwarding of unsupported params.
136-139: Confirm Set-SqlDscTraceFlag accepts Force; remove if not.As in Add‑, ensure
-Forceis valid forSet-SqlDscTraceFlag. If not, drop it before invocation to avoid binding errors.$setSqlDscTraceFlagParameters = Remove-CommonParameter -Hashtable $PSBoundParameters +$null = $setSqlDscTraceFlagParameters.Remove('Force') $setSqlDscTraceFlagParameters.TraceFlag = $desiredTraceFlagsazure-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.
johlju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johlju reviewed 236 of 236 files at r8, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @copilot)
The integration test ensures
Remove-SqlDscTraceFlagcommand 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