2026-02-13 09:28:07 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestGetModelPricing_Gpt53CodexSparkUsesGpt51CodexPricing(t *testing.T) {
|
|
|
|
|
sparkPricing := &LiteLLMModelPricing{InputCostPerToken: 1}
|
|
|
|
|
gpt53Pricing := &LiteLLMModelPricing{InputCostPerToken: 9}
|
|
|
|
|
|
|
|
|
|
svc := &PricingService{
|
|
|
|
|
pricingData: map[string]*LiteLLMModelPricing{
|
|
|
|
|
"gpt-5.1-codex": sparkPricing,
|
|
|
|
|
"gpt-5.3": gpt53Pricing,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
got := svc.GetModelPricing("gpt-5.3-codex-spark")
|
|
|
|
|
require.Same(t, sparkPricing, got)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestGetModelPricing_Gpt53CodexFallbackStillUsesGpt52Codex(t *testing.T) {
|
|
|
|
|
gpt52CodexPricing := &LiteLLMModelPricing{InputCostPerToken: 2}
|
|
|
|
|
|
|
|
|
|
svc := &PricingService{
|
|
|
|
|
pricingData: map[string]*LiteLLMModelPricing{
|
|
|
|
|
"gpt-5.2-codex": gpt52CodexPricing,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
got := svc.GetModelPricing("gpt-5.3-codex")
|
|
|
|
|
require.Same(t, gpt52CodexPricing, got)
|
|
|
|
|
}
|
2026-02-13 19:27:07 +08:00
|
|
|
|
|
|
|
|
func TestGetModelPricing_OpenAIFallbackMatchedLoggedAsInfo(t *testing.T) {
|
|
|
|
|
logSink, restore := captureStructuredLog(t)
|
|
|
|
|
defer restore()
|
|
|
|
|
|
|
|
|
|
gpt52CodexPricing := &LiteLLMModelPricing{InputCostPerToken: 2}
|
|
|
|
|
svc := &PricingService{
|
|
|
|
|
pricingData: map[string]*LiteLLMModelPricing{
|
|
|
|
|
"gpt-5.2-codex": gpt52CodexPricing,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
got := svc.GetModelPricing("gpt-5.3-codex")
|
|
|
|
|
require.Same(t, gpt52CodexPricing, got)
|
|
|
|
|
|
|
|
|
|
require.True(t, logSink.ContainsMessageAtLevel("[Pricing] OpenAI fallback matched gpt-5.3-codex -> gpt-5.2-codex", "info"))
|
|
|
|
|
require.False(t, logSink.ContainsMessageAtLevel("[Pricing] OpenAI fallback matched gpt-5.3-codex -> gpt-5.2-codex", "warn"))
|
|
|
|
|
}
|