From 926d3cd86d8b104d59c1dfd474863d9a0223c953 Mon Sep 17 00:00:00 2001 From: shaw Date: Tue, 17 Nov 2026 09:25:25 +0800 Subject: [PATCH] =?UTF-8?q?test(billing):=20=E5=B0=86=20Ultrafast=20?= =?UTF-8?q?=E9=97=A8=E6=8E=A7=E4=B8=8E=E8=AE=A1=E8=B4=B9=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=80=A7=E7=94=A8=E4=BE=8B=E7=A7=BB=E5=85=A5=20unit=20?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用例依赖仅在 unit 标签下定义的 newTestBillingService,放在无标签的 openai_fast_policy_test.go 中导致 lint 与 integration 构建失败。 --- .../internal/service/billing_service_test.go | 29 +++++++++++++++++++ .../service/openai_fast_policy_test.go | 29 ------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/backend/internal/service/billing_service_test.go b/backend/internal/service/billing_service_test.go index 52264f8058..2ac79d6daa 100644 --- a/backend/internal/service/billing_service_test.go +++ b/backend/internal/service/billing_service_test.go @@ -2225,6 +2225,35 @@ func TestAstraUltrafastPricingUsesSixTimesStandard(t *testing.T) { require.Equal(t, 2.0, configuredServiceTierMultiplier("ultrafast", p)) } +// 门控与计费共用同一判定:凡是分组会强制写入 ultrafast 的模型,都必须按 6x 计费。 +func TestOpenAIUltrafastGateMatchesBilling(t *testing.T) { + svc := newTestBillingService() + for _, tt := range []struct { + model string + want float64 + }{ + {model: "gpt-6-astra", want: 6}, + {model: "gpt-6.1-sol", want: 6}, + {model: "gpt-6.1-sol-high", want: 6}, + {model: "gpt-6.1-terra", want: 2}, + {model: "gpt-6-sol", want: 2}, + {model: "gpt-5.6-sol", want: 2}, + } { + pricing, err := svc.GetModelPricing(tt.model) + require.NoError(t, err, tt.model) + require.Equal(t, tt.want, configuredServiceTierMultiplier(OpenAIFastTierUltrafast, pricing), tt.model) + require.Equal(t, tt.want == 6, openAIModelSupportsUltrafast(tt.model), tt.model) + + // 渠道自定义价格与显式 Fast 倍率都不改变 Ultrafast 倍率。 + custom, fast := 1e-6, 3.0 + channelPricing, err := svc.GetModelPricingWithChannel(tt.model, &ChannelModelPricing{ + InputPrice: &custom, OutputPrice: &custom, FastMultiplier: &fast, + }) + require.NoError(t, err, tt.model) + require.Equal(t, tt.want, configuredServiceTierMultiplier(OpenAIFastTierUltrafast, channelPricing), tt.model) + } +} + func TestGPT61SolExplicitZeroCacheWriteAcrossTiers(t *testing.T) { pricing := &PricingService{} var err error diff --git a/backend/internal/service/openai_fast_policy_test.go b/backend/internal/service/openai_fast_policy_test.go index 1d5e50fd88..a53e5ffe1d 100644 --- a/backend/internal/service/openai_fast_policy_test.go +++ b/backend/internal/service/openai_fast_policy_test.go @@ -681,35 +681,6 @@ func TestOpenAIModelSupportsUltrafast(t *testing.T) { } } -// 门控与计费共用同一判定:凡是分组会强制写入 ultrafast 的模型,都必须按 6x 计费。 -func TestOpenAIUltrafastGateMatchesBilling(t *testing.T) { - svc := newTestBillingService() - for _, tt := range []struct { - model string - want float64 - }{ - {model: "gpt-6-astra", want: 6}, - {model: "gpt-6.1-sol", want: 6}, - {model: "gpt-6.1-sol-high", want: 6}, - {model: "gpt-6.1-terra", want: 2}, - {model: "gpt-6-sol", want: 2}, - {model: "gpt-5.6-sol", want: 2}, - } { - pricing, err := svc.GetModelPricing(tt.model) - require.NoError(t, err, tt.model) - require.Equal(t, tt.want, configuredServiceTierMultiplier(OpenAIFastTierUltrafast, pricing), tt.model) - require.Equal(t, tt.want == 6, openAIModelSupportsUltrafast(tt.model), tt.model) - - // 渠道自定义价格与显式 Fast 倍率都不改变 Ultrafast 倍率。 - custom, fast := 1e-6, 3.0 - channelPricing, err := svc.GetModelPricingWithChannel(tt.model, &ChannelModelPricing{ - InputPrice: &custom, OutputPrice: &custom, FastMultiplier: &fast, - }) - require.NoError(t, err, tt.model) - require.Equal(t, tt.want, configuredServiceTierMultiplier(OpenAIFastTierUltrafast, channelPricing), tt.model) - } -} - func TestOpenAIGroupForcedServiceTier(t *testing.T) { openAIAccount := &Account{Platform: PlatformOpenAI, Type: AccountTypeOAuth} const sol, astra, unsupported = "gpt-6.1-sol", "gpt-6-astra", "gpt-5.6-sol"