-
Notifications
You must be signed in to change notification settings - Fork 227
Ensure module imports in tests #2133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedMore 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 WalkthroughUpdated 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–25 minutes ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 53
🔭 Outside diff range comments (19)
tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1 (1)
73-76: Replace backtick line continuation with parenthesesOur 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 assertionsThese 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 $mockExpectedParameterstests/Unit/Private/Assert-ManagedServiceType.Tests.ps1 (2)
70-74: Replace 'Should -Not -Throw' with direct invocation per test guidelinesThe 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 1tests/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 1tests/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.InstanceNametests/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
📒 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.ps1tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1tests/Unit/Public/Repair-SqlDscServer.Tests.ps1tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1tests/Unit/Classes/DatabasePermission.Tests.ps1tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1tests/Unit/Public/Get-SqlDscAudit.Tests.ps1tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1tests/Unit/Classes/SqlDatabasePermission.Tests.ps1tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1tests/Unit/Classes/SqlResourceBase.Tests.ps1tests/Unit/Public/Remove-SqlDscNode.Tests.ps1tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1tests/Unit/Private/Invoke-SetupAction.Tests.ps1tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Complete-SqlDscImage.Tests.ps1tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1tests/Unit/Classes/SqlReason.Tests.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1tests/Unit/Classes/SqlAudit.Tests.ps1tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1tests/Unit/Public/Install-SqlDscServer.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1tests/Unit/Public/Set-SqlDscAudit.Tests.ps1tests/Unit/Private/Get-FileVersionInformation.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/Unit/Classes/StartupParameters.Tests.ps1tests/Unit/Private/Assert-Feature.Tests.ps1tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1tests/Unit/Classes/SqlRSSetup.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/Unit/Classes/SqlPermission.Tests.ps1tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1tests/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.ps1tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1tests/Unit/Public/Repair-SqlDscServer.Tests.ps1tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1tests/Unit/Classes/DatabasePermission.Tests.ps1tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1tests/Unit/Public/Get-SqlDscAudit.Tests.ps1tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1tests/Unit/Classes/SqlDatabasePermission.Tests.ps1tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1tests/Unit/Classes/SqlResourceBase.Tests.ps1tests/Unit/Public/Remove-SqlDscNode.Tests.ps1tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1tests/Unit/Private/Invoke-SetupAction.Tests.ps1tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Complete-SqlDscImage.Tests.ps1tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1tests/Unit/Classes/SqlReason.Tests.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1tests/Unit/Classes/SqlAudit.Tests.ps1tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1tests/Unit/Public/Install-SqlDscServer.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1tests/Unit/Public/Set-SqlDscAudit.Tests.ps1tests/Unit/Private/Get-FileVersionInformation.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/Unit/Classes/StartupParameters.Tests.ps1tests/Unit/Private/Assert-Feature.Tests.ps1tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1tests/Unit/Classes/SqlRSSetup.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/Unit/Classes/SqlPermission.Tests.ps1tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1tests/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.ps1tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1tests/Unit/Public/Repair-SqlDscServer.Tests.ps1tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1tests/Unit/Public/Get-SqlDscAudit.Tests.ps1tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1tests/Unit/Public/Remove-SqlDscNode.Tests.ps1tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Complete-SqlDscImage.Tests.ps1tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1tests/Unit/Public/Install-SqlDscServer.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1tests/Unit/Public/Set-SqlDscAudit.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1tests/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.ps1tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1tests/Unit/Public/Repair-SqlDscServer.Tests.ps1tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1tests/Unit/Classes/DatabasePermission.Tests.ps1tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1tests/Unit/Public/Get-SqlDscAudit.Tests.ps1tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1tests/Unit/Classes/SqlDatabasePermission.Tests.ps1tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1tests/Unit/Classes/SqlResourceBase.Tests.ps1tests/Unit/Public/Remove-SqlDscNode.Tests.ps1tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1tests/Unit/Private/Invoke-SetupAction.Tests.ps1tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Complete-SqlDscImage.Tests.ps1tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1tests/Unit/Classes/SqlReason.Tests.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1tests/Unit/Classes/SqlAudit.Tests.ps1tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1tests/Unit/Public/Install-SqlDscServer.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1tests/Unit/Public/Set-SqlDscAudit.Tests.ps1tests/Unit/Private/Get-FileVersionInformation.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/Unit/Classes/StartupParameters.Tests.ps1tests/Unit/Private/Assert-Feature.Tests.ps1tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1tests/Unit/Classes/SqlRSSetup.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/Unit/Classes/SqlPermission.Tests.ps1tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1tests/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.ps1tests/Unit/Public/Install-SqlDscReportingService.Tests.ps1tests/Unit/Public/Repair-SqlDscServer.Tests.ps1tests/Unit/Public/Repair-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Get-SqlDscStartupParameter.Tests.ps1tests/Unit/Classes/DatabasePermission.Tests.ps1tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1tests/Unit/Public/Test-SqlDscRSInstalled.Tests.ps1tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1tests/Unit/Private/Assert-ManagedServiceType.Tests.ps1tests/Unit/Public/Assert-SqlDscLogin.Tests.ps1tests/Unit/Public/Get-SqlDscAudit.Tests.ps1tests/Unit/Public/Enable-SqlDscAudit.Tests.ps1tests/Unit/Classes/SqlDatabasePermission.Tests.ps1tests/Unit/Public/Connect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1tests/Unit/Public/Uninstall-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscServerPermission.Tests.ps1tests/Unit/Classes/SqlResourceBase.Tests.ps1tests/Unit/Public/Remove-SqlDscNode.Tests.ps1tests/Unit/Public/Test-SqlDscIsLogin.Tests.ps1tests/Unit/Private/Invoke-SetupAction.Tests.ps1tests/Unit/Public/Add-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Complete-SqlDscImage.Tests.ps1tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscEditionName.Tests.ps1tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1tests/Unit/Public/Save-SqlDscSqlServerMediaFile.Tests.ps1tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputerService.Tests.ps1tests/Unit/Classes/SqlReason.Tests.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Private/ConvertTo-RedactedText.Tests.ps1tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1tests/Unit/Public/Set-SqlDscDatabasePermission.Tests.ps1tests/Unit/Public/Get-SqlDscDatabasePermission.Tests.ps1tests/Unit/Classes/SqlAudit.Tests.ps1tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Initialize-SqlDscRebuildDatabase.Tests.ps1tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1tests/Unit/Public/Install-SqlDscServer.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1tests/Unit/Private/Get-SMOModuleCalculatedVersion.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscServerPermission.Tests.ps1tests/Unit/Public/Disconnect-SqlDscDatabaseEngine.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1tests/Unit/Public/Set-SqlDscAudit.Tests.ps1tests/Unit/Private/Get-FileVersionInformation.Tests.ps1tests/Unit/Public/ConvertFrom-SqlDscDatabasePermission.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/Unit/Classes/StartupParameters.Tests.ps1tests/Unit/Private/Assert-Feature.Tests.ps1tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1tests/Unit/Public/Get-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/ConvertTo-SqlDscServerPermission.Tests.ps1tests/Unit/Classes/SqlRSSetup.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/Unit/Classes/SqlPermission.Tests.ps1tests/Unit/Public/Remove-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1tests/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.ps1tests/Unit/Public/Repair-SqlDscServer.Tests.ps1tests/Unit/Classes/DatabasePermission.Tests.ps1tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1tests/Unit/Public/Get-SqlDscAudit.Tests.ps1tests/Unit/Classes/SqlDatabasePermission.Tests.ps1tests/Unit/Public/Uninstall-SqlDscBIReportServer.Tests.ps1tests/Unit/Public/Disable-SqlDscAudit.Tests.ps1tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1tests/Unit/Public/Remove-SqlDscNode.Tests.ps1tests/Unit/Private/Invoke-SetupAction.Tests.ps1tests/Unit/Public/Complete-SqlDscImage.Tests.ps1tests/Unit/Public/Get-SqlDscInstalledInstance.Tests.ps1tests/Unit/Public/Uninstall-SqlDscServer.Tests.ps1tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1tests/Unit/Classes/SqlReason.Tests.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1tests/Unit/Public/Import-SqlDscPreferredModule.Tests.ps1tests/Unit/Public/Repair-SqlDscReportingService.Tests.ps1tests/Unit/Classes/SqlAudit.Tests.ps1tests/Unit/Public/Install-SqlDscBIReportServer.Tests.ps1tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1tests/Unit/Public/Install-SqlDscServer.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/Complete-SqlDscFailoverCluster.Tests.ps1tests/Unit/Public/Test-SqlDscIsSupportedFeature.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/Unit/Public/Get-SqlDscConfigurationOption.Tests.ps1tests/Unit/Public/Set-SqlDscAudit.Tests.ps1tests/Unit/Private/Get-FileVersionInformation.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/Unit/Private/Assert-Feature.Tests.ps1tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1tests/Unit/Classes/SqlRSSetup.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/Unit/Classes/SqlPermission.Tests.ps1tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1tests/Unit/Public/Get-SqlDscPreferredModule.Tests.ps1tests/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.ps1tests/Unit/Public/Set-SqlDscStartupParameter.Tests.ps1tests/Unit/Private/Invoke-SetupAction.Tests.ps1tests/Unit/Classes/SqlReason.Tests.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1tests/Unit/Classes/SqlRSSetup.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1tests/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.ps1tests/Unit/Private/ConvertFrom-ManagedServiceType.Tests.ps1tests/Unit/Public/Get-SqlDscAudit.Tests.ps1tests/Unit/Private/Invoke-SetupAction.Tests.ps1tests/Unit/Public/Complete-SqlDscImage.Tests.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Public/Remove-SqlDscAudit.Tests.ps1tests/Unit/Private/Invoke-ReportServerSetupAction.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/Unit/Private/Assert-Feature.Tests.ps1tests/Unit/Public/Test-SqlDscIsRole.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/Unit/Classes/SqlPermission.Tests.ps1tests/Unit/Public/Invoke-SqlDscQuery.Tests.ps1tests/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.ps1tests/Unit/Public/Set-SqlDscTraceFlag.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/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.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Public/New-SqlDscAudit.Tests.ps1tests/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.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/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.ps1tests/Unit/Public/Get-SqlDscRSSetupConfiguration.Tests.ps1tests/Unit/Public/Add-SqlDscNode.Tests.ps1tests/Unit/Classes/ServerPermission.Tests.ps1tests/Unit/Public/Get-SqlDscManagedComputer.Tests.ps1tests/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 runsUsing
-Forceguarantees 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 testsUsing -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 objectiveAdding -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 solidSingle 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 reliabilityUsing
-Forcehere 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 requiredRan 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 determinismConsistent 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 goalEnsures 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 stateAligned 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 desirablePrevents 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 testsUsing -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 failuresMake 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:dscModuleNameand 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 patternEnsures a clean reload of SqlServerDsc for this test suite.
tests/Unit/Classes/SqlReason.Tests.ps1 (1)
36-36: LGTM: -Force import improves test isolationConsistent 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 appropriateThis 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 conventionsMaintains consistent, reliable module loading before running tests.
tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1 (2)
31-31: LGTM: Forcing module import improves test isolationUsing 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 neededSearched 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 consistentlyThis 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 setupMatches 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 hereThis 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 stateChange 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
-Forceparameter 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
-Forceparameter 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
-Forceto 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
-Forceparameter 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
-Forceto 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 changeUsing 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 -ForceI 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 -Forcetests/Unit/Public/Test-SqlDscIsRole.Tests.ps1 (1)
31-31: Forcing module reload in tests — good changeThis 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 changeConsistent 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 changeAppropriate 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 changeHelps 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 appropriateUsing 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 — verifiedI 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 -ForceNo changes required.
tests/Unit/Private/ConvertTo-ManagedServiceType.Tests.ps1 (1)
32-32: LGTM: -Force on import is consistent with the PR goalThis makes test runs resilient to already-loaded modules.
tests/Unit/Public/Test-SqlDscIsDatabasePrincipal.Tests.ps1 (1)
31-31: LGTM: Forcing module reload during setupThis 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 testConsistent 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 moveThis keeps the test environment deterministic.
tests/Integration/Commands/Assert-SqlDscLogin.Integration.Tests.ps1
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review continued from previous batch...
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2133 +/- ##
====================================
Coverage 94% 94%
====================================
Files 107 107
Lines 8094 8094
====================================
Hits 7655 7655
Misses 439 439
🚀 New features to boost your workflow:
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
johlju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix wording: "Assumes dependencies has been resolved, so if this module" -> "Assumes dependencies have been resolved, so if this module". In all tests.
|
Also: to |
…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.
johlju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, 151 of 151 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju)
Pull Request (PR) description
when testing changes.
This Pull Request (PR) fixes the following issues
None.
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is