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.ps1
scripts/tests/linting/Invoke-PSScriptAnalyzer.Tests.ps1
scripts/tests/linting/Link-Lang-Check.Tests.ps1
scripts/tests/linting/Markdown-Link-Check.Tests.ps1
scripts/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
Dependencies
Estimated Effort
4-6 hours (5 scripts)
Additional Context
Target Scripts
scripts/linting/Invoke-LinkLanguageCheck.ps1
scripts/linting/Invoke-PSScriptAnalyzer.ps1
scripts/linting/Link-Lang-Check.ps1
scripts/linting/Markdown-Link-Check.ps1
scripts/linting/Validate-MarkdownFrontmatter.ps1
Testing Priority
- Validate-MarkdownFrontmatter.ps1 (complex schema logic)
- Invoke-PSScriptAnalyzer.ps1 (integrates with external tool)
- Remaining scripts
Related Issues
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.ps1Implementation Details
Scripts Under Test
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
Dependencies
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.ps1Testing Priority
Related Issues