-
Notifications
You must be signed in to change notification settings - Fork 125
Closed
Labels
enhancementNew feature or requestNew feature or requestlintingLinting rules and validationLinting rules and validationscriptsPowerShell, Bash, or Python scriptsPowerShell, Bash, or Python scripts
Description
Summary
Create unit tests for the core linting PowerShell scripts that perform markdown, link, and PSScriptAnalyzer validation.
Parent Issue: #190
Requirements
Create test files for each linting script:
scripts/tests/linting/Invoke-LinkLanguageCheck.Tests.ps1scripts/tests/linting/Invoke-PSScriptAnalyzer.Tests.ps1scripts/tests/linting/Link-Lang-Check.Tests.ps1scripts/tests/linting/Markdown-Link-Check.Tests.ps1scripts/tests/linting/Validate-MarkdownFrontmatter.Tests.ps1
Implementation Details
Scripts Under Test
| Script | Purpose | Key Functions |
|---|---|---|
| Invoke-LinkLanguageCheck.ps1 | Link language validation | Parameter handling, output formatting |
| Invoke-PSScriptAnalyzer.ps1 | PowerShell analysis | PSScriptAnalyzer invocation, result processing |
| Link-Lang-Check.ps1 | Link validation | URL checking, result aggregation |
| Markdown-Link-Check.ps1 | Markdown link checking | File discovery, link extraction |
| Validate-MarkdownFrontmatter.ps1 | Frontmatter validation | YAML parsing, schema validation |
Test Pattern
BeforeAll {
# Use dot-sourcing pattern for scripts
. $PSScriptRoot/../../linting/ScriptName.ps1
}
Describe 'Script-Name.ps1' {
Context 'Parameter Validation' {
It 'Should accept valid parameters' {
# Test parameter binding
}
It 'Should reject invalid parameters' {
{ Invoke-Script -InvalidParam 'value' } | Should -Throw
}
}
Context 'Core Functionality' {
BeforeEach {
# Mock external dependencies
Mock Get-ChildItem { return @() }
Mock Invoke-ExternalTool { return $null }
}
It 'Should process files correctly' {
# Test main logic
}
}
Context 'Output Formatting' {
It 'Should produce valid JSON output' {
$result = Invoke-Script -OutputFormat Json
{ $result | ConvertFrom-Json } | Should -Not -Throw
}
}
}Shared Mocks Usage
BeforeAll {
# Import shared test utilities
. $PSScriptRoot/../TestHelpers/SharedMocks.ps1
# Get mock file system
$mockFiles = Get-MockMarkdownFiles
}Acceptance Criteria
- Test file exists for each of the 5 linting scripts
- Parameter validation tests for each script
- Core logic tests with mocked dependencies
- Output format tests (JSON, console)
- Error handling tests
- All tests pass in CI environment
Dependencies
- [Issue]: Add Pester test infrastructure (config, directories, shared mocks) #193 (infrastructure) for test directory structure
- [Issue]: Integrate Pester tests into PR validation workflow #195 (LintingHelpers tests) for module mocking patterns
Estimated Effort
4-6 hours (5 scripts)
Additional Context
Target Scripts
scripts/linting/Invoke-LinkLanguageCheck.ps1scripts/linting/Invoke-PSScriptAnalyzer.ps1scripts/linting/Link-Lang-Check.ps1scripts/linting/Markdown-Link-Check.ps1scripts/linting/Validate-MarkdownFrontmatter.ps1
Testing Priority
- Validate-MarkdownFrontmatter.ps1 (complex schema logic)
- Invoke-PSScriptAnalyzer.ps1 (integrates with external tool)
- Remaining scripts
Related Issues
- Depends on: [Issue]: Add Pester test infrastructure (config, directories, shared mocks) #193 (infrastructure), [Issue]: Integrate Pester tests into PR validation workflow #195 (module tests)
- Parent: [Issue]: Add Pester unit testing framework for PowerShell scripts #190
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestlintingLinting rules and validationLinting rules and validationscriptsPowerShell, Bash, or Python scriptsPowerShell, Bash, or Python scripts