Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

77 linhas
2.0 KiB

  1. #!/usr/bin/env bats
  2. load test_helper
  3. @test "blank invocation" {
  4. run pyenv
  5. assert_failure
  6. assert_line 0 "$(pyenv---version)"
  7. }
  8. @test "invalid command" {
  9. run pyenv does-not-exist
  10. assert_failure
  11. assert_output "pyenv: no such command \`does-not-exist'"
  12. }
  13. @test "default PYENV_ROOT" {
  14. PYENV_ROOT="" HOME=/home/mislav run pyenv root
  15. assert_success
  16. assert_output "/home/mislav/.pyenv"
  17. }
  18. @test "inherited PYENV_ROOT" {
  19. PYENV_ROOT=/opt/pyenv run pyenv root
  20. assert_success
  21. assert_output "/opt/pyenv"
  22. }
  23. @test "default PYENV_DIR" {
  24. run pyenv echo PYENV_DIR
  25. assert_output "$(pwd)"
  26. }
  27. @test "inherited PYENV_DIR" {
  28. dir="${BATS_TMPDIR}/myproject"
  29. mkdir -p "$dir"
  30. PYENV_DIR="$dir" run pyenv echo PYENV_DIR
  31. assert_output "$dir"
  32. }
  33. @test "invalid PYENV_DIR" {
  34. dir="${BATS_TMPDIR}/does-not-exist"
  35. assert [ ! -d "$dir" ]
  36. PYENV_DIR="$dir" run pyenv echo PYENV_DIR
  37. assert_failure
  38. assert_output "pyenv: cannot change working directory to \`$dir'"
  39. }
  40. @test "adds its own libexec to PATH" {
  41. run pyenv echo "PATH"
  42. assert_success "${BATS_TEST_DIRNAME%/*}/libexec:${BATS_TEST_DIRNAME%/*}/plugins/python-build/bin:$PATH"
  43. }
  44. @test "adds plugin bin dirs to PATH" {
  45. mkdir -p "$PYENV_ROOT"/plugins/python-build/bin
  46. mkdir -p "$PYENV_ROOT"/plugins/pyenv-each/bin
  47. run pyenv echo -F: "PATH"
  48. assert_success
  49. assert_line 0 "${BATS_TEST_DIRNAME%/*}/libexec"
  50. assert_line 1 "${PYENV_ROOT}/plugins/python-build/bin"
  51. assert_line 2 "${PYENV_ROOT}/plugins/pyenv-each/bin"
  52. assert_line 3 "${BATS_TEST_DIRNAME%/*}/plugins/python-build/bin"
  53. }
  54. @test "PYENV_HOOK_PATH preserves value from environment" {
  55. PYENV_HOOK_PATH=/my/hook/path:/other/hooks run pyenv echo -F: "PYENV_HOOK_PATH"
  56. assert_success
  57. assert_line 0 "/my/hook/path"
  58. assert_line 1 "/other/hooks"
  59. assert_line 2 "${PYENV_ROOT}/pyenv.d"
  60. }
  61. @test "PYENV_HOOK_PATH includes pyenv built-in plugins" {
  62. unset PYENV_HOOK_PATH
  63. run pyenv echo "PYENV_HOOK_PATH"
  64. assert_success "${PYENV_ROOT}/pyenv.d:${BATS_TEST_DIRNAME%/*}/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks"
  65. }