Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dev_drive.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Mode> plan only what that mode does' -TestCases @(
Expand Down
2 changes: 1 addition & 1 deletion dev_drive.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading