From 0f0e938dfbfb455dde7456fe8bb01b296ec3d790 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Wed, 18 Dec 2024 16:37:11 -0500 Subject: [PATCH] feat(golang-rewrite): add simple test for completions package --- internal/completions/completions_test.go | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 internal/completions/completions_test.go diff --git a/internal/completions/completions_test.go b/internal/completions/completions_test.go new file mode 100644 index 00000000..a001fd5c --- /dev/null +++ b/internal/completions/completions_test.go @@ -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()) + }) +}