feat: Phase 3 - architecture & maintainability
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

- 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/)
This commit is contained in:
2026-04-26 14:52:10 -04:00
parent 1f574d8134
commit af2c5b95f7
9 changed files with 904 additions and 954 deletions
+60
View File
@@ -0,0 +1,60 @@
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")
}
}