2014-01-02 11:48:22 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
@test "prints usage help given no argument" {
|
|
|
|
run pyenv-hooks
|
|
|
|
assert_failure "Usage: pyenv hooks <command>"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "prints list of hooks" {
|
|
|
|
path1="${PYENV_TEST_DIR}/pyenv.d"
|
|
|
|
path2="${PYENV_TEST_DIR}/etc/pyenv_hooks"
|
2016-03-01 20:39:52 -05:00
|
|
|
PYENV_HOOK_PATH="$path1"
|
2015-12-29 11:01:10 -05:00
|
|
|
create_hook exec "hello.bash"
|
|
|
|
create_hook exec "ahoy.bash"
|
|
|
|
create_hook exec "invalid.sh"
|
|
|
|
create_hook which "boom.bash"
|
2016-03-01 20:39:52 -05:00
|
|
|
PYENV_HOOK_PATH="$path2"
|
2015-12-29 11:01:10 -05:00
|
|
|
create_hook exec "bueno.bash"
|
2014-01-02 11:48:22 -05:00
|
|
|
|
|
|
|
PYENV_HOOK_PATH="$path1:$path2" run pyenv-hooks exec
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
${PYENV_TEST_DIR}/pyenv.d/exec/ahoy.bash
|
|
|
|
${PYENV_TEST_DIR}/pyenv.d/exec/hello.bash
|
|
|
|
${PYENV_TEST_DIR}/etc/pyenv_hooks/exec/bueno.bash
|
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "supports hook paths with spaces" {
|
|
|
|
path1="${PYENV_TEST_DIR}/my hooks/pyenv.d"
|
|
|
|
path2="${PYENV_TEST_DIR}/etc/pyenv hooks"
|
2016-03-01 20:39:52 -05:00
|
|
|
PYENV_HOOK_PATH="$path1"
|
2015-12-29 11:01:10 -05:00
|
|
|
create_hook exec "hello.bash"
|
2016-03-01 20:39:52 -05:00
|
|
|
PYENV_HOOK_PATH="$path2"
|
2015-12-29 11:01:10 -05:00
|
|
|
create_hook exec "ahoy.bash"
|
2014-01-02 11:48:22 -05:00
|
|
|
|
|
|
|
PYENV_HOOK_PATH="$path1:$path2" run pyenv-hooks exec
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
${PYENV_TEST_DIR}/my hooks/pyenv.d/exec/hello.bash
|
|
|
|
${PYENV_TEST_DIR}/etc/pyenv hooks/exec/ahoy.bash
|
|
|
|
OUT
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "resolves relative paths" {
|
2016-03-01 20:39:52 -05:00
|
|
|
PYENV_HOOK_PATH="${PYENV_TEST_DIR}/pyenv.d"
|
2015-12-29 11:01:10 -05:00
|
|
|
create_hook exec "hello.bash"
|
2014-01-02 11:48:22 -05:00
|
|
|
mkdir -p "$HOME"
|
|
|
|
|
|
|
|
PYENV_HOOK_PATH="${HOME}/../pyenv.d" run pyenv-hooks exec
|
|
|
|
assert_success "${PYENV_TEST_DIR}/pyenv.d/exec/hello.bash"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "resolves symlinks" {
|
|
|
|
path="${PYENV_TEST_DIR}/pyenv.d"
|
|
|
|
mkdir -p "${path}/exec"
|
|
|
|
mkdir -p "$HOME"
|
|
|
|
touch "${HOME}/hola.bash"
|
|
|
|
ln -s "../../home/hola.bash" "${path}/exec/hello.bash"
|
2015-10-27 15:50:14 -04:00
|
|
|
touch "${path}/exec/bright.sh"
|
|
|
|
ln -s "bright.sh" "${path}/exec/world.bash"
|
2014-01-02 11:48:22 -05:00
|
|
|
|
|
|
|
PYENV_HOOK_PATH="$path" run pyenv-hooks exec
|
2015-10-27 15:50:14 -04:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
${HOME}/hola.bash
|
2015-11-20 23:13:52 -05:00
|
|
|
${PYENV_TEST_DIR}/pyenv.d/exec/bright.sh
|
2015-10-27 15:50:14 -04:00
|
|
|
OUT
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|