tests/DiskUsage.Tests.ps1
|
$moduleRoot = Split-Path -Parent $PSScriptRoot Import-Module (Join-Path $moduleRoot 'Octa.psd1') -Force Describe 'Show-OctaDiskUsage' { It 'never changes registry or service state (SC-014-style non-mutation guarantee)' { $before = Get-Service | Select-Object -ExpandProperty Status { Show-OctaDiskUsage -Path $env:TEMP -Top 3 | Out-Null } | Should Not Throw $after = Get-Service | Select-Object -ExpandProperty Status (Compare-Object $before $after) | Should Be $null } It 'reports real, non-negative sizes for at most -Top folders' { $result = @(Show-OctaDiskUsage -Path $env:USERPROFILE -Top 5) ($result.Count -le 5) | Should Be $true foreach ($r in $result) { $r.SizeBytes | Should BeGreaterThan -1 } } It 'reports an empty list for a path with no subfolders, without throwing' { $emptyDir = Join-Path $env:TEMP ('octa-diskusage-empty-{0}' -f [guid]::NewGuid()) New-Item -ItemType Directory -Path $emptyDir -Force | Out-Null try { $result = @(Show-OctaDiskUsage -Path $emptyDir -Top 10) $result.Count | Should Be 0 } finally { Remove-Item -Path $emptyDir -Recurse -Force -ErrorAction SilentlyContinue } } } |