57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package command
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestCompletion_bash(t *testing.T) {
|
|
output, err := RunCommand(completionCmd, `completion`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !strings.Contains(output.String(), "complete -o default -F __start_gh gh") {
|
|
t.Errorf("problem in bash completion:\n%s", output)
|
|
}
|
|
}
|
|
|
|
func TestCompletion_zsh(t *testing.T) {
|
|
output, err := RunCommand(completionCmd, `completion -s zsh`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !strings.Contains(output.String(), "#compdef _gh gh") {
|
|
t.Errorf("problem in zsh completion:\n%s", output)
|
|
}
|
|
}
|
|
|
|
func TestCompletion_fish(t *testing.T) {
|
|
output, err := RunCommand(completionCmd, `completion -s fish`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !strings.Contains(output.String(), "complete -c gh ") {
|
|
t.Errorf("problem in fish completion:\n%s", output)
|
|
}
|
|
}
|
|
|
|
func TestCompletion_powerShell(t *testing.T) {
|
|
output, err := RunCommand(completionCmd, `completion -s powershell`)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if !strings.Contains(output.String(), "Register-ArgumentCompleter") {
|
|
t.Errorf("problem in fish completion:\n%s", output)
|
|
}
|
|
}
|
|
|
|
func TestCompletion_unsupported(t *testing.T) {
|
|
_, err := RunCommand(completionCmd, `completion -s csh`)
|
|
if err == nil || err.Error() != `unsupported shell type "csh"` {
|
|
t.Fatal(err)
|
|
}
|
|
}
|