Skip to content

Commit

Permalink
feat: add completion test for zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 17, 2023
1 parent 5e8bc3d commit d417f30
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/gotest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
26 changes: 26 additions & 0 deletions test/cli/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
}

0 comments on commit d417f30

Please sign in to comment.