Skip to content

SqlServerDsc: Update tests to Pester 6 syntax where supported#2465

Draft
johlju wants to merge 22 commits into
dsccommunity:mainfrom
johlju:f/pester-6-attempt-2
Draft

SqlServerDsc: Update tests to Pester 6 syntax where supported#2465
johlju wants to merge 22 commits into
dsccommunity:mainfrom
johlju:f/pester-6-attempt-2

Conversation

@johlju

@johlju johlju commented Jun 28, 2026

Copy link
Copy Markdown
Member

Pull Request (PR) description

  • SqlServerDsc
    • Update tests to Pester 6 syntax where supported.

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

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 90ffc263-37cd-446a-a197-68ce91333a53

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

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

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (9400ebf) to head (34bec4a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##           main   #2465     +/-   ##
======================================
+ Coverage    91%     94%     +2%     
======================================
  Files        32     227    +195     
  Lines      5353   10871   +5518     
======================================
+ Hits       4904   10234   +5330     
- Misses      449     637    +188     
Flag Coverage Δ
unit 94% <ø> (+2%) ⬆️
see 197 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

johlju and others added 20 commits June 28, 2026 21:03
… Should-NotInvoke

- Changed all instances of 'Should:ModuleName' to 'Should-Invoke:ModuleName' and 'Should-NotInvoke:ModuleName' in various test scripts.
- Updated BeforeAll and AfterAll blocks in the following test files:
  - Test-SqlDscIsLogin.Tests.ps1
  - Test-SqlDscIsLoginEnabled.Tests.ps1
  - Test-SqlDscIsRole.Tests.ps1
  - Test-SqlDscIsSupportedFeature.Tests.ps1
  - Test-SqlDscRSAccessible.Tests.ps1
  - Test-SqlDscRSInitialized.Tests.ps1
  - Test-SqlDscRSInstalled.Tests.ps1
  - Test-SqlDscServerPermission.Tests.ps1
  - Uninstall-SqlDscPowerBIReportServer.Tests.ps1
  - Uninstall-SqlDscReportingService.Tests.ps1
  - Uninstall-SqlDscServer.Tests.ps1
  - Update-SqlDscServer.Tests.ps1
  - Update-SqlDscServerEdition.Tests.ps1
  - Connect-Sql.Tests.ps1
  - Connect-SqlAnalysis.Tests.ps1
  - Connect-UncPath.Tests.ps1
  - ConvertTo-ServerInstanceName.Tests.ps1
  - Copy-ItemWithRobocopy.Tests.ps1
  - Disconnect-UncPath.Tests.ps1
  - Find-ExceptionByNumber.Tests.ps1
  - Get-PrimaryReplicaServerObject.Tests.ps1
  - Get-ServiceAccount.Tests.ps1
  - Get-SqlInstanceMajorVersion.Tests.ps1
  - Invoke-InstallationMediaCopy.Tests.ps1
  - Invoke-SqlScript.Tests.ps1
  - Restart-SqlClusterService.Tests.ps1
  - Restart-SqlService.Tests.ps1
  - Split-FullSqlInstanceName.Tests.ps1
  - Start-SqlSetupProcess.Tests.ps1
  - Test-ActiveNode.Tests.ps1
  - Test-AvailabilityReplicaSeedingModeAutomatic.Tests.ps1
  - Test-ClusterPermissions.Tests.ps1
  - Test-FeatureFlag.Tests.ps1
  - Test-ImpersonatePermissions.Tests.ps1
  - Test-LoginEffectivePermissions.Tests.ps1
  - Update-AvailabilityGroupReplica.Tests.ps1
- Updated all test scripts to replace references of `$script:dscModuleName` with `$script:moduleName` for the `Should-Invoke` and `Should-NotInvoke` parameters in the `BeforeAll` block.
…e:ModuleName' and 'Should-NotInvoke:ModuleName' for consistency with Pester 6
…datory checks

- Updated tests for various SQL DSC commands to replace direct checks for mandatory attributes with Should-All { $_ | Should-BeTrue } for better readability and consistency.
- Ensured that non-mandatory parameters are checked using Should-All { $_ | Should-BeFalse } where applicable.
- This change applies to tests across multiple files including Disable-SqlDscDatabaseSnapshotIsolation, Enable-SqlDscLogin, Get-SqlDscAgentAlert, and others.
…consistency

- Updated multiple unit test files to replace the use of inline script blocks with -FilterScript in assertions for parameter attributes.
- Ensured that mandatory and non-mandatory parameter checks are consistently using the same validation method across various test files.
- This change improves readability and maintains a uniform approach to parameter validation in the tests.
…ssertions

- Updated parameter handling in multiple test scripts to use 'Should:ModuleName' instead of 'Should-Invoke:ModuleName' and 'Should-NotInvoke:ModuleName'.
- Replaced 'Should -MatchExactly' assertions with 'Should-MatchString -CaseSensitive' for better clarity and consistency in tests.
- Adjusted various test cases to ensure proper invocation and parameter filtering for SQL setup processes.
- Enhanced type checking in tests to ensure expected object types are returned.
- Cleaned up redundant code and improved readability across multiple test files.
…sertions and update type checks for consistency
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