Skip to content

Refactor and enhance Pester tests batch #9761

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

Merged
merged 23 commits into from
Aug 10, 2025
Merged

Refactor and enhance Pester tests batch #9761

merged 23 commits into from
Aug 10, 2025

Conversation

potatoqualitee
Copy link
Member

Refactored multiple test scripts to standardize parameter handling, use $CommandName variables, and improve consistency in parameter validation. Updated integration test setup and cleanup to use EnableException for reliability, improved variable naming, and enhanced test isolation and clarity across dbatools command tests.

Refactored multiple test scripts to standardize parameter handling, use $CommandName variables, and improve consistency in parameter validation. Updated integration test setup and cleanup to use EnableException for reliability, improved variable naming, and enhanced test isolation and clarity across dbatools command tests.
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.
Cleaned up formatting by removing an unnecessary trailing space after 'SqlCredential' in the expected parameters array.
This commit updates various test scripts to standardize whitespace, indentation, and minor formatting for consistency. No functional changes were made to the test logic.
Eliminated the SkipInvisibleOnly parameter and related logic from Invoke-DbatoolsFormatter. Updated documentation and examples to reflect the removal, and simplified the formatting process to always apply changes when content differs, regardless of whether changes are only invisible (e.g., whitespace, line endings).
Refactored multiple test files to standardize parameter validation, use param blocks, and improve setup/teardown logic. Updated tests to use $CommandName, $TestConfig, and consistent BeforeAll/AfterAll blocks. Improved cleanup, variable scoping, and assertion syntax for clarity and maintainability.
Added 'Get-DbaDbMasterKey' to the list of tests not to run due to frequent failures.
Replaced usage of $global: variables with local variables throughout Export-DbaLogin.Tests.ps1. This improves test isolation and reduces side effects between tests.
Adjusted the spacing in the hashtable initialization for $placeholders to use a space between the braces, improving code style consistency.
Updated test assertions to join output arrays into strings before matching, ensuring correct evaluation of script output. This improves reliability of tests that check for batch separators and error messages.
Introduces a CopyOnly switch to Repair-PullRequestTest.ps1, allowing the process to stop after copying working test files from the development branch without running Update-PesterTest or committing changes. This provides more granular control for users who only want to copy test files.
@potatoqualitee
Copy link
Member Author

couldnt automate the upgrade of export-dbascript or export-dbalogin

@potatoqualitee
Copy link
Member Author

gotta merge this cuz it has tool fixes that i need in other branches

@potatoqualitee potatoqualitee merged commit dcdf21a into development Aug 10, 2025
14 checks passed
@potatoqualitee potatoqualitee deleted the b2 branch August 10, 2025 20:54
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