Make sure we always return an object in command searcher (#9623)

This commit is contained in:
Travis Plunk 2019-05-20 11:22:34 -07:00 committed by Aditya Patwardhan
parent 94c1098e16
commit 1d94e8c947
2 changed files with 7 additions and 1 deletions

View file

@ -565,7 +565,7 @@ namespace System.Management.Automation
}
provider = null;
return null;
return new Collection<string>();
}
private static bool checkPath(string path, string commandName)

View file

@ -205,4 +205,10 @@ Describe "Command Discovery tests" -Tags "CI" {
}
}
}
Context "error cases" {
It 'Get-Command "less `"-PsPage %db?B of %DoesNotExist:`"" should throw Drive not found' {
{Get-Command -Name "less `"-PsPage %db?B of %DoesNotExist:`""} | Should -Throw -ErrorId 'DriveNotFound' -Because "The drive 'DoesNotExist:' should not exist"
}
}
}