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/)
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user