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) } }