2014-01-02 11:48:22 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
|
|
|
|
create_command() {
|
|
|
|
bin="${PYENV_TEST_DIR}/bin"
|
|
|
|
mkdir -p "$bin"
|
|
|
|
echo "$2" > "${bin}/$1"
|
|
|
|
chmod +x "${bin}/$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "command with no completion support" {
|
|
|
|
create_command "pyenv-hello" "#!$BASH
|
|
|
|
echo hello"
|
|
|
|
run pyenv-completions hello
|
2015-11-17 15:01:33 -05:00
|
|
|
assert_success "--help"
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "command with completion support" {
|
|
|
|
create_command "pyenv-hello" "#!$BASH
|
2014-01-02 14:58:29 -05:00
|
|
|
# Provide pyenv completions
|
2014-01-02 11:48:22 -05:00
|
|
|
if [[ \$1 = --complete ]]; then
|
|
|
|
echo hello
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi"
|
|
|
|
run pyenv-completions hello
|
2015-11-17 15:01:33 -05:00
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
|
|
|
--help
|
|
|
|
hello
|
|
|
|
OUT
|
2014-01-02 11:48:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "forwards extra arguments" {
|
|
|
|
create_command "pyenv-hello" "#!$BASH
|
|
|
|
# provide pyenv completions
|
|
|
|
if [[ \$1 = --complete ]]; then
|
|
|
|
shift 1
|
|
|
|
for arg; do echo \$arg; done
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi"
|
|
|
|
run pyenv-completions hello happy world
|
|
|
|
assert_success
|
|
|
|
assert_output <<OUT
|
2015-11-17 15:01:33 -05:00
|
|
|
--help
|
2014-01-02 11:48:22 -05:00
|
|
|
happy
|
|
|
|
world
|
|
|
|
OUT
|
|
|
|
}
|