-
Notifications
You must be signed in to change notification settings - Fork 25
feat(tests): add Pester tests for LintingHelpers and Validate-MarkdownFrontmatter (#197, #198) #205
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
base: main
Are you sure you want to change the base?
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Pull request overview
This pull request adds comprehensive Pester 5.x unit tests for the LintingHelpers.psm1 module, providing coverage for all 7 exported functions. The test suite validates git integration, file enumeration, gitignore pattern parsing, and GitHub Actions workflow command functions using proper mocking patterns.
Changes:
- Added 41 test cases across 7 describe blocks covering all exported functions in LintingHelpers.psm1
- Implemented proper mocking for git commands with LASTEXITCODE handling
- Utilized existing GitMocks.psm1 module for GitHub Actions environment simulation
- Add third fallback test (merge-base + HEAD~1 fail) - Add git diff failure test (LASTEXITCODE -ne 0) - Add exception handling test (catch block coverage) - Fix assertion precision with platform-aware separators - Update comment to be platform-neutral Addresses review comments on PR #205
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.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
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.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
- add tests for Get-ChangedFilesFromGit, Get-FilesRecursive, Get-GitIgnorePatterns - add tests for Write-GitHubAnnotation, Set-GitHubOutput, Set-GitHubEnv - add tests for Write-GitHubStepSummary with GitHub Actions context handling - leverage GitMocks.psm1 for environment simulation 🧪 - Generated by Copilot
- Add third fallback test (merge-base + HEAD~1 fail) - Add git diff failure test (LASTEXITCODE -ne 0) - Add exception handling test (catch block coverage) - Fix assertion precision with platform-aware separators - Update comment to be platform-neutral Addresses review comments on PR #205
…downFrontmatter - add custom PowerShell classes for FrontmatterResult, SchemaValidationResult, ValidationResult, FileTypeInfo - add ConvertFrom-YamlFrontmatter and Get-FileTypeInfo pure helper functions - add -Content parameter to Get-MarkdownFrontmatter for testing without file I/O - add comprehensive docstrings with OutputType attributes on all functions 🧪 - Generated by Copilot
- Add comprehensive Pester test suite covering all 8 exported functions - Create 7 fixture files for frontmatter validation scenarios - Fix regex escaping order in Get-SchemaForFile (escape dots before glob conversion) Closes #198 🧪 - Generated by Copilot
…tion tests - add npm run test:ps script for running Pester tests - add Initialize-JsonSchemaValidation test coverage 🧪 - Generated by Copilot
…ures - add ExcludePaths parameter to Validate-MarkdownFrontmatter.ps1 script and function - exclude scripts/tests/Fixtures/* from frontmatter and markdown linting - normalize Windows backslash paths for cross-platform pattern matching 🔧 - Generated by Copilot
📝 - Generated by Copilot
🔧 - Generated by Copilot
- update workflow to use ** for recursive matching in subdirectories - fix npm script to use -Command for proper array parameter parsing - remove duplicate Initialize-JsonSchemaValidation test region 🔧 - Generated by Copilot
- Add ExcludePaths check to the Files code path used by ChangedFilesOnly mode - Previously ExcludePaths filtering only applied when using Paths parameter - CI uses ChangedFilesOnly which populates Files, so exclusions were ignored 🔧 - Generated by Copilot
e39d58e to
5a69873
Compare
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.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.
- remove unreachable duplicate elseif block in Get-SchemaForFile - add descriptive comments for pattern matching logic - remove UTF-8 BOM from test file 🧹 - Generated by Copilot
- file contains non-ASCII characters requiring BOM encoding 🔧 - Generated by Copilot
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.
Pull request overview
Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.
Description
This PR adds comprehensive Pester test coverage for the linting modules, implementing 104 tests across two test suites:
The implementation also includes a production bug fix for regex escaping order in
Get-SchemaForFile.Key Changes
LintingHelpers Tests (#197):
Get-ChangedFilesFromGit,Get-FilesRecursive,Get-GitIgnorePatternsWrite-GitHubAnnotation,Set-GitHubOutput,Set-GitHubEnv,Write-GitHubStepSummaryGitMocks.psm1for environment simulationValidate-MarkdownFrontmatter Tests (#198):
ConvertFrom-YamlFrontmatter,Get-MarkdownFrontmatter,Get-FileTypeInfo,Test-MarkdownFooterGet-SchemaForFile,Test-JsonSchemaValidation,Get-ChangedMarkdownFileGroup,Test-FrontmatterValidationGet-SchemaForFile- dots are now escaped BEFORE glob conversionValidationResult,SchemaValidationResult,FileTypeInfo,FrontmatterResult)Related Issue(s)
Closes #197
Closes #198
Type of Change
Sample Prompts
Not applicable - infrastructure/testing changes.
Testing
Test Results
All 104 tests pass:
Test Coverage Summary
Get-ChangedFilesFromGitGet-FilesRecursiveGet-GitIgnorePatternsWrite-GitHubAnnotationSet-GitHubOutputSet-GitHubEnvWrite-GitHubStepSummaryConvertFrom-YamlFrontmatterGet-MarkdownFrontmatterGet-FileTypeInfoTest-MarkdownFooterGet-SchemaForFileTest-JsonSchemaValidationGet-ChangedMarkdownFileGroupTest-FrontmatterValidationRequired Checks
Security Considerations
Additional Notes
Schema Validation Mode
Schema validation operates in soft/advisory mode - schema errors produce warnings rather than build failures. Tests are designed with this expectation.
Production Bug Fixed
The regex escaping bug in
Get-SchemaForFilecaused patterns likedocs/**/*.mdto fail matching because the dot in.mdwas being escaped after the glob-to-regex conversion, resulting in invalid patterns likedocs/.*/.*.mdinstead ofdocs/.*/.*\.md.Files Changed
scripts/linting/Modules/LintingHelpers.psm1scripts/linting/Validate-MarkdownFrontmatter.ps1scripts/tests/Modules/LintingHelpers.Tests.ps1scripts/tests/Modules/Validate-MarkdownFrontmatter.Tests.ps1scripts/tests/Mocks/GitMocks.psm1scripts/tests/Fixtures/Frontmatter/*.md🧪 - Generated by Copilot