Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

74 lignes
1.5 KiB

  1. #!/usr/bin/env bats
  2. load test_helper
  3. setup() {
  4. mkdir -p "$HOME"
  5. git config --global user.name "Tester"
  6. git config --global user.email "tester@test.local"
  7. mkdir -p "${PYENV_TEST_DIR}/bin"
  8. cat > "${PYENV_TEST_DIR}/bin/git" <<CMD
  9. #!$BASH
  10. if [[ \$1 == remote && \$PWD != "\$PYENV_TEST_DIR"/* ]]; then
  11. echo "not allowed" >&2
  12. exit 1
  13. else
  14. exec $(which git) "\$@"
  15. fi
  16. CMD
  17. chmod +x "${PYENV_TEST_DIR}/bin/git"
  18. }
  19. git_commit() {
  20. git commit --quiet --allow-empty -m "empty"
  21. }
  22. @test "default version" {
  23. assert [ ! -e "$PYENV_ROOT" ]
  24. run pyenv---version
  25. assert_success
  26. [[ $output == "pyenv 20"* ]]
  27. }
  28. @test "doesn't read version from non-pyenv repo" {
  29. mkdir -p "$PYENV_ROOT"
  30. cd "$PYENV_ROOT"
  31. git init
  32. git remote add origin https://github.com/homebrew/homebrew.git
  33. git_commit
  34. git tag v1.0
  35. cd "$PYENV_TEST_DIR"
  36. run pyenv---version
  37. assert_success
  38. [[ $output == "pyenv 20"* ]]
  39. }
  40. @test "reads version from git repo" {
  41. mkdir -p "$PYENV_ROOT"
  42. cd "$PYENV_ROOT"
  43. git init
  44. git remote add origin https://github.com/yyuu/pyenv.git
  45. git_commit
  46. git tag v20380119
  47. git_commit
  48. git_commit
  49. cd "$PYENV_TEST_DIR"
  50. run pyenv---version
  51. assert_success
  52. [[ $output == "pyenv 20380119-2-g"* ]]
  53. }
  54. @test "prints default version if no tags in git repo" {
  55. mkdir -p "$PYENV_ROOT"
  56. cd "$PYENV_ROOT"
  57. git init
  58. git remote add origin https://github.com/yyuu/pyenv.git
  59. git_commit
  60. cd "$PYENV_TEST_DIR"
  61. run pyenv---version
  62. [[ $output == "pyenv 20"* ]]
  63. }