grokkit/config/config_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

57 lines
1.1 KiB
Go

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) {
result := GetModel(tt.flagModel)
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")
result := GetModel("beta")
expected := "grok-beta-2"
if result != expected {
t.Errorf("GetModel('beta') = %q, want %q", result, expected)
}
}
func TestLoad(t *testing.T) {
// Just ensure Load doesn't panic
Load()
}