tests/History.Tests.ps1
|
$moduleRoot = Split-Path -Parent $PSScriptRoot Import-Module (Join-Path $moduleRoot 'Octa.psd1') -Force . (Join-Path $moduleRoot 'private\RunRecord.ps1') Describe 'Show-OctaHistory' { It 'never mutates any Run Record file (read-only, same guarantee as Show-OctaDashboard)' { $runsRoot = Get-OctaRunsRoot $before = @(Get-ChildItem -Path $runsRoot -Recurse -File -ErrorAction SilentlyContinue | Select-Object FullName, LastWriteTime) { Show-OctaHistory | Out-Null } | Should Not Throw $after = @(Get-ChildItem -Path $runsRoot -Recurse -File -ErrorAction SilentlyContinue | Select-Object FullName, LastWriteTime) (Compare-Object $before $after -Property FullName, LastWriteTime) | Should Be $null } It 'returns an array with the expected shape per entry, or an empty array when no runs exist' { $history = @(Show-OctaHistory) foreach ($h in $history) { $names = @($h.PSObject.Properties.Name) ($names -contains 'RunId') | Should Be $true ($names -contains 'Timestamp') | Should Be $true ($names -contains 'CategoriesApplied') | Should Be $true ($names -contains 'ActionCount') | Should Be $true ($names -contains 'Status') | Should Be $true } } } |