tests/BykaDrBackup.Manifest.Tests.ps1
|
# Manifest schema tests for the BykaDrBackup module. # # Run with: # pwsh -NoProfile -Command "Invoke-Pester -Path packages/byka-dr-backup/tests -Output Detailed" BeforeAll { $script:ManifestPath = Join-Path $PSScriptRoot '..' 'BykaDrBackup.psd1' } Describe 'BykaDrBackup manifest' { It 'parses via Test-ModuleManifest without errors' { { Test-ModuleManifest -Path $script:ManifestPath -ErrorAction Stop } | Should -Not -Throw } It 'exports Invoke-BykaDrBackup' { $m = Test-ModuleManifest -Path $script:ManifestPath $m.ExportedFunctions.Keys | Should -Contain 'Invoke-BykaDrBackup' } It 'has ModuleVersion 1.0.0' { (Test-ModuleManifest -Path $script:ManifestPath).Version.ToString() | Should -Be '1.0.0' } It 'requires PowerShell 7.0 or newer' { (Test-ModuleManifest -Path $script:ManifestPath).PowerShellVersion.Major | Should -BeGreaterOrEqual 7 } It 'FileList covers every .ps1 in Public/ and Private/' { # [G4] qa F5: a future author adding `Public\New-XYZ.ps1` without # updating FileList would silently exclude it from the PSGallery # tarball. Enumerate the actual shipped sources and require each one # to be in the manifest's FileList. # Resolve $moduleRoot to a normalized absolute path because the manifest # is referenced via `Join-Path $PSScriptRoot '..'` which leaves a `\..` # segment that breaks Substring math against Get-ChildItem FullName. $moduleRoot = (Resolve-Path -LiteralPath (Split-Path -Parent $script:ManifestPath)).ProviderPath $sep = [IO.Path]::DirectorySeparatorChar $testsPattern = "*${sep}tests${sep}*" $expected = @(Get-ChildItem -Recurse -Path $moduleRoot -Filter '*.ps1' -ErrorAction SilentlyContinue | Where-Object { # Tests are NOT shipped -- exclude tests/ from the expected set. $_.FullName -notlike $testsPattern } | ForEach-Object { $_.FullName.Substring($moduleRoot.Length + 1) }) $manifest = Import-PowerShellDataFile -Path $script:ManifestPath $fileList = @($manifest.FileList | ForEach-Object { ($_ -replace '\\', [IO.Path]::DirectorySeparatorChar) }) foreach ($f in $expected) { $fileList | Should -Contain $f -Because "manifest FileList must include $f" } } } |