File: completion_install_test.go

package info (click to toggle)
golang-github-willabides-kongplete 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: sh: 40; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 778 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package kongplete

import (
	"strings"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestInstallCompletion(t *testing.T) {
	tests := map[string]string{
		"zsh":  "autoload -U +X bashcompinit && bashcompinit\ncomplete -C /usr/bin/docker docker\n",
		"bash": "complete -C /usr/bin/docker docker\n",
		"fish": `function __complete_docker
    set -lx COMP_LINE (commandline -cp)
    test -z (commandline -ct)
    and set COMP_LINE "$COMP_LINE "
    /usr/bin/docker
end
complete -f -c docker -a "(__complete_docker)"
`,
	}
	for shell, fragment := range tests {
		t.Run(shell, func(t *testing.T) {
			w := &strings.Builder{}
			err := installCompletion(w, shell, "docker", "/usr/bin/docker")
			require.NoError(t, err)
			require.Equal(t, fragment, w.String())
		})
	}
}