feat(billing): 统一计价与候选冻结估算
新增 effective-pricing-v2、9 位十进制定点计算、显式免费校验和结构化缺价错误。估价与生产预处理覆盖全部可用候选,并按最大候选费用冻结;规则优先级为平台模型、平台、基准模型。\n\n同步计价契约和 OpenAPI,补充 Token 参数别名、视频五秒向上取整及缺价回归测试。\n\n验证:go test ./...、pnpm openapi、Web 测试与构建通过。
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/easyai/easyai-ai-gateway/apps/api/internal/runner"
|
||||
)
|
||||
|
||||
func TestPricingUnavailableUsesStructuredServiceUnavailableError(t *testing.T) {
|
||||
err := &runner.PricingUnavailableError{
|
||||
Reason: "missing, invalid, or not explicitly free",
|
||||
ResourceType: "image",
|
||||
RuleSetID: "rule-set-id",
|
||||
}
|
||||
if got := statusFromRunError(err); got != http.StatusServiceUnavailable {
|
||||
t.Fatalf("statusFromRunError()=%d, want %d", got, http.StatusServiceUnavailable)
|
||||
}
|
||||
if got := runErrorCode(err); got != "pricing_unavailable" {
|
||||
t.Fatalf("runErrorCode()=%q, want pricing_unavailable", got)
|
||||
}
|
||||
details := runErrorDetails(err)
|
||||
pricing, _ := details["pricing"].(map[string]any)
|
||||
if pricing["resourceType"] != "image" || pricing["ruleSetId"] != "rule-set-id" {
|
||||
t.Fatalf("unexpected pricing details: %+v", details)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user