tests/DiskHealth.Tests.ps1
|
$moduleRoot = Split-Path -Parent $PSScriptRoot Import-Module (Join-Path $moduleRoot 'Octa.psd1') -Force Describe 'Show-OctaDiskHealth' { It 'never changes registry or service state (SC-014-style non-mutation guarantee)' { # ponytail: compares StartType (persistent config), not Status (live running/stopped # state). Diagnosed a real, deterministic (not flaky) failure: Get-PhysicalDisk alone - # before Show-OctaDiskHealth even reaches Get-StorageReliabilityCounter - makes Windows # start the smphost (Storage Management Provider Host) service as a side effect of # querying its WMI namespace, the same way many Manual-start services activate on first # COM/WMI use. That's normal OS behavior for any code that calls Get-PhysicalDisk, not a # mutation Octa's own code performs - and a raw Status diff can't tell the difference # between that and every OTHER service on the machine starting/stopping for unrelated # reasons in the background, which made this "flaky" on every unrelated app on the test # machine too. StartType only changes if something reconfigures a service (Set-Service, # sc.exe config, etc.) - which is the actual thing a non-mutation guarantee should mean. $before = Get-Service | Select-Object Name, StartType { Show-OctaDiskHealth | Out-Null } | Should Not Throw $after = Get-Service | Select-Object Name, StartType (Compare-Object $before $after -Property Name, StartType) | Should Be $null } It 'reports a real entry per physical disk with "not available" (not fabricated) for any missing counter' { $result = @(Show-OctaDiskHealth) $result.Count | Should BeGreaterThan 0 foreach ($r in $result) { $r.FriendlyName | Should Not BeNullOrEmpty # Each of these is either a real measured value or the literal honesty sentinel - # never $null/blank (research.md: confirmed a real per-field gap on real hardware). $r.TemperatureC | Should Not BeNullOrEmpty $r.PowerOnHours | Should Not BeNullOrEmpty $r.Wear | Should Not BeNullOrEmpty } } } |