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
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestGetModel(t *testing.T) {
|
|
|
|
|
// Reset viper for testing
|
|
|
|
|
viper.Reset()
|
|
|
|
|
viper.SetDefault("default_model", "grok-4")
|
|
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
flagModel string
|
|
|
|
|
expected string
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "returns flag model when provided",
|
|
|
|
|
flagModel: "grok-beta",
|
|
|
|
|
expected: "grok-beta",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "returns default when flag empty",
|
|
|
|
|
flagModel: "",
|
|
|
|
|
expected: "grok-4",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2026-03-02 16:56:56 +00:00
|
|
|
result := GetModel("", tt.flagModel)
|
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
|
|
|
if result != tt.expected {
|
|
|
|
|
t.Errorf("GetModel(%q) = %q, want %q", tt.flagModel, result, tt.expected)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGetModelWithAlias(t *testing.T) {
|
|
|
|
|
viper.Reset()
|
|
|
|
|
viper.Set("aliases.beta", "grok-beta-2")
|
|
|
|
|
viper.SetDefault("default_model", "grok-4")
|
|
|
|
|
|
2026-03-02 16:56:56 +00:00
|
|
|
result := GetModel("", "beta")
|
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
|
|
|
expected := "grok-beta-2"
|
|
|
|
|
if result != expected {
|
|
|
|
|
t.Errorf("GetModel('beta') = %q, want %q", result, expected)
|
2026-03-02 16:56:56 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGetCommandModel(t *testing.T) {
|
|
|
|
|
viper.Reset()
|
|
|
|
|
viper.SetDefault("default_model", "grok-4")
|
|
|
|
|
viper.Set("commands.lint.model", "grok-4-1-fast-non-reasoning")
|
|
|
|
|
viper.Set("commands.other.model", "grok-other")
|
|
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
|
command string
|
|
|
|
|
flagModel string
|
|
|
|
|
expected string
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
command: "lint",
|
|
|
|
|
flagModel: "",
|
|
|
|
|
expected: "grok-4-1-fast-non-reasoning",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "lint",
|
|
|
|
|
flagModel: "override",
|
|
|
|
|
expected: "override",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "other",
|
|
|
|
|
flagModel: "",
|
|
|
|
|
expected: "grok-other",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
command: "unknown",
|
|
|
|
|
flagModel: "",
|
|
|
|
|
expected: "grok-4",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.command+"_"+tt.flagModel, func(t *testing.T) {
|
|
|
|
|
result := GetModel(tt.command, tt.flagModel)
|
|
|
|
|
if result != tt.expected {
|
|
|
|
|
t.Errorf("GetModel(%q, %q) = %q, want %q", tt.command, tt.flagModel, result, tt.expected)
|
|
|
|
|
}
|
|
|
|
|
})
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestLoad(t *testing.T) {
|
|
|
|
|
// Just ensure Load doesn't panic
|
|
|
|
|
Load()
|
|
|
|
|
}
|