Skip to content

Conversation

@johlju
Copy link
Member

@johlju johlju commented Aug 13, 2025

Pull Request (PR) description

  • Make sure tests forcibly imports the module being tested to avoid AI failing
    when testing changes.

This Pull Request (PR) fixes the following issues

None.

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

@johlju johlju requested a review from a team as a code owner August 13, 2025 17:51
@coderabbitai
Copy link

coderabbitai bot commented Aug 13, 2025

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

45 files out of 152 files are above the max files limit of 100. Please upgrade to Pro plan to get higher limits.

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

Walkthrough

Updated CHANGELOG with Copilot workflow notes and a new public command (Assert-SqlDscLogin). Across integration and unit tests, changed Import-Module calls to include -Force to ensure module reload during test setup. No public/exported signatures were altered in tests.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Added Unreleased notes: GitHub Copilot workflow setup/wording tweaks; added public command Assert-SqlDscLogin; test guidance to forcibly import modules.
Integration tests: force module reload
tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1
In BeforeAll, changed Import-Module to use -Force to reload the module if already loaded.
Unit tests (Classes): force module reload
tests/Unit/Classes/*.Tests.ps1 (e.g., DatabasePermission, ServerPermission, SqlAudit, SqlDatabasePermission, SqlPermission, SqlRSSetup, SqlReason, SqlResourceBase, StartupParameters)
In BeforeAll, added -Force to Import-Module to force module re-import.
Unit tests (Private): force module reload
tests/Unit/Private/*.Tests.ps1 (e.g., Assert-Feature, Assert-ManagedServiceType, Assert-SetupActionProperties, ConvertFrom-ManagedServiceType, ConvertTo-ManagedServiceType, ConvertTo-RedactedText, Get-FileVersionInformation, Get-SMOModuleCalculatedVersion, Invoke-ReportServerSetupAction, Invoke-SetupAction)
In BeforeAll, added -Force to Import-Module to force module re-import.
Unit tests (Public): force module reload
tests/Unit/Public/*.Tests.ps1 (e.g., Add-SqlDscNode, Add-SqlDscTraceFlag, Assert-SqlDscLogin, Complete-SqlDscFailoverCluster, Complete-SqlDscImage, Connect-SqlDscDatabaseEngine, ConvertFrom-*, ConvertTo-*, Disable-*, Disconnect-*, Enable-*, Get-*, Import-*, Initialize-*, Install-*, Invoke-*, New-*, Remove-*, Repair-*, Save-*, Set-*, Test-*, Uninstall-*)
In BeforeAll, added -Force to Import-Module to force module re-import across all listed tests.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant PS as PowerShell
  participant Mod as SqlServerDsc Module
  participant Cmd as Assert-SqlDscLogin
  participant Helper as Test-SqlDscIsLogin
  participant SQL as SQL Server

  User->>PS: Run Assert-SqlDscLogin -Principal ...
  PS->>Mod: Invoke command
  Mod->>Cmd: Execute
  Cmd->>Helper: Validate principal is login
  Helper->>SQL: Check login existence
  SQL-->>Helper: Exists?/Not found
  Helper-->>Cmd: True/False
  alt Login exists
    Cmd-->>PS: Return success
  else Missing
    Cmd-->>PS: Throw terminating, localized error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–25 minutes

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🔭 Outside diff range comments (19)
tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1 (1)

73-76: Replace backtick line continuation with parentheses

Our guidelines state to never use backtick for line continuation. Use parentheses for implicit continuation and readability.

-            Mock -CommandName New-Object -ParameterFilter {
-                $TypeName -eq 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' `
-                -and $ArgumentList -eq 'localhost'
-            } -MockWith {
+            Mock -CommandName New-Object -ParameterFilter {
+                ($TypeName -eq 'Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer' -and
+                 $ArgumentList -eq 'localhost')
+            } -MockWith {
tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1 (1)

71-72: Unify variable casing to camelCase in assertions

These refer to the same ForEach-provided variables already used as $mockParameterSetName earlier. Unify casing to meet our guideline on camelCase for local variables.

-        $result.ParameterSetName | Should -Be $MockParameterSetName
-        $result.ParameterListAsString | Should -Be $MockExpectedParameters
+        $result.ParameterSetName | Should -Be $mockParameterSetName
+        $result.ParameterListAsString | Should -Be $mockExpectedParameters
tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1 (2)

70-74: Replace 'Should -Not -Throw' with direct invocation per test guidelines

The coding guidelines explicitly state to never use Should -Not -Throw. Call the command directly; Pester will fail the test if an exception occurs.

-                {
-                    $MockServiceObject |
-                        Assert-ManagedServiceType -ServiceType 'DatabaseEngine' -ErrorAction 'Stop'
-                } | Should -Not -Throw
+                $MockServiceObject |
+                    Assert-ManagedServiceType -ServiceType 'DatabaseEngine' -ErrorAction 'Stop'

92-92: Fix InModuleScope parameter name: use -Parameters (plural)

In Pester v5, InModuleScope accepts -Parameters (plural). Using -Parameter is likely ignored or causes a failure. Line 67 correctly uses -Parameters; make the two other occurrences consistent.

-                InModuleScope -Parameter $_ -ScriptBlock {
+                InModuleScope -Parameters $_ -ScriptBlock {
-                InModuleScope -Parameter $_ -ScriptBlock {
+                InModuleScope -Parameters $_ -ScriptBlock {

Also applies to: 109-109

tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1 (1)

139-147: Typo in Context description: 'WhatId' → 'WhatIf'

Minor spelling fix to match the parameter name and other contexts.

-                Context 'When using parameter WhatId' {
+                Context 'When using parameter WhatIf' {
tests/Unit/Classes/SqlDatabasePermission.Tests.ps1 (1)

986-992: Correct misleading test description for Set() when not in desired state.

The test expects Modify() to be called once, but the It description says “Should not call…”. Update the description for clarity.

-        It 'Should not call method Modify()' {
+        It 'Should call method Modify()' {
             InModuleScope -ScriptBlock {
                 $script:mockSqlDatabasePermissionInstance.Set()
 
                 $script:mockMethodModifyCallCount | Should -Be 1
             }
         }
tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1 (1)

481-487: Fix assertion to use the correct counter variable in the WithGrant revoke pipeline test.

This test currently checks $script:mockMethodGrantUsingWithGrantCallCount, but the code under test increments $script:mockMethodRevokeUsingWithGrantCallCount. This will cause a false assertion or nondeterminism depending on prior tests.

-                    $script:mockMethodGrantUsingWithGrantCallCount | Should -Be 1
+                    $script:mockMethodRevokeUsingWithGrantCallCount | Should -Be 1
tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1 (2)

409-412: Fix assertion checks for Revoke-WithGrant pipeline case (login)

The counter variable referenced is for Grant, not Revoke. This causes the test to assert the wrong metric.

-                    $script:mockMethodGrantUsingWithGrantCallCount | Should -Be 1
+                    $script:mockMethodRevokeUsingWithGrantCallCount | Should -Be 1

811-815: Fix assertion checks for Revoke-WithGrant pipeline case (role)

Same issue here: the test asserts the Grant counter instead of the Revoke counter.

-                    $script:mockMethodGrantUsingWithGrantCallCount | Should -Be 1
+                    $script:mockMethodRevokeUsingWithGrantCallCount | Should -Be 1
tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1 (1)

291-295: Duplicate test case entry for 'FailoverClusterGroup'.

The ForEach data block defines 'FailoverClusterGroup' twice. This is likely redundant and can cause confusion or duplicate coverage.

Please remove one of the duplicate entries so each optional parameter is represented once in the data set.

tests/Unit/Classes/SqlResourceBase.Tests.ps1 (2)

60-63: Avoid Should -Not -Throw in unit tests per guidelines.

The coding guidelines explicitly disallow Should -Not -Throw. You already validate construction in subsequent tests, so this It block is redundant and should be removed.

Consider removing this It block and relying on the existing constructor/type assertions.


82-83: Single Describe per file guideline.

This file has multiple Describe blocks; the guidelines call for a single Describe per test file (use Context blocks for scenarios). Consider nesting the GetServerObject() scenarios under the existing Describe 'SqlResourceBase' as a Context named 'When calling GetServerObject()'.

tests/Unit/Classes/ServerPermission.Tests.ps1 (5)

126-144: Bug: second instance is assigned to mockServerPermissionInstance1 instead of mockServerPermissionInstance2.

This makes the subsequent comparison use a null/undefined second instance, potentially passing for the wrong reason.

-                $script:mockServerPermissionInstance1 = InModuleScope -ScriptBlock {
+                $script:mockServerPermissionInstance2 = InModuleScope -ScriptBlock {
                     $databasPermissionInstance = [ServerPermission]::new()
 
                     $databasPermissionInstance.State = 'Grant'
                     $databasPermissionInstance.Permission = 'ViewServerState'
 
                     return $databasPermissionInstance
                 }

151-169: Bug: same variable misassignment in the Permission-difference context.

Second instance should be stored in mockServerPermissionInstance2.

-                $script:mockServerPermissionInstance1 = InModuleScope -ScriptBlock {
+                $script:mockServerPermissionInstance2 = InModuleScope -ScriptBlock {
                     $databasPermissionInstance = [ServerPermission]::new()
 
                     $databasPermissionInstance.State = 'Grant'
                     $databasPermissionInstance.Permission = 'AlterAnyAvailabilityGroup'
 
                     return $databasPermissionInstance
                 }

257-273: Mismatch between test description and assertion (CompareTo: follows → should be > 0).

Description says “less than zero” but assertion checks “greater than 0”.

-                It 'Should return a value less than zero' {
+                It 'Should return a value greater than zero' {

276-286: Mismatch between test description and assertion (CompareTo: vs null → should be > 0).

Description says “less than zero” but assertion checks “greater than 0”.

-                It 'Should return a value less than zero' {
+                It 'Should return a value greater than zero' {

305-321: Mismatch between test description and assertion (CompareTo: same position → should be 0).

Description says “less than zero” but assertion checks equality to 0.

-                It 'Should return a value less than zero' {
+                It 'Should return 0' {
tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1 (1)

243-247: Likely copy-paste: second instance assertions reference $result[0] instead of $result[1].

This prevents validating the second object’s details. Use index 1 and prefer existing mock variables for expectations.

-            $result[0].EditionID | Should -Be 2176971986
-            $result[0].EditionName | Should -Be 'SQL Server Developer'
-            $result[0].IsSharePointIntegrated | Should -BeFalse
-            $result[0].InstanceId | Should -Be 'SSRS'
+            $result[1].EditionID | Should -Be 2176971986
+            $result[1].EditionName | Should -Be 'SQL Server Developer'
+            $result[1].IsSharePointIntegrated | Should -BeFalse
+            $result[1].InstanceId | Should -Be $mockPBIRSInstance.InstanceName
tests/Unit/Classes/SqlAudit.Tests.ps1 (1)

71-75: Replace Should -Not -Throw with direct invocation (per test guidelines)

Guideline: tests/Unit/**/*.ps1 should not use Should -Not -Throw. Call the constructor directly so any exception fails the test.

-        It 'Should not throw an exception' {
-            InModuleScope -ScriptBlock {
-                { [SqlAudit]::new() } | Should -Not -Throw
-            }
-        }
+        It 'Should not throw an exception' {
+            InModuleScope -ScriptBlock {
+                [void] [SqlAudit]::new()
+            }
+        }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14c5107 and c9e7198.

📒 Files selected for processing (73)
  • CHANGELOG.md (1 hunks)
  • tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/DatabasePermission.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/ServerPermission.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/SqlAudit.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/SqlDatabasePermission.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/SqlPermission.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/SqlRSSetup.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/SqlReason.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/SqlResourceBase.Tests.ps1 (1 hunks)
  • tests/Unit/Classes/StartupParameters.Tests.ps1 (1 hunks)
  • tests/Unit/Private/Assert-Feature.Tests.ps1 (1 hunks)
  • tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1 (1 hunks)
  • tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1 (1 hunks)
  • tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1 (1 hunks)
  • tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1 (1 hunks)
  • tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1 (1 hunks)
  • tests/Unit/Private/Get-FileVersionInformation.Tests.ps1 (1 hunks)
  • tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1 (1 hunks)
  • tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1 (1 hunks)
  • tests/Unit/Private/Invoke-SetupAction.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Complete-SqlDscImage.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1 (1 hunks)
  • tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1 (1 hunks)
  • tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1 (1 hunks)
  • tests/Unit/Public/ConvertTo-SqlDscDatabasePermission.Tests.ps1 (1 hunks)
  • tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1 (1 hunks)
  • tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscAudit.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscServerPermission.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Install-SqlDscServer.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1 (1 hunks)
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Remove-SqlDscNode.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Set-SqlDscAudit.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1 (1 hunks)
  • tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1 (1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
tests/**/*.ps1

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

tests/**/*.ps1: All tests should use the Pester framework and use Pester v5.0 syntax.
Parameter validation should never be tested.
Test code should never be added outside of the Describe block.
There should only be one Pester Describe block per test file, and the name of the Describe block should be the same as the name of the public command, private function, or class-based resource being tested.
Each scenario or code path being tested should have its own Pester Context block that starts with the phrase 'When'.
Pester It block descriptions should start with the phrase 'Should'.
It blocks must always call the command or function being tested and result and outcomes should be kept in the same It block.
BeforeAll and BeforeEach blocks should never call the command or function being tested.
BeforeAll, BeforeEach, AfterAll and AfterEach blocks should be used inside the Context block as near as possible to the It block that will use the test data, test setup and teardown.
AfterAll block can be used to clean up any test data.
BeforeEach and AfterEach blocks should be used sparingly.
It is okay to duplicate code in BeforeAll and BeforeEach blocks that are used inside different Context blocks.
Use localized strings in the tests only when necessary.
Files that need to be mocked should be created in Pester's test drive using the $TestDrive variable.

Files:

  • tests/Unit/Public/ConvertTo-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Classes/DatabasePermission.Tests.ps1
  • tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1
  • tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1
  • tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1
  • tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1
  • tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1
  • tests/Unit/Public/Get-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1
  • tests/Unit/Classes/SqlDatabasePermission.Tests.ps1
  • tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Classes/SqlResourceBase.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1
  • tests/Unit/Private/Invoke-SetupAction.Tests.ps1
  • tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscImage.Tests.ps1
  • tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1
  • tests/Unit/Classes/SqlReason.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Classes/SqlAudit.Tests.ps1
  • tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1
  • tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1
  • tests/Unit/Public/Install-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1
  • tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1
  • tests/Unit/Public/Set-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Get-FileVersionInformation.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Classes/StartupParameters.Tests.ps1
  • tests/Unit/Private/Assert-Feature.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1
  • tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Classes/SqlRSSetup.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Classes/SqlPermission.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
  • tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1
  • tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1
  • tests/Unit/Public/Get-SqlDscServerPermission.Tests.ps1
tests/Unit/{Classes,Public,Private}/*.Tests.ps1

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

Unit tests should be added for all public commands, private functions and class-based resources. Unit tests for class-based resources should be placed in tests/Unit/Classes, for public commands in tests/Unit/Public, and for private functions in tests/Unit/Private. The unit tests should be named after the item being tested with the suffix .Tests.ps1.

Files:

  • tests/Unit/Public/ConvertTo-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Classes/DatabasePermission.Tests.ps1
  • tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1
  • tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1
  • tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1
  • tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1
  • tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1
  • tests/Unit/Public/Get-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1
  • tests/Unit/Classes/SqlDatabasePermission.Tests.ps1
  • tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Classes/SqlResourceBase.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1
  • tests/Unit/Private/Invoke-SetupAction.Tests.ps1
  • tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscImage.Tests.ps1
  • tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1
  • tests/Unit/Classes/SqlReason.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Classes/SqlAudit.Tests.ps1
  • tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1
  • tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1
  • tests/Unit/Public/Install-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1
  • tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1
  • tests/Unit/Public/Set-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Get-FileVersionInformation.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Classes/StartupParameters.Tests.ps1
  • tests/Unit/Private/Assert-Feature.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1
  • tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Classes/SqlRSSetup.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Classes/SqlPermission.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
  • tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Get-SqlDscServerPermission.Tests.ps1
tests/Unit/Public/*.Tests.ps1

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

tests/Unit/Public/*.Tests.ps1: All public commands should always have a test to validate parameter sets using the provided template.
All public commands should also include tests to validate parameter properties.

Files:

  • tests/Unit/Public/ConvertTo-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1
  • tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1
  • tests/Unit/Public/Get-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1
  • tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscImage.Tests.ps1
  • tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1
  • tests/Unit/Public/Install-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1
  • tests/Unit/Public/Set-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1
  • tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
  • tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Get-SqlDscServerPermission.Tests.ps1
tests/Unit/**/*.ps1

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

tests/Unit/**/*.ps1: Never test, mock or use Should -Invoke for Write-Verbose and Write-Debug.
Never use Should -Not -Throw in tests; instead, call the command directly.
All unit tests should use the provided code block prior to the Describe block to set up the test environment and load the correct module.

Files:

  • tests/Unit/Public/ConvertTo-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Classes/DatabasePermission.Tests.ps1
  • tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1
  • tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1
  • tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1
  • tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1
  • tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1
  • tests/Unit/Public/Get-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1
  • tests/Unit/Classes/SqlDatabasePermission.Tests.ps1
  • tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Classes/SqlResourceBase.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1
  • tests/Unit/Private/Invoke-SetupAction.Tests.ps1
  • tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscImage.Tests.ps1
  • tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1
  • tests/Unit/Classes/SqlReason.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Classes/SqlAudit.Tests.ps1
  • tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1
  • tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1
  • tests/Unit/Public/Install-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1
  • tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1
  • tests/Unit/Public/Set-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Get-FileVersionInformation.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Classes/StartupParameters.Tests.ps1
  • tests/Unit/Private/Assert-Feature.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1
  • tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Classes/SqlRSSetup.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Classes/SqlPermission.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
  • tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Get-SqlDscServerPermission.Tests.ps1
**/*.ps1

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.ps1: All PowerShell files should use UTF8 without BOM.
All PowerShell files must end with a new line.
Try to limit PowerShell code lines to 120 characters.
Use 4 spaces for indentation in PowerShell files, never use tabs.
Use '#' for single line comments in PowerShell code.
Use comment-blocks for multiline comments with the format <# ... #> where the multiline text is indented 4 spaces.
Use descriptive, clear, and full names for all variables, parameters, and function names. All names must be more than 2 characters. No abbreviations should be used.
Use camelCase for local variable names in PowerShell.
Use Write-Error for error messages.
Use Write-Warning for warning messages.
Use Write-Information for informational messages.
Never use Write-Host.
Never use backtick as line continuation in code.
Use splatting for commands to reduce line length.
PowerShell reserved keywords should be in all lower case.
Single quotes should always be used to delimit string literals wherever possible. Double quoted string literals may only be used when string literals contain ($) expressions that need to be evaluated.
Hashtables properties should always be in PascalCase and be on a separate line.
When comparing a value to $null, $null should be on the left side of the comparison.

Files:

  • tests/Unit/Public/ConvertTo-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Classes/DatabasePermission.Tests.ps1
  • tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1
  • tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1
  • tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1
  • tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1
  • tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1
  • tests/Unit/Public/Get-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1
  • tests/Unit/Classes/SqlDatabasePermission.Tests.ps1
  • tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Classes/SqlResourceBase.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1
  • tests/Unit/Private/Invoke-SetupAction.Tests.ps1
  • tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscImage.Tests.ps1
  • tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1
  • tests/Unit/Classes/SqlReason.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Classes/SqlAudit.Tests.ps1
  • tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1
  • tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1
  • tests/Unit/Public/Install-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1
  • tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1
  • tests/Unit/Public/Set-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Get-FileVersionInformation.Tests.ps1
  • tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Classes/StartupParameters.Tests.ps1
  • tests/Unit/Private/Assert-Feature.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1
  • tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1
  • tests/Unit/Classes/SqlRSSetup.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Classes/SqlPermission.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
  • tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1
  • tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1
  • tests/Unit/Public/Get-SqlDscServerPermission.Tests.ps1
CHANGELOG.md

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

The Unreleased section in CHANGELOG.md should always be updated when making changes to the codebase, using the keepachangelog format and providing concrete release notes.

Files:

  • CHANGELOG.md
**/*.md

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.md: Markdown files should wrap lines after a word when a line exceeds 80 characters.
Use 2 spaces for indentation in Markdown files.

Files:

  • CHANGELOG.md
tests/Integration/Commands/*.Integration.Tests.ps1

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

tests/Integration/Commands/*.Integration.Tests.ps1: Integration tests for public commands should be placed in tests/Integration/Commands and named after the command with the suffix .Integration.Tests.ps1.
All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.

Files:

  • tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1
🧠 Learnings (8)
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Unit/**/*.ps1 : All unit tests should use the provided code block prior to the Describe block to set up the test environment and load the correct module.

Applied to files:

  • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1
  • tests/Unit/Classes/DatabasePermission.Tests.ps1
  • tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1
  • tests/Unit/Public/Get-SqlDscAudit.Tests.ps1
  • tests/Unit/Classes/SqlDatabasePermission.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscNode.Tests.ps1
  • tests/Unit/Private/Invoke-SetupAction.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscImage.Tests.ps1
  • tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1
  • tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1
  • tests/Unit/Classes/SqlReason.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1
  • tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1
  • tests/Unit/Classes/SqlAudit.Tests.ps1
  • tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1
  • tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1
  • tests/Unit/Public/Install-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1
  • tests/Unit/Public/Set-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Get-FileVersionInformation.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Private/Assert-Feature.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1
  • tests/Unit/Classes/SqlRSSetup.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Classes/SqlPermission.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
  • tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1
  • tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : All integration tests must use the provided code block prior to the first Describe block to set up the integration test environment.

Applied to files:

  • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1
  • tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1
  • tests/Unit/Private/Invoke-SetupAction.Tests.ps1
  • tests/Unit/Classes/SqlReason.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1
  • tests/Unit/Classes/SqlRSSetup.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
  • tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : BeforeAll and BeforeEach blocks should never call the command or function being tested.

Applied to files:

  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1
  • tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1
  • tests/Unit/Public/Get-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Invoke-SetupAction.Tests.ps1
  • tests/Unit/Public/Complete-SqlDscImage.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1
  • tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Private/Assert-Feature.Tests.ps1
  • tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Classes/SqlPermission.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
  • tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : AfterAll block can be used to clean up any test data.

Applied to files:

  • tests/Unit/Public/Repair-SqlDscServer.Tests.ps1
  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to source/Classes/*.ps1 : A derived DSC class-based resource should only inherit from SqlResourceBase if it needs to connect to a SQL Server Database Engine.

Applied to files:

  • tests/Unit/Classes/SqlResourceBase.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : BeforeAll, BeforeEach, AfterAll and AfterEach blocks should be used inside the Context block as near as possible to the It block that will use the test data, test setup and teardown.

Applied to files:

  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Public/New-SqlDscAudit.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : BeforeEach and AfterEach blocks should be used sparingly.

Applied to files:

  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
📚 Learning: 2025-08-03T09:50:27.001Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-03T09:50:27.001Z
Learning: Applies to tests/**/*.ps1 : It is okay to duplicate code in BeforeAll and BeforeEach blocks that are used inside different Context blocks.

Applied to files:

  • tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1
  • tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1
  • tests/Unit/Public/Add-SqlDscNode.Tests.ps1
  • tests/Unit/Classes/ServerPermission.Tests.ps1
  • tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1
  • tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1
🧬 Code Graph Analysis (1)
tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (1)
  • DatabasePermissionSet (233-244)
⏰ 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 (49)
tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1 (1)

31-31: Good fix: forcing module import ensures fresh test runs

Using -Force guarantees the latest on-disk module is loaded during test setup, aligning with the PR objective and avoiding stale module state.

tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1 (1)

31-31: LGTM: Forcing module import ensures a fresh load during tests

Using -Force here aligns with the PR objective and our standard pre-Describe environment setup. This helps make tests resilient to prior state.

tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1 (1)

31-31: Forcing module reload aligns with the PR objective

Adding -Force ensures the test run picks up the latest module changes and avoids stale state. Combined with the AfterAll removal, this provides good isolation between tests.

tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1 (1)

49-256: Pester v5 structure and test semantics look solid

Single Describe matching the public command, Contexts start with 'When', Its start with 'Should', mocks are scoped appropriately, and the module bootstrap (including the new -Force) follows the provided pre-Describe pattern. No functional concerns.

tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1 (2)

31-31: LGTM: Forcing module reload improves test reliability

Using -Force here is aligned with the PR objective and prevents stale module state across test runs.


31-31: Verified — all Import-Module calls include -Force; no action required

Ran a repo-wide search for Import-Module -Name $script:dscModuleName missing -Force and found no matches, so tests force-reload the module as intended.

Note (optional): several tests use -Force without an explicit -ErrorAction 'Stop' (e.g. tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1, tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1, tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1) — consider adding for consistency, but not required for this change.

tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1 (1)

31-31: LGTM: Forcing module reload improves test determinism

Consistent with the new test bootstrap approach; avoids caching issues across runs.

tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1 (1)

32-32: LGTM: Using -Force on Import-Module matches PR goal

Ensures the latest module state is always used by this suite.

tests/Unit/Public/Repair-SqlDscServer.Tests.ps1 (1)

32-32: LGTM: Forced module import prevents stale state

Aligned with the standardized test bootstrap across the repo.

tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1 (1)

32-32: LGTM: Forcing module reload here is correct and desirable

Prevents leakage of module state between tests, matching the PR intent.

tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1 (1)

31-31: LGTM: Forcing module import ensures a fresh test target.

Using Import-Module with -Force in BeforeAll aligns with the PR goal and avoids stale module state across tests.

tests/Unit/Classes/SqlDatabasePermission.Tests.ps1 (1)

37-37: LGTM: -Force here matches the suite-wide approach.

Forcing the module import in BeforeAll is consistent and appropriate.

tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1 (1)

31-31: LGTM: Module reload is enforced as intended.

This aligns with the PR objective and helps ensure tests run against current definitions.

tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1 (1)

31-31: LGTM: Forcing import reduces flakiness.

The -Force reload here is appropriate and consistent with the rest of the suite.

tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1 (1)

31-31: LGTM: -Force import aligns with the test bootstrap pattern.

Ensures a clean module state for this test file.

tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1 (2)

31-31: LGTM: Forcing module import ensures fresh module state in tests

Using -Force here aligns with the PR objective and prevents stale module definitions during test runs.


31-31: Optional: Add -ErrorAction 'Stop' to Import-Module for deterministic failures

Make the test bootstrap fail-fast if the module can't be loaded.

  • Expected location to update:
    • tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1 (around line 31)

Apply this diff:

-    Import-Module -Name $script:dscModuleName -Force
+    Import-Module -Name $script:dscModuleName -Force -ErrorAction 'Stop'

Verification note: I searched the repo under tests/ for occurrences of Import-Module -Name $script:dscModuleName and found no matches (search output: NO_IMPORT_MODULE_MATCHES_FOUND). Please confirm the file/path or apply the change where the module is imported.

tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1 (1)

31-31: LGTM: -Force on Import-Module matches the test bootstrap pattern

Ensures a clean reload of SqlServerDsc for this test suite.

tests/Unit/Classes/SqlReason.Tests.ps1 (1)

36-36: LGTM: -Force import improves test isolation

Consistent with the repo-wide change to avoid stale module state across test runs.

tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1 (1)

31-31: LGTM: Force-reloading module in BeforeAll is appropriate

This helps ensure the new Assert-SqlDscLogin command is loaded from the current PR build.

tests/Unit/Classes/SqlPermission.Tests.ps1 (1)

37-37: LGTM: Forced module import is aligned with the suite’s setup conventions

Maintains consistent, reliable module loading before running tests.

tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1 (2)

31-31: LGTM: Forcing module import improves test isolation

Using Import-Module -Force here aligns with the PR goal and prevents stale exports during test runs. Teardown already unloads all instances.


31-31: All test imports of SqlServerDsc already use -Force — no change needed

Searched tests/ for Import-Module usages of SqlServerDsc (both $script:dscModuleName and literal "SqlServerDsc") without -Force; none were found.

  • tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1 — Import-Module -Name $script:dscModuleName -Force (line ~31) — OK
tests/Unit/Classes/SqlRSSetup.Tests.ps1 (1)

37-37: LGTM: Force-import applied consistently

This ensures the class under test is reloaded between runs, preventing stale state.

tests/Unit/Public/Complete-SqlDscImage.Tests.ps1 (1)

32-32: LGTM: Force re-import during setup

Matches the suite-wide pattern; teardown removes the module as well.

tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1 (1)

31-31: LGTM: Force import is appropriate here

This change is aligned with the PR intent and existing teardown unload logic.

tests/Unit/Public/Set-SqlDscAudit.Tests.ps1 (1)

31-31: LGTM: Force import ensures fresh module state

Change is consistent with PR scope; teardown already unloads the module.

tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1 (1)

31-31: Resolved — Import-Module already uses -ErrorAction 'Stop'

Repo-wide scan of tests found no Import-Module invocations missing -Force or missing -ErrorAction 'Stop' (no hits). No change required.

tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1 (1)

31-31: LGTM: using -Force ensures the latest module is under test.

Change aligns with the PR objective and the shared test bootstrap pattern.

tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1 (1)

32-32: LGTM: import with -Force is appropriate here.

Consistent with the suite’s initialization approach.

tests/Unit/Classes/SqlResourceBase.Tests.ps1 (1)

36-36: LGTM: -Force import is correct and consistent with the test harness.

tests/Unit/Public/ConvertTo-SqlDscDatabasePermission.Tests.ps1 (1)

31-31: LGTM: forcing module reload is appropriate here.

Keeps the test environment consistent across runs.

tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1 (1)

32-32: LGTM! Consistent with PR's module import standardization.

The addition of the -Force parameter ensures a clean module state by forcibly reloading the SqlServerDsc module if it's already loaded. This aligns with the PR objective to avoid AI failing when testing changes and ensures tests run against the latest module definitions.

tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1 (1)

32-32: LGTM! Proper module reload for test isolation.

The -Force parameter addition ensures the module is forcibly reloaded, providing a clean test environment. This change is consistent with the PR-wide pattern to standardize module importing in test setups and prevents potential issues with cached module state during testing.

tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1 (1)

31-31: LGTM! Forced module reload ensures clean test state.

The addition of -Force to the Import-Module command aligns with the PR's objective to ensure tests forcibly import the module being tested. This prevents potential issues with stale module definitions and ensures consistent test behavior.

tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1 (1)

31-31: LGTM! Consistent module import pattern for reliable testing.

The -Force parameter ensures the SqlServerDsc module is reloaded if already present in memory, providing a clean test environment. This change is part of the systematic improvement across test files to prevent AI-related testing failures by ensuring tests run against fresh module definitions.

tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1 (1)

31-31: LGTM! Aligns with coding guidelines and PR objectives.

The addition of -Force to the Import-Module command follows the retrieved learning that "All unit tests should use the provided code block prior to the Describe block to set up the test environment and load the correct module." This ensures proper test isolation and prevents issues with cached module state, which is the primary objective of this PR.

tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1 (2)

31-31: Forcing module reload in tests — good change

Using Import-Module -Force in BeforeAll ensures the latest module definitions are used during test execution and aligns with the PR objective and our testing guidelines.


31-31: No action required — tests already import the module with -Force

I searched the test suite for Import-Module usages referencing $script:dscModuleName; all matches include -Force. The file under review is correct:

Import-Module -Name $script:dscModuleName -Force
tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1 (1)

31-31: Forcing module reload in tests — good change

This ensures a clean state for the module under test and prevents stale definitions during runs. Matches the suite-wide approach noted in the changelog.

tests/Unit/Public/Add-SqlDscNode.Tests.ps1 (1)

32-32: Forcing module reload in tests — good change

Consistent with the established test bootstrap pattern and reduces flakiness from cached module state.

tests/Unit/Private/Get-FileVersionInformation.Tests.ps1 (1)

31-31: Forcing module reload in tests — good change

Appropriate for unit tests and aligned with our guideline to load the correct module prior to the Describe block.

tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1 (1)

32-32: Forcing module reload in tests — good change

Helps ensure the test suite executes against the latest module contents; consistent with other updated tests in this PR.

tests/Unit/Classes/SqlAudit.Tests.ps1 (2)

37-37: LGTM: Forcing module reload in tests is appropriate

Using Import-Module -Force ensures a clean module state between test runs and aligns with the PR objective.


37-37: All tests import SqlServerDsc ($script:dscModuleName) with -Force — verified

I ran the provided ripgrep check across tests; it returned no matches for Import-Module $script:dscModuleName missing -Force. The file tests/Unit/Classes/SqlAudit.Tests.ps1 already uses:
Import-Module -Name $script:dscModuleName -Force

No changes required.

tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1 (1)

32-32: LGTM: -Force on import is consistent with the PR goal

This makes test runs resilient to already-loaded modules.

tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1 (1)

31-31: LGTM: Forcing module reload during setup

This aligns with the intended behavior of ensuring fresh module state per test run.

tests/Unit/Public/Install-SqlDscServer.Tests.ps1 (1)

32-32: LGTM: -Force ensures the latest module is under test

Consistent with the PR intent and helps avoid stale state.

tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1 (1)

31-31: LGTM: Forcing module import is the right move

This keeps the test environment deterministic.

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.

Review continued from previous batch...

@codecov
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

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

Additional details and impacted files

Impacted file tree graph

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

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@johlju johlju added the needs review The pull request needs a code review. label Aug 14, 2025
Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

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

Fix wording: "Assumes dependencies has been resolved, so if this module" -> "Assumes dependencies have been resolved, so if this module". In all tests.

@johlju
Copy link
Member Author

johlju commented Aug 15, 2025

Also:

[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')]

to

[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]

johlju added 3 commits August 16, 2025 11:03
…ncy and clarity regarding dependency resolution.
…warnings with justification

- Updated multiple test files to include a justification for suppressing the 'PSUseDeclaredVarsMoreThanAssignments' rule, clarifying that the suppression is due to Script Analyzer's inability to understand Pester syntax.
- Maintained existing suppressions for 'PSAvoidUsingConvertToSecureStringWithPlainText' where applicable, ensuring clarity in test intent and compliance with best practices.
…to Import-Module commands

- Updated all test scripts to include -ErrorAction 'Stop' in the Import-Module command for improved error handling.
- This change ensures that any failure in module import will halt the execution of the tests, allowing for quicker identification of issues.
Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

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

:lgtm:

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

@johlju johlju enabled auto-merge (squash) August 16, 2025 17:00
@johlju johlju disabled auto-merge August 16, 2025 17:00
@johlju johlju merged commit 3a792fc into dsccommunity:main Aug 16, 2025
3 of 7 checks passed
@johlju johlju deleted the fix/tests-force-import branch August 16, 2025 17:00
@johlju johlju removed the needs review The pull request needs a code review. label Aug 16, 2025
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.

1 participant