grokkit/internal/git/git_test.go
Greg Gauthier e355142c05 feat: add CI/CD workflows, persistent chat, shell completions, and testing
- Add Gitea CI workflow for testing, linting, and building
- Add release workflow for multi-platform builds and GitHub releases
- Implement persistent chat history with JSON storage
- Add shell completion generation for bash, zsh, fish, powershell
- Introduce custom error types and logging system
- Add interfaces for git and AI client for better testability
- Enhance config with temperature and timeout settings
- Add comprehensive unit tests for config, errors, git, grok, and logger
- Update README with installation, features, and development instructions
- Make model flag persistent across commands
- Add context timeouts to API requests
2026-03-01 12:17:22 +00:00

67 lines
1.3 KiB
Go

package git
import (
"testing"
)
func TestIsRepo(t *testing.T) {
// This test assumes we're running in a git repo
result := IsRepo()
if !result {
t.Log("Warning: Not in a git repository, test may be running in unexpected environment")
}
}
func TestRun(t *testing.T) {
tests := []struct {
name string
args []string
shouldErr bool
}{
{
name: "version command succeeds",
args: []string{"--version"},
shouldErr: false,
},
{
name: "invalid command fails",
args: []string{"invalid-command-xyz"},
shouldErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
output, err := Run(tt.args)
if tt.shouldErr {
if err == nil {
t.Errorf("Run() expected error, got nil")
}
} else {
if err != nil {
t.Errorf("Run() unexpected error: %v", err)
}
if output == "" {
t.Errorf("Run() expected output, got empty string")
}
}
})
}
}
func TestGitRunner(t *testing.T) {
runner := NewRunner()
// Test Run
output, err := runner.Run([]string{"--version"})
if err != nil {
t.Errorf("GitRunner.Run() unexpected error: %v", err)
}
if output == "" {
t.Errorf("GitRunner.Run() expected output, got empty string")
}
// Test IsRepo
_ = runner.IsRepo() // Just ensure it doesn't panic
}