allow test to work in cases where you can't create $profile

This commit is contained in:
Steve Lee 2019-05-04 07:44:30 -07:00
parent 3b5663ee97
commit 592f897d21

View file

@ -269,8 +269,14 @@ Describe "ConsoleHost unit tests" -tags "Feature" {
){
param($switch)
Get-Content $profile -Raw | Should -Not -BeNullOrEmpty
& pwsh $switch -c exit | Should -BeExactly "profile-loaded"
if (Test-Path $profile) {
& pwsh $switch -command exit | Should -BeExactly "profile-loaded"
}
else {
# In CI, may not be able to write to $profile location, so just verify that the switch is accepted
# and no error message is in the output
& pwsh $switch -command exit *>&1 | Should -BeNullOrEmpty
}
}
}