easyai-ai-gateway/apps/api/internal/httpapi/pricing_handlers_test.go
chengcheng 5114686c35 feat(billing): 统一计价与候选冻结估算
新增 effective-pricing-v2、9 位十进制定点计算、显式免费校验和结构化缺价错误。估价与生产预处理覆盖全部可用候选,并按最大候选费用冻结;规则优先级为平台模型、平台、基准模型。\n\n同步计价契约和 OpenAPI,补充 Token 参数别名、视频五秒向上取整及缺价回归测试。\n\n验证:go test ./...、pnpm openapi、Web 测试与构建通过。
2026-07-20 23:22:45 +08:00

29 lines
770 B
Go

package httpapi
import (
"testing"
"github.com/easyai/easyai-ai-gateway/apps/api/internal/store"
)
func TestPricingRuleSetRejectsImplicitZeroAndUnsupportedCalculator(t *testing.T) {
base := store.PricingRuleSetInput{
RuleSetKey: "test", Name: "test",
Rules: []store.PricingRuleInput{{
ResourceType: "image", Unit: "image", BasePrice: 0,
Currency: "resource", CalculatorType: "unit_weight",
}},
}
if validPricingRuleSetInput(base) {
t.Fatal("implicit zero price must be rejected")
}
base.Rules[0].IsFree = true
if !validPricingRuleSetInput(base) {
t.Fatal("explicit free price should be accepted")
}
base.Rules[0].CalculatorType = "formula"
if validPricingRuleSetInput(base) {
t.Fatal("arbitrary formula calculator must be rejected")
}
}