Skip to content

Add integration tests for Remove-SqlDscAudit command#2246

Merged
johlju merged 3 commits intomainfrom
copilot/fix-2241
Sep 17, 2025
Merged

Add integration tests for Remove-SqlDscAudit command#2246
johlju merged 3 commits intomainfrom
copilot/fix-2241

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 17, 2025

  • Analyze existing audit-related command patterns and test structure
  • Create integration tests for Remove-SqlDscAudit command following project guidelines
  • Test ServerObject parameter set functionality
  • Test AuditObject parameter set functionality
  • Test pipeline input scenarios
  • Test error handling for non-existent audits
  • Test Force parameter functionality
  • Test Refresh parameter functionality
  • Add tests to appropriate pipeline group in azure-pipelines.yml
  • Update README.md with dependency information
  • Update CHANGELOG.md with new functionality
  • Validate tests syntax and follow project standards
  • Fix dependency documentation (Remove-SqlDscAudit doesn't depend on New-SqlDscAudit tests)
  • Add required blank line at end of test file

Implementation complete! Added comprehensive integration tests for the Remove-SqlDscAudit command covering all parameter sets, pipeline scenarios, and error conditions. The tests follow the existing patterns in the project and are properly integrated into the CI pipeline.

Key features added:

  • Tests for both ServerObject and AuditObject parameter sets
  • Pipeline input support verification
  • Error handling validation for non-existent audits
  • Force and Refresh parameter testing
  • Multiple audit removal scenarios
  • Proper test cleanup and SQL Server service management

Issues addressed:

  • Corrected dependency documentation - Remove-SqlDscAudit creates its own test audits and doesn't depend on New-SqlDscAudit integration tests
  • Added required blank line at end of test file per project standards

The tests are added to Group 8 in the pipeline alongside other Remove commands and follow all project guidelines including proper CI tagging, service management, and dependency handling.

Fixes #2241.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


This change is Reviewable

Co-authored-by: johlju <7189721+johlju@users.noreply.github.com>
Copilot AI changed the title [WIP] No integration tests for Remove-SqlDscAudit Add integration tests for Remove-SqlDscAudit command Sep 17, 2025
Copilot AI requested a review from johlju September 17, 2025 10:13
@johlju
Copy link
Copy Markdown
Member

johlju commented Sep 17, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 17, 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.

@coderabbitai
Copy link
Copy Markdown

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

Adds a new integration test for Remove-SqlDscAudit, updates CI to include it in the SQL Server Commands integration test roster, and documents the addition in CHANGELOG and the Commands integration test README.

Changes

Cohort / File(s) Summary
Integration tests
tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1
New Pester integration suite for Remove-SqlDscAudit covering ServerObject/AuditObject parameter sets, pipeline scenarios, error handling, and multi-audit removal with setup/teardown on DSCSQLTEST instance.
CI/test orchestration
azure-pipelines.yml
Added the new test path tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1 to the SQL Server Commands integration test list (Group 8).
Docs
CHANGELOG.md, tests/Integration/Commands/README.md
CHANGELOG Unreleased entry noting added integration tests for Remove-SqlDscAudit (#2241). README run-order table updated to include Remove-SqlDscAudit with its dependency on New-SqlDscAudit.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Pre-merge checks

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Add integration tests for Remove-SqlDscAudit command" is concise and accurately summarizes the primary change in the changeset (new integration tests for Remove-SqlDscAudit and related CI/docs updates), making it clear to reviewers what the PR delivers. It is specific, on-topic, and matches the added test file and pipeline/readme/changelog modifications.
Linked Issues Check ✅ Passed The changes satisfy the primary coding objective of issue [#2241] by adding tests (tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1) that cover both parameter sets, pipeline scenarios, Force/Refresh behavior, error handling, and multiple removals, and by integrating the test into CI and updating README/CHANGELOG; there are no public API or signature changes. These artifacts implement the requested integration test coverage and follow the project's testing and CI patterns.
Out of Scope Changes Check ✅ Passed All modified files are test, CI, and documentation artifacts (new integration test script, azure-pipelines.yml entry, README and CHANGELOG updates); no unrelated production code or public API changes were introduced, so I detect no out-of-scope changes.
Description Check ✅ Passed The PR description clearly documents the implemented integration tests, the CI pipeline addition, README and CHANGELOG updates, test coverage goals, and references Fixes #2241, so it is directly related to the changeset and provides adequate context for reviewers. The level of detail is sufficient for this lenient check.
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.

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

🧹 Nitpick comments (4)
tests/Integration/Commands/README.md (1)

82-82: Fix dependency listing for Remove-SqlDscAudit.

The new Remove-SqlDscAudit tests create and remove their own audits; they don’t depend on New-SqlDscAudit. Update “Depends on #” to “-” (or “1 (Install-SqlDscServer)” if you want to express the baseline instance requirement).

Apply this diff:

-Remove-SqlDscAudit | 8 | 2 (New-SqlDscAudit) | DSCSQLTEST | -
+Remove-SqlDscAudit | 8 | - | DSCSQLTEST | -
tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1 (3)

38-38: Remove unused variable.

$script:mockComputerName is never used.

Apply this diff:

-        $script:mockComputerName = Get-ComputerName

45-45: Prefer specifying ServerName for clarity and consistency.

Explicitly set -ServerName (Get-ComputerName) when connecting.

Apply this diff:

-        $script:serverObject = Connect-SqlDscDatabaseEngine -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential -ErrorAction Stop
+        $script:serverObject = Connect-SqlDscDatabaseEngine -ServerName (Get-ComputerName) -InstanceName $script:mockInstanceName -Credential $script:mockSqlAdminCredential -ErrorAction 'Stop'

58-60: Strengthen uniqueness of transient names.

Using GUIDs avoids rare collisions from Get-Random, especially in parallel runs.

Apply this diff:

-            $script:testAuditName = 'SqlDscTestRemoveAudit_' + (Get-Random)
+            $script:testAuditName = "SqlDscTestRemoveAudit_$([guid]::NewGuid().ToString('N'))"
@@
-            $script:testAuditNameForObject = 'SqlDscTestRemoveAuditObj_' + (Get-Random)
+            $script:testAuditNameForObject = "SqlDscTestRemoveAuditObj_$([guid]::NewGuid().ToString('N'))"
@@
-            $script:testAuditNameForPipeline = 'SqlDscTestRemoveAuditPipe_' + (Get-Random)
+            $script:testAuditNameForPipeline = "SqlDscTestRemoveAuditPipe_$([guid]::NewGuid().ToString('N'))"
@@
-            $script:testAuditNames = @(
-                'SqlDscTestMultiRemove1_' + (Get-Random),
-                'SqlDscTestMultiRemove2_' + (Get-Random)
-            )
+            $script:testAuditNames = @(
+                "SqlDscTestMultiRemove1_$([guid]::NewGuid().ToString('N'))",
+                "SqlDscTestMultiRemove2_$([guid]::NewGuid().ToString('N'))"
+            )

Also applies to: 97-99, 129-131, 151-159

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a4bba5 and fde0777.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • azure-pipelines.yml (1 hunks)
  • tests/Integration/Commands/README.md (1 hunks)
  • tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**

⚙️ 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-SqlDscAudit.Integration.Tests.ps1
  • tests/Integration/Commands/README.md
  • CHANGELOG.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-SqlDscAudit.Integration.Tests.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-SqlDscAudit.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-SqlDscAudit.Integration.Tests.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:

  • tests/Integration/Commands/README.md
  • CHANGELOG.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 (21)
📓 Common learnings
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)
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
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
📚 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-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-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-SqlDscAudit.Integration.Tests.ps1
  • 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/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-SqlDscAudit.Integration.Tests.ps1
  • 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 : When invoking commands in integration tests, pass -Force where applicable to avoid prompts

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscAudit.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 : 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-SqlDscAudit.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 : All public commands and class-based resources must have integration tests

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscAudit.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 : After Connect-SqlDscDatabaseEngine, integration tests must call Disconnect-SqlDscDatabaseEngine

Applied to files:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscAudit.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 : Use -ErrorAction Stop on commands so failures surface immediately

Applied to files:

  • azure-pipelines.yml
📚 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-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:

  • azure-pipelines.yml
  • tests/Integration/Commands/Remove-SqlDscAudit.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-SqlDscAudit.Integration.Tests.ps1
📚 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-SqlDscAudit.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-SqlDscAudit.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 : 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-SqlDscAudit.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 requiring SQL Server DB must start the Windows service in BeforeAll and stop it in AfterAll

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscAudit.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 : In BeforeAll, set $script:moduleName and Import-Module -Name $script:moduleName -Force -ErrorAction Stop

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscAudit.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 : Define variables for -ForEach in a separate BeforeDiscovery near usage

Applied to files:

  • tests/Integration/Commands/Remove-SqlDscAudit.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-SqlDscAudit.Integration.Tests.ps1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: PSScriptAnalyzer
  • GitHub Check: PSScriptAnalyzer
  • GitHub Check: PSScriptAnalyzer
  • GitHub Check: PSScriptAnalyzer
  • GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test Unit)
  • GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test HQRM)
  • GitHub Check: dsccommunity.SqlServerDsc (Quality Test and Unit Test Determine DSC Resource Test Requirements)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
  • GitHub Check: dsccommunity.SqlServerDsc
🔇 Additional comments (3)
CHANGELOG.md (1)

8-13: LGTM: Unreleased changelog entry is correct and compliant.

Entry follows Keep a Changelog format, references the issue, and stays concise.

azure-pipelines.yml (1)

331-331: LGTM: Added test path in Group 8.

Placement matches the Group-8 teardown phase. No pipeline structure issues spotted.

tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1 (1)

48-53: Verify downstream tests aren't relying on the DSCSQLTEST service state.

Search of tests/Integration/Commands/Remove-*.Integration.Tests.ps1 found no explicit Start-Service/Stop-Service calls for 'MSSQL$DSCSQLTEST'. Confirm Group‑8/later tests or shared setup explicitly start the service; otherwise change this test's AfterAll to restore the prior state instead of stopping the service. Location: tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1 — AfterAll (lines 48–53).

Comment thread tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1
@codecov
Copy link
Copy Markdown

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 (356df9c).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #2246   +/-   ##
====================================
  Coverage    94%     94%           
====================================
  Files       149     149           
  Lines      9163    9163           
====================================
  Hits       8687    8687           
  Misses      476     476           
Flag Coverage Δ
unit 94% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/Integration/Commands/README.md Outdated
Comment thread tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1 Outdated
Co-authored-by: johlju <7189721+johlju@users.noreply.github.com>
Copilot AI requested a review from johlju September 17, 2025 12:53
@johlju johlju marked this pull request as ready for review September 17, 2025 12:58
@johlju johlju requested a review from a team as a code owner September 17, 2025 12:58
@johlju johlju merged commit 7d8be55 into main Sep 17, 2025
24 of 26 checks passed
@johlju johlju deleted the copilot/fix-2241 branch September 17, 2025 15:27
Comment thread tests/Integration/Commands/Remove-SqlDscAudit.Integration.Tests.ps1
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.

No integration tests for Remove-SqlDscAudit

2 participants