diff --git a/test/init.bats b/test/init.bats index 21109c94..564153f2 100755 --- a/test/init.bats +++ b/test/init.bats @@ -63,6 +63,19 @@ OUT assert_line 'pyenv init - | source' } +@test "setup shell completions (pwsh)" { + root="$(cd $BATS_TEST_DIRNAME/.. && pwd)" + run pyenv-init - pwsh + assert_success + assert_line "iex (gc ${root}/test/../libexec/../completions/pyenv.pwsh -Raw)" +} + +@test "pwsh instructions" { + run pyenv-init pwsh + assert [ "$status" -eq 1 ] + assert_line 'iex ((pyenv init -) -join "`n")' +} + @test "shell detection for installer" { run pyenv-init --detect-shell assert_success @@ -89,6 +102,13 @@ OUT assert_line "set -gx PATH '${PYENV_ROOT}/shims' \$PATH" } +@test "adds shims to PATH (pwsh)" { + export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin" + run pyenv-init - pwsh + assert_success + assert_line '$Env:PATH="'${PYENV_ROOT}'/shims:$Env:PATH"' +} + @test "removes existing shims from PATH" { OLDPATH="$PATH" export PATH="${BATS_TEST_DIRNAME}/nonexistent:${PYENV_ROOT}/shims:$PATH" @@ -113,6 +133,19 @@ echo "\$PATH" assert_output "${PYENV_ROOT}/shims:${BATS_TEST_DIRNAME}/nonexistent:${OLDPATH//${PYENV_ROOT}\/shims:/}" } +@test "removes existing shims from PATH (pwsh)" { + command -v pwsh >/dev/null || skip "-- pwsh not installed" + OLDPATH="$PATH" + export PATH="${BATS_TEST_DIRNAME}/nonexistent:${PYENV_ROOT}/shims:$PATH" + run pwsh -noni -c - </dev/null || skip "-- pwsh not installed" + export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:/bin:/usr/local/bin" + run pwsh -noni -c - </dev/null || skip "-- pwsh not installed" + export PATH="${BATS_TEST_DIRNAME}/../libexec:/usr/bin:${PYENV_ROOT}/shims:/bin:/usr/local/bin" + run pwsh -noni -c - <