Add test to verify filesystem provider isn't used when accessing root path in psdrive (#7173)
* add test to verify filesystem isn't used when not in filesystem drive
This commit is contained in:
parent
040c494f94
commit
e5e1c53084
|
@ -54,6 +54,22 @@ Describe "Set-Location" -Tags "CI" {
|
|||
$(Get-Location).Path | Should -BeExactly $testPath.FullName
|
||||
}
|
||||
|
||||
It "Should not use filesystem root folder if not in filesystem provider" -Skip:(!$IsWindows) {
|
||||
# find filesystem root folder that doesn't exist in HKCU:
|
||||
$foundFolder = $false
|
||||
foreach ($folder in Get-ChildItem "${env:SystemDrive}\" -Directory) {
|
||||
if (-Not (Test-Path "HKCU:\$($folder.Name)")) {
|
||||
$testFolder = $folder.Name
|
||||
$foundFolder = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
$foundFolder | Should -BeTrue
|
||||
Set-Location HKCU:\
|
||||
{ Set-Location ([System.IO.Path]::DirectorySeparatorChar + $testFolder) -ErrorAction Stop } |
|
||||
Should -Throw -ErrorId "PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand"
|
||||
}
|
||||
|
||||
Context 'Set-Location with no arguments' {
|
||||
|
||||
It 'Should go to $env:HOME when Set-Location run with no arguments from FileSystem provider' {
|
||||
|
|
Loading…
Reference in a new issue