grokkit/cmd/completion_test.go
Greg Gauthier ebb0cbcf3a
Some checks failed
CI / Test (push) Failing after 26s
CI / Lint (push) Has been skipped
CI / Build (push) Has been skipped
test(cmd): add unit tests for completion, root execution, config, errors, and logger
- Add tests for shell completion generation in completion_test.go
- Add tests for root command execution and flags in root_test.go
- Expand config tests for temperature, timeout, and log level getters
- Add APIError unwrap test in errors_test.go
- Add WithContext tests in logger_test.go
- Stage test output artifact in .output.txt
2026-03-02 22:12:54 +00:00

43 lines
691 B
Go

package cmd
import (
"io"
"os"
"testing"
"github.com/spf13/cobra"
)
func TestCompletionCmd(t *testing.T) {
tests := []struct {
shell string
}{
{"bash"},
{"zsh"},
{"fish"},
{"powershell"},
}
for _, tt := range tests {
t.Run(tt.shell, func(t *testing.T) {
oldStdout := os.Stdout
defer func() { os.Stdout = oldStdout }()
r, w, err := os.Pipe()
if err != nil {
t.Fatal(err)
}
os.Stdout = w
defer w.Close()
cmd := &cobra.Command{}
completionCmd.Run(cmd, []string{tt.shell})
w.Close()
b, err := io.ReadAll(r)
if err != nil {
t.Fatal(err)
}
if len(b) == 0 {
t.Error("expected non-empty completion script")
}
})
}
}