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
+40
View File
@@ -0,0 +1,40 @@
package utils
import (
"testing"
"gophergate/internal/models"
)
func TestCalculateCost_NotFound(t *testing.T) {
r := &models.ModelRegistry{Providers: make(map[string]models.ProviderInfo)}
cost := CalculateCost(r, "unknown-model", 100, 50, 0, 0, 0)
if cost != 0.0 {
t.Fatalf("expected 0 cost for unknown model, got %f", cost)
}
}
func TestCalculateCost_KnownModel(t *testing.T) {
inputCost := 2.5 // $2.50 per 1M tokens
outputCost := 10.0 // $10.00 per 1M tokens
r := &models.ModelRegistry{
Providers: map[string]models.ProviderInfo{
"openai": {
Models: map[string]models.ModelMetadata{
"gpt-4o": {
Cost: &models.ModelCost{
Input: inputCost,
Output: outputCost,
},
},
},
},
},
}
cost := CalculateCost(r, "gpt-4o", 1000, 500, 0, 0, 0)
expected := (1000 * inputCost / 1000000.0) + (500 * outputCost / 1000000.0)
if cost != expected {
t.Fatalf("expected %f, got %f", expected, cost)
}
}