You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 regels
880 B

  1. #!/usr/bin/env bats
  2. load test_helper
  3. create_command() {
  4. bin="${PYENV_TEST_DIR}/bin"
  5. mkdir -p "$bin"
  6. echo "$2" > "${bin}/$1"
  7. chmod +x "${bin}/$1"
  8. }
  9. @test "command with no completion support" {
  10. create_command "pyenv-hello" "#!$BASH
  11. echo hello"
  12. run pyenv-completions hello
  13. assert_success "--help"
  14. }
  15. @test "command with completion support" {
  16. create_command "pyenv-hello" "#!$BASH
  17. # Provide pyenv completions
  18. if [[ \$1 = --complete ]]; then
  19. echo hello
  20. else
  21. exit 1
  22. fi"
  23. run pyenv-completions hello
  24. assert_success
  25. assert_output <<OUT
  26. --help
  27. hello
  28. OUT
  29. }
  30. @test "forwards extra arguments" {
  31. create_command "pyenv-hello" "#!$BASH
  32. # provide pyenv completions
  33. if [[ \$1 = --complete ]]; then
  34. shift 1
  35. for arg; do echo \$arg; done
  36. else
  37. exit 1
  38. fi"
  39. run pyenv-completions hello happy world
  40. assert_success
  41. assert_output <<OUT
  42. --help
  43. happy
  44. world
  45. OUT
  46. }