Files
multica/server/internal/metrics/pricing_test.go

46 lines
1.5 KiB
Go

package metrics
import "testing"
func TestPriceForModelAliasAnthropicFableAndOpus48(t *testing.T) {
cases := []struct {
model string
want ModelPrice
}{
{
model: "claude-sonnet-5",
want: ModelPrice{Provider: "anthropic", Model: "claude-sonnet-5", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 10},
},
{
model: "anthropic:claude-sonnet-5",
want: ModelPrice{Provider: "anthropic", Model: "claude-sonnet-5", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 10},
},
{
model: "claude-5-sonnet",
want: ModelPrice{Provider: "anthropic", Model: "claude-sonnet-5", InputPerM: 2, CacheReadPerM: 0.2, CacheWritePerM: 2.5, OutputPerM: 10},
},
{
model: "claude-fable-5",
want: ModelPrice{Provider: "anthropic", Model: "claude-fable-5", InputPerM: 10, CacheReadPerM: 1, CacheWritePerM: 12.5, OutputPerM: 50},
},
{
model: "anthropic/claude-fable-5",
want: ModelPrice{Provider: "anthropic", Model: "claude-fable-5", InputPerM: 10, CacheReadPerM: 1, CacheWritePerM: 12.5, OutputPerM: 50},
},
{
model: "claude-opus-4-8",
want: ModelPrice{Provider: "anthropic", Model: "claude-opus-4.8", InputPerM: 5, CacheReadPerM: 0.5, CacheWritePerM: 6.25, OutputPerM: 25},
},
}
for _, tc := range cases {
got, ok := PriceForModelAlias(tc.model)
if !ok {
t.Fatalf("PriceForModelAlias(%q) did not resolve", tc.model)
}
if got != tc.want {
t.Fatalf("PriceForModelAlias(%q) = %+v, want %+v", tc.model, got, tc.want)
}
}
}