Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Trenly <12611259+Trenly@users.noreply.github.com>
3.1 KiB
3.1 KiB
YamlCreate.InstallerDetection Tests
This directory contains Pester tests for the YamlCreate.InstallerDetection PowerShell module.
Overview
The test suite validates the functionality of the installer detection module, which provides functions to:
- Parse PE file structures
- Detect various installer types (ZIP, MSIX, MSI, WIX, Nullsoft, Inno, Burn)
- Identify font files
- Resolve installer types from file paths
Running the Tests
Prerequisites
- PowerShell 7.0 or later
- Pester 5.x (included with PowerShell 7+)
Run All Tests
From the module directory, run:
Invoke-Pester -Path ./YamlCreate.InstallerDetection.Tests.ps1
Run Tests with Detailed Output
For more detailed test output:
Invoke-Pester -Path ./YamlCreate.InstallerDetection.Tests.ps1 -Output Detailed
Run Tests with Code Coverage
To see code coverage metrics:
Invoke-Pester -Path ./YamlCreate.InstallerDetection.Tests.ps1 -CodeCoverage ./YamlCreate.InstallerDetection.psm1
Test Structure
The test suite is organized into the following sections:
Module Tests
- Module import validation
- Exported functions verification
Function Tests
- Get-OffsetBytes: Tests for byte array extraction with various offsets and endianness
- Get-PESectionTable: Tests for PE file parsing
- Test-IsZip: Tests for ZIP file detection
- Test-IsMsix: Tests for MSIX/APPX detection
- Test-IsMsi: Tests for MSI installer detection
- Test-IsWix: Tests for WIX installer detection
- Test-IsNullsoft: Tests for Nullsoft installer detection
- Test-IsInno: Tests for Inno Setup installer detection
- Test-IsBurn: Tests for Burn installer detection
- Test-IsFont: Tests for font file detection (TTF, OTF, TTC)
- Resolve-InstallerType: Tests for the main installer type resolution function
Known Limitations
Some tests are skipped due to complexity or external dependencies:
- ZIP Archive Tests: Tests that require complete valid ZIP archives are skipped as they would need complex ZIP structure generation
- PE File Tests: Some PE-related tests are skipped when they would require reading non-existent files
- External Dependencies: The module relies on external commands (
Get-MSITable,Get-MSIProperty,Get-Win32ModuleResource) that are stubbed in the test environment
Test Coverage
Current test coverage includes:
- 32 passing tests
- 3 skipped tests (require complex setup)
- Covers all 11 exported functions
- Tests both positive and negative scenarios
- Validates edge cases and error handling
Contributing
When adding new functions to the module:
- Add corresponding tests to
YamlCreate.InstallerDetection.Tests.ps1 - Follow the existing test structure (Describe → Context → It blocks)
- Use descriptive test names that explain what is being tested
- Include both positive and negative test cases
- Clean up any temporary files created during tests