tests/BuiltinTools.Tests.ps1
|
$moduleRoot = Split-Path -Parent $PSScriptRoot Import-Module (Join-Path $moduleRoot 'Octa.psd1') -Force Describe 'Show-OctaDashboard' { It 'never changes registry or service state (SC-014)' { $before = Get-Service | Select-Object -ExpandProperty Status Show-OctaDashboard | Out-Null $after = Get-Service | Select-Object -ExpandProperty Status (Compare-Object $before $after) | Should Be $null } It 'reports non-null CPU, RAM, and OS info' { $report = Show-OctaDashboard $report.Cpu.Name | Should Not BeNullOrEmpty $report.Ram.TotalGB | Should Not Be 0 $report.Os.Caption | Should Not BeNullOrEmpty } } Describe 'Invoke-OctaStartupManager' { It 'lists startup items without throwing and without modifying anything' { { Invoke-OctaStartupManager } | Should Not Throw } It 'reports NotFound for a startup item that does not exist, without modifying the real system' { $result = Invoke-OctaStartupManager -Disable 'ThisStartupItemDoesNotExist12345' $result.Status | Should Be 'NotFound' } } Describe 'Invoke-OctaTaskBrowser' { It 'lists scheduled tasks without throwing' { { Invoke-OctaTaskBrowser } | Should Not Throw } } Describe 'Get-OctaCleanupTargets' { # Computed once for both It blocks below - scanning SoftwareDistribution\Download etc. # is real disk I/O, not free; read-only measurement only, never calls # Invoke-OctaDiskCleanup -Apply, which would delete real files on whoever runs this test. # Real deletion is validated on the disposable VM. $targets = Get-OctaCleanupTargets It 'measures real, non-negative bytes for every target and never throws' { foreach ($t in $targets) { ($t.MeasuredBytes -ge 0) | Should Be $true $t.Reversible | Should Be $false $t.IrreversibleReason | Should Not BeNullOrEmpty } } It 'classifies Windows.old as Risky if present on this machine' { $windowsOld = $targets | Where-Object { $_.Name -match 'Windows.old' } if ($windowsOld) { $windowsOld.RiskLevel | Should Be 'Risky' } } } |