mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
add tests for completions
This commit is contained in:
parent
9b58b6642e
commit
4d96d0a6c6
1 changed files with 48 additions and 0 deletions
48
test/completions.bats
Normal file
48
test/completions.bats
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
create_command() {
|
||||||
|
bin="${RBENV_TEST_DIR}/bin"
|
||||||
|
mkdir -p "$bin"
|
||||||
|
echo "$2" > "${bin}/$1"
|
||||||
|
chmod +x "${bin}/$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "command with no completion support" {
|
||||||
|
create_command "rbenv-hello" "#!$BASH
|
||||||
|
echo hello"
|
||||||
|
run rbenv-completions hello
|
||||||
|
assert_success ""
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "command with completion support" {
|
||||||
|
create_command "rbenv-hello" "#!$BASH
|
||||||
|
# provide rbenv completions
|
||||||
|
if [[ \$1 = --complete ]]; then
|
||||||
|
echo hello
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi"
|
||||||
|
run rbenv-completions hello
|
||||||
|
assert_success "hello"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "forwards extra arguments" {
|
||||||
|
create_command "rbenv-hello" "#!$BASH
|
||||||
|
# provide rbenv completions
|
||||||
|
if [[ \$1 = --complete ]]; then
|
||||||
|
shift 1
|
||||||
|
while [[ \$# -gt 0 ]]; do
|
||||||
|
echo \$1
|
||||||
|
shift 1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi"
|
||||||
|
run rbenv-completions hello happy world
|
||||||
|
assert_success
|
||||||
|
assert_line 0 "happy"
|
||||||
|
assert_line 1 "world"
|
||||||
|
refute_line 2
|
||||||
|
}
|
Loading…
Reference in a new issue