Completed test suite for Bash-it completion

pull/1043/head
Nils Winkler 2017-09-15 08:10:17 +02:00
parent cd578f8772
commit 5c66f478dd
2 changed files with 93 additions and 5 deletions

View File

@ -65,10 +65,10 @@ _bash-it-comp()
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
chose_opt="${COMP_WORDS[1]}" chose_opt="${COMP_WORDS[1]}"
file_type="${COMP_WORDS[2]}" file_type="${COMP_WORDS[2]}"
opts="help show enable disable update search migrate" opts="disable enable help migrate search show update"
case "${chose_opt}" in case "${chose_opt}" in
show) show)
local show_args="plugins aliases completions" local show_args="aliases completions plugins"
COMPREPLY=( $(compgen -W "${show_args}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${show_args}" -- ${cur}) )
return 0 return 0
;; ;;
@ -77,7 +77,7 @@ _bash-it-comp()
_bash-it-comp-list-available aliases _bash-it-comp-list-available aliases
return 0 return 0
else else
local help_args="plugins aliases completions migrate update" local help_args="aliases completions migrate plugins update"
COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) )
return 0 return 0
fi fi

View File

@ -72,11 +72,76 @@ function __check_completion () {
echo "${COMPREPLY[@]}" echo "${COMPREPLY[@]}"
} }
@test "completion bash-it: help aliases" { @test "completion bash-it: help - show options" {
run __check_completion 'bash-it help '
assert_line "0" "aliases completions migrate plugins update"
}
@test "completion bash-it: help - aliases v" {
run __check_completion 'bash-it help aliases v' run __check_completion 'bash-it help aliases v'
assert_line "0" "vagrant vault vim" assert_line "0" "vagrant vault vim"
} }
@test "completion bash-it: update - show no options" {
run __check_completion 'bash-it update '
assert_line "0" ""
}
@test "completion bash-it: search - show no options" {
run __check_completion 'bash-it search '
assert_line "0" ""
}
@test "completion bash-it: migrate - show no options" {
run __check_completion 'bash-it migrate '
assert_line "0" ""
}
@test "completion bash-it: show options" {
run __check_completion 'bash-it '
assert_line "0" "disable enable help migrate search show update"
}
@test "completion bash-it: bash-ti - show options" {
run __check_completion 'bash-ti '
assert_line "0" "disable enable help migrate search show update"
}
@test "completion bash-it: shit - show options" {
run __check_completion 'shit '
assert_line "0" "disable enable help migrate search show update"
}
@test "completion bash-it: bashit - show options" {
run __check_completion 'bashit '
assert_line "0" "disable enable help migrate search show update"
}
@test "completion bash-it: batshit - show options" {
run __check_completion 'batshit '
assert_line "0" "disable enable help migrate search show update"
}
@test "completion bash-it: bash_it - show options" {
run __check_completion 'bash_it '
assert_line "0" "disable enable help migrate search show update"
}
@test "completion bash-it: show - show options" {
run __check_completion 'bash-it show '
assert_line "0" "aliases completions plugins"
}
@test "completion bash-it: enable - show options" {
run __check_completion 'bash-it enable '
assert_line "0" "alias completion plugin"
}
@test "completion bash-it: enable - show options a" {
run __check_completion 'bash-it enable a'
assert_line "0" "alias"
}
@test "completion bash-it: disable - show options" { @test "completion bash-it: disable - show options" {
run __check_completion 'bash-it disable ' run __check_completion 'bash-it disable '
assert_line "0" "alias completion plugin" assert_line "0" "alias completion plugin"
@ -84,7 +149,6 @@ function __check_completion () {
@test "completion bash-it: disable - show options a" { @test "completion bash-it: disable - show options a" {
run __check_completion 'bash-it disable a' run __check_completion 'bash-it disable a'
assert_line "0" "alias" assert_line "0" "alias"
} }
@ -255,6 +319,30 @@ function __check_completion () {
assert_line "0" "docker-compose docker-machine docker" assert_line "0" "docker-compose docker-machine docker"
} }
@test "completion bash-it: enable - provide the docker-* completions when nothing is enabled with the old location and name" {
ln -s $BASH_IT/aliases/available/docker-compose.aliases.bash $BASH_IT/aliases/enabled/docker-compose.aliases.bash
assert [ -L "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" ]
run __check_completion 'bash-it enable completion docker'
assert_line "0" "docker docker-compose docker-machine"
}
@test "completion bash-it: enable - provide the docker-* completions when nothing is enabled with the old location and priority-based name" {
ln -s $BASH_IT/aliases/available/docker-compose.aliases.bash $BASH_IT/aliases/enabled/150---docker-compose.aliases.bash
assert [ -L "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" ]
run __check_completion 'bash-it enable completion docker'
assert_line "0" "docker docker-compose docker-machine"
}
@test "completion bash-it: enable - provide the docker-* completions when nothing is enabled with the new location and priority-based name" {
ln -s $BASH_IT/aliases/available/docker-compose.aliases.bash $BASH_IT/enabled/150---docker-compose.aliases.bash
assert [ -L "$BASH_IT/enabled/150---docker-compose.aliases.bash" ]
run __check_completion 'bash-it enable completion docker'
assert_line "0" "docker docker-compose docker-machine"
}
@test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and name" { @test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and name" {
ln -s $BASH_IT/plugins/available/todo.plugin.bash $BASH_IT/plugins/enabled/todo.plugin.bash ln -s $BASH_IT/plugins/available/todo.plugin.bash $BASH_IT/plugins/enabled/todo.plugin.bash
assert [ -L "$BASH_IT/plugins/enabled/todo.plugin.bash" ] assert [ -L "$BASH_IT/plugins/enabled/todo.plugin.bash" ]