1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-16 23:33:45 -05:00

Use create_hook helper

Use extracted create_hook helper in tests for:

- exec
- hooks
- rehash
- version-name
- version-origin
- which
This commit is contained in:
Jason Karns
2015-12-29 11:01:10 -05:00
parent 5ccba5d7cc
commit 0f7a2cad8d
6 changed files with 23 additions and 37 deletions

View File

@@ -2,11 +2,6 @@
load test_helper
create_hook() {
mkdir -p "$1/$2"
touch "$1/$2/$3"
}
@test "prints usage help given no argument" {
run rbenv-hooks
assert_failure "Usage: rbenv hooks <command>"
@@ -15,11 +10,13 @@ create_hook() {
@test "prints list of hooks" {
path1="${RBENV_TEST_DIR}/rbenv.d"
path2="${RBENV_TEST_DIR}/etc/rbenv_hooks"
create_hook "$path1" exec "hello.bash"
create_hook "$path1" exec "ahoy.bash"
create_hook "$path1" exec "invalid.sh"
create_hook "$path1" which "boom.bash"
create_hook "$path2" exec "bueno.bash"
RBENV_HOOK_PATH="$path1"
create_hook exec "hello.bash"
create_hook exec "ahoy.bash"
create_hook exec "invalid.sh"
create_hook which "boom.bash"
RBENV_HOOK_PATH="$path2"
create_hook exec "bueno.bash"
RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec
assert_success
@@ -33,8 +30,10 @@ OUT
@test "supports hook paths with spaces" {
path1="${RBENV_TEST_DIR}/my hooks/rbenv.d"
path2="${RBENV_TEST_DIR}/etc/rbenv hooks"
create_hook "$path1" exec "hello.bash"
create_hook "$path2" exec "ahoy.bash"
RBENV_HOOK_PATH="$path1"
create_hook exec "hello.bash"
RBENV_HOOK_PATH="$path2"
create_hook exec "ahoy.bash"
RBENV_HOOK_PATH="$path1:$path2" run rbenv-hooks exec
assert_success
@@ -45,8 +44,8 @@ OUT
}
@test "resolves relative paths" {
path="${RBENV_TEST_DIR}/rbenv.d"
create_hook "$path" exec "hello.bash"
RBENV_HOOK_PATH="${RBENV_TEST_DIR}/rbenv.d"
create_hook exec "hello.bash"
mkdir -p "$HOME"
RBENV_HOOK_PATH="${HOME}/../rbenv.d" run rbenv-hooks exec