Skip to content

Refactor and enhance Pester tests batch #9755

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

Open
wants to merge 20 commits into
base: development
Choose a base branch
from
Open

Conversation

potatoqualitee
Copy link
Member

Standardized parameter quoting, variable naming, and splatting across test scripts. Improved error handling and cleanup in integration tests, replaced deprecated syntax, and enhanced readability and maintainability. No functional changes to the tested modules.

Standardized parameter quoting, variable naming, and splatting across test scripts. Improved error handling and cleanup in integration tests, replaced deprecated syntax, and enhanced readability and maintainability. No functional changes to the tested modules.
Standardized the use of $PSDefaultParameterValues to enable exceptions during setup and cleanup in integration tests across multiple test files. Added and clarified comments, improved variable scoping, and ensured proper cleanup of test artifacts and directories. This improves test reliability and consistency.
Updated Invoke-DbatoolsFormatter to use custom PSSA settings that preserve manually aligned hashtables and assignment operators. The script now only writes files if formatting changes are detected, reducing unnecessary file writes.
Added checks to skip directories and non-PowerShell files, improved error handling for file read/write operations, and ensured only valid content is processed. These changes enhance robustness and prevent errors when processing invalid or unreadable files.
Enhances the formatter to compare processed, formatted content rather than raw content, ensuring that only meaningful formatting changes trigger file writes. Also applies CBH (Comment-Based Help) fixes and whitespace normalization to both the original and formatted content for accurate comparison.
Simplifies the formatter by removing custom alignment-preserving settings and redundant code. Now uses a placeholder approach to preserve aligned assignments, streamlines file type checks, and only writes files if actual formatting changes are detected. Improves maintainability and reliability of the formatting process.
Enhanced Invoke-DbatoolsFormatter to display progress when formatting multiple files, including status updates for each file, error handling, and a summary of processed and updated files. This improves user feedback during batch operations.
This commit addresses whitespace, indentation, and minor style inconsistencies across multiple test scripts. No functional changes were made; these updates improve code readability and maintain consistent formatting throughout the test suite.
@potatoqualitee potatoqualitee changed the title Refactor and improve test scripts for consistency Refactor and enhance Pester tests batch Aug 10, 2025
Simplified and cleaned up integration tests in Add-DbaDbMirrorMonitor.Tests.ps1 by removing redundant parameter handling and streamlining setup/teardown logic. In Connect-DbaInstance.Tests.ps1, variable naming was improved, unnecessary array casts were removed, and minor comment and assertion updates were made for clarity and consistency.
Added checks for the existence of backup files before attempting to remove them in Connect-DbaInstance integration tests. This prevents errors if the backup file does not exist.
Added the -IgnoreFileChecks parameter to Backup-DbaDatabase calls in integration tests to bypass file checks. This ensures the tests run without file validation issues.
Updated the test to check for at least 3 results and verify that each expected certificate is present, rather than requiring exactly 3 results. This makes the test more robust to additional certificates.
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