mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-12-23 20:05:09 -07:00
feat(golang-rewrite): add simple test for completions package
This commit is contained in:
parent
58634cfd7a
commit
0f0e938dfb
30
internal/completions/completions_test.go
Normal file
30
internal/completions/completions_test.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package completions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGet(t *testing.T) {
|
||||||
|
t.Run("returns file when completion file found with matching name", func(t *testing.T) {
|
||||||
|
file, found := Get("bash")
|
||||||
|
|
||||||
|
info, err := file.Stat()
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, "asdf.bash", info.Name())
|
||||||
|
|
||||||
|
assert.True(t, found)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("returns false when completion file not found", func(t *testing.T) {
|
||||||
|
_, found := Get("non-existent")
|
||||||
|
assert.False(t, found)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNames(t *testing.T) {
|
||||||
|
t.Run("returns slice of shell names for which completion is available", func(t *testing.T) {
|
||||||
|
assert.Equal(t, []string{"bash", "elvish", "fish", "nushell", "zsh"}, Names())
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user