diff --git a/.github/workflows/gotest.yml b/.github/workflows/gotest.yml index 08a741532f01..630160fbb828 100644 --- a/.github/workflows/gotest.yml +++ b/.github/workflows/gotest.yml @@ -35,6 +35,8 @@ jobs: go-version: 1.19.x - name: Check out Kubo uses: actions/checkout@v3 + - name: Install missing tools + run: sudo apt update && sudo apt install -y zsh - name: Restore Go cache uses: protocol/cache-go-action@v1 with: diff --git a/test/cli/completion_test.go b/test/cli/completion_test.go index 0c40eb02b6e7..548cb17a2ffe 100644 --- a/test/cli/completion_test.go +++ b/test/cli/completion_test.go @@ -29,3 +29,29 @@ func TestBashCompletion(t *testing.T) { assert.NoError(t, res.Err) }) } + +func TestZshCompletion(t *testing.T) { + t.Parallel() + h := harness.NewT(t) + node := h.NewNode() + + res := node.IPFS("commands", "completion", "zsh") + + length := len(res.Stdout.String()) + if length < 100 { + t.Fatalf("expected a long Bash completion file, but got one of length %d", length) + } + + t.Run("completion file can be loaded in bash", func(t *testing.T) { + RequiresLinux(t) + + completionFile := h.WriteToTemp(res.Stdout.String()) + res = h.Runner.Run(harness.RunRequest{ + Path: "zsh", + Args: []string{"-c", fmt.Sprintf("autoload -Uz compinit && compinit && source %s && echo -E $_comps[ipfs]", completionFile)}, + }) + + assert.NoError(t, res.Err) + assert.NotEmpty(t, res.Stdout.String()) + }) +}