Files
GopherGate/internal/models/registry_test.go
T
hobokenchicken af2c5b95f7
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled
feat: Phase 3 - architecture & maintainability
- Split 1474-line dashboard.go into 5 domain files (clients, providers, users, system)
- Unit tests for ModelRegistry.FindModel and CalculateCost
- go mod tidy + verify (deps clean)
- .gitignore excludes tool cache dirs (.pi-lens/, .opencode/)
2026-04-26 14:52:10 -04:00

61 lines
1.2 KiB
Go

package models
import (
"testing"
)
func TestModelRegistry_FindModel_Exact(t *testing.T) {
r := &ModelRegistry{
Providers: map[string]ProviderInfo{
"openai": {
Models: map[string]ModelMetadata{
"gpt-4o": {ID: "gpt-4o", Name: "GPT-4o"},
},
},
},
}
m := r.FindModel("gpt-4o")
if m == nil {
t.Fatal("expected to find gpt-4o")
}
if m.Name != "GPT-4o" {
t.Fatalf("expected GPT-4o, got %s", m.Name)
}
}
func TestModelRegistry_FindModel_Fuzzy(t *testing.T) {
r := &ModelRegistry{
Providers: map[string]ProviderInfo{
"openai": {
Models: map[string]ModelMetadata{
"gpt-4o": {ID: "gpt-4o", Name: "GPT-4o"},
},
},
},
}
// Fuzzy: "gpt-4o-2024-05-13" should match "gpt-4o"
m := r.FindModel("gpt-4o-2024-05-13")
if m == nil {
t.Fatal("expected fuzzy match")
}
if m.Name != "GPT-4o" {
t.Fatalf("expected GPT-4o, got %s", m.Name)
}
}
func TestModelRegistry_FindModel_NotFound(t *testing.T) {
r := &ModelRegistry{
Providers: map[string]ProviderInfo{
"openai": {
Models: map[string]ModelMetadata{
"gpt-4o": {ID: "gpt-4o", Name: "GPT-4o"},
},
},
},
}
m := r.FindModel("nonexistent-model")
if m != nil {
t.Fatal("expected nil for nonexistent model")
}
}