From fda6b58295ef0d3ea48303f773f582ebd453ab95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexey=20ALERT=20Rubash=D1=91ff?= Date: Thu, 27 Aug 2026 19:58:37 +0300 Subject: [PATCH] fix: show a path example where the path is typed The example of a .vhdx path was printed once, three lines above the box it goes into, and had scrolled out of attention by the time the cursor was blinking. Eleven other prompts in this script already carry what they accept inside the prompt itself; this one now does too. Request-VhdxPath gains its first direct tests along with it: it had none, and only the rule that reads its answer was covered. Closes #109 Co-Authored-By: Claude Opus 5 --- dev_drive.Tests.ps1 | 20 ++++++++++++++++++++ dev_drive.ps1 | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dev_drive.Tests.ps1 b/dev_drive.Tests.ps1 index 0d538df..68562ed 100644 --- a/dev_drive.Tests.ps1 +++ b/dev_drive.Tests.ps1 @@ -1227,6 +1227,26 @@ Describe 'Resolve-VhdxPathInput' { } } +Describe 'Request-VhdxPath' { + BeforeAll { + Mock Write-Host { } + Mock Read-Host { 'D:\DevDrive.vhdx' } + Mock Test-Path { $true } -ParameterFilter { $LiteralPath -eq 'D:\' } + Mock Test-Path { $false } -ParameterFilter { $LiteralPath -eq 'D:\DevDrive.vhdx' } + Mock Get-Volume { [PSCustomObject]@{ DriveType = 'Fixed' } } + } + + It 'takes a path whose folder exists on a fixed drive' { + Request-VhdxPath | Should -Be 'D:\DevDrive.vhdx' + } + + It 'shows what a path looks like where one is typed, not three lines above it' { + # The example above the prompt is still on screen, and still was not what got typed. + Request-VhdxPath | Out-Null + Should -Invoke Read-Host -ParameterFilter { $Prompt -match '\(E\.g\. D:\\DevDrive\.vhdx\)' } + } +} + Describe 'Format-CreationPlan' { # The screen that asks for consent; nothing below it could be tested until it became a function. It 'names in the plan only what that mode does' -TestCases @( diff --git a/dev_drive.ps1 b/dev_drive.ps1 index 4e8b207..1ba38ba 100644 --- a/dev_drive.ps1 +++ b/dev_drive.ps1 @@ -2186,7 +2186,7 @@ function Request-VhdxPath { Write-Host "" while ($true) { - $verdict = Resolve-VhdxPathInput -Answer (Read-Host "Path of the .vhdx file").Trim('"', ' ') + $verdict = Resolve-VhdxPathInput -Answer (Read-Host "Path of the .vhdx file (E.g. D:\DevDrive.vhdx)").Trim('"', ' ') if ($verdict.Rejection -eq 'Empty') { Write-Host "Path cannot be empty." -ForegroundColor Red