Commit fa17f2b
authored
test(scripts): add Pester tests for Invoke-YamlLint.ps1 (#326)
## Description
Added comprehensive Pester 5.x unit tests for `Invoke-YamlLint.ps1`,
achieving 100% code coverage. The test suite validates all script
functionality including parameter handling, tool availability checks,
file discovery modes, JSON parsing edge cases, GitHub Actions
integration, and exit code behavior.
- Created 37 unit tests organized across 9 Describe blocks covering all
code paths
- Implemented extensive mocking of `actionlint` binary and
`LintingHelpers` module functions
- Tested both all-files and changed-files-only modes with proper
filtering
- Validated JSON parsing for null, empty, single, multiple, and
malformed outputs
- Verified GitHub Actions outputs, environment variables, annotations,
and step summaries
## Related Issue(s)
N/A
## Type of Change
Select all that apply:
**Code & Documentation:**
- [ ] Bug fix (non-breaking change fixing an issue)
- [ ] New feature (non-breaking change adding functionality)
- [ ] Breaking change (fix or feature causing existing functionality to
change)
- [ ] Documentation update
**Infrastructure & Configuration:**
- [ ] GitHub Actions workflow
- [ ] Linting configuration (markdown, PowerShell, etc.)
- [ ] Security configuration
- [ ] DevContainer configuration
- [ ] Dependency update
**AI Artifacts:**
- [ ] Reviewed contribution with `prompt-builder` agent and addressed
all feedback
- [ ] Copilot instructions (`.github/instructions/*.instructions.md`)
- [ ] Copilot prompt (`.github/prompts/*.prompt.md`)
- [ ] Copilot agent (`.github/agents/*.agent.md`)
**Other:**
- [x] Script/automation (`.ps1`, `.sh`, `.py`)
- [ ] Other (please describe):
## Sample Prompts (for AI Artifact Contributions)
N/A - This is a test file contribution.
## Testing
- Executed `Invoke-Pester` with code coverage analysis
- All 37 tests passed
- Achieved 100% code coverage (target: 80%)
- Coverage report generated at `logs/coverage-yamllint.xml`
## Checklist
### Required Checks
- [ ] Documentation is updated (if applicable)
- [x] Files follow existing naming conventions
- [x] Changes are backwards compatible (if applicable)
- [x] Tests added for new functionality (if applicable)
### AI Artifact Contributions
N/A
### Required Automated Checks
The following validation commands must pass before merging:
- [ ] Markdown linting: `npm run lint:md`
- [ ] Spell checking: `npm run spell-check`
- [ ] Frontmatter validation: `npm run lint:frontmatter`
- [ ] Link validation: `npm run lint:md-links`
- [x] PowerShell analysis: `npm run lint:ps`
## Security Considerations
- [x] This PR does not contain any sensitive or NDA information
- [x] Any new dependencies have been reviewed for security issues
- [x] Security-related scripts follow the principle of least privilege
## Additional Notes
Test file location: `scripts/tests/linting/Invoke-YamlLint.Tests.ps1`
Test coverage areas:
| Area | Tests |
|------|-------|
| Parameter Validation | 3 |
| Tool Availability | 3 |
| File Discovery | 8 |
| JSON Parsing | 5 |
| Issue Processing | 3 |
| Output Generation | 3 |
| GitHub Actions Integration | 7 |
| Exit Code Handling | 5 |
🧪 - Generated by Copilot1 parent 35c4417 commit fa17f2b
1 file changed
+585
-0
lines changed
0 commit comments