...
1 package cmd
2
3 import (
4 "testing"
5 )
6
7 func TestCompletion(t *testing.T) {
8 t.Run("Returns completion code", func(t *testing.T) {
9
10 _, err := getCompletion("bash", RootCmd)
11 if err != nil {
12 t.Fatalf("Unexpected error: %+v", err)
13 }
14
15 _, err = getCompletion("zsh", RootCmd)
16 if err != nil {
17 t.Fatalf("Unexpected error: %+v", err)
18 }
19 })
20
21 t.Run("Fails with invalid shell type", func(t *testing.T) {
22 out, err := getCompletion("foo", RootCmd)
23 if err == nil {
24 t.Fatalf("Unexpected success for invalid shell type: %+v", out)
25 }
26 })
27 }
28
View as plain text