-
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 comprehensive unit tests for LintingHelpers.psm1, the shared module containing helper functions used by multiple linting scripts.
Parent Issue: #190
Requirements
- Create
scripts/tests/Modules/LintingHelpers.Tests.ps1 - Test all exported functions from LintingHelpers.psm1
- Use Pester 5.x syntax with
Describe/Context/Itblocks - Mock filesystem and external dependencies
- Achieve minimum 80% code coverage for the module
Implementation Details
Target Functions
Based on research analysis, LintingHelpers.psm1 likely exports:
- Path resolution helpers
- Result formatting functions
- Common validation utilities
- JSON/output serialization helpers
Test Structure
BeforeAll {
# Import module under test
$ModulePath = Join-Path $PSScriptRoot '../../linting/Modules/LintingHelpers.psm1'
Import-Module $ModulePath -Force
}
Describe 'LintingHelpers Module' {
Context 'Module Structure' {
It 'Should export expected functions' {
$module = Get-Module LintingHelpers
$module.ExportedFunctions.Keys | Should -Contain 'Get-ExpectedFunction'
}
}
Context 'Function-Name' {
It 'Should handle valid input' {
# Arrange
$input = 'test-value'
# Act
$result = Get-FunctionName -Input $input
# Assert
$result | Should -Be 'expected-output'
}
It 'Should handle edge cases' {
# Test empty input, null, special characters, etc.
}
}
}
AfterAll {
Remove-Module LintingHelpers -ErrorAction SilentlyContinue
}Mocking Patterns
BeforeEach {
# Mock filesystem operations
Mock Test-Path { return $true }
Mock Get-Content { return '{"key": "value"}' }
# Mock external commands if needed
Mock Invoke-ExternalTool { return @{ Success = $true } }
}Acceptance Criteria
- Test file exists at
scripts/tests/Modules/LintingHelpers.Tests.ps1 - All exported functions have corresponding test coverage
- Tests use proper Pester 5.x syntax
- Mocks isolate tests from filesystem/external dependencies
- Tests pass in CI environment (ubuntu-latest)
- Code coverage >= 80% for module
Dependencies
- [Issue]: Add Pester test infrastructure (config, directories, shared mocks) #193 (infrastructure) provides test directory structure and shared mocks
Estimated Effort
2-3 hours
Additional Context
Target File
scripts/linting/Modules/LintingHelpers.psm1- Module under test
Why Module Tests First
Testing the shared module first:
- Establishes mocking patterns for dependent scripts
- Validates test infrastructure with simpler target
- Provides reusable test helpers for script tests
Related Issues
- Depends on: [Issue]: Add Pester test infrastructure (config, directories, shared mocks) #193 (infrastructure)
- Blocks: Linting scripts tests, frontmatter 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