feat(billing): 完成异步结算与请求执行闭环
统一任务成功、Attempt 与结算 Outbox 的事务边界,增加多实例安全结算、人工复核、请求幂等与执行租约。钱包决策使用九位精确金额,并通过审计保护约束保留流水事实;同时补充管理接口、指标与 PostgreSQL 集成测试。
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package runner
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNormalizedBillingEngineMode(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := normalizedBillingEngineMode(""); got != "observe" {
|
||||
t.Fatalf("empty mode = %q", got)
|
||||
}
|
||||
if got := normalizedBillingEngineMode("ENFORCE"); got != "enforce" {
|
||||
t.Fatalf("enforce mode = %q", got)
|
||||
}
|
||||
if got := normalizedBillingEngineMode("hold"); got != "hold" {
|
||||
t.Fatalf("hold mode = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBillingItemsFixedTotalKeepsNineDecimalPlaces(t *testing.T) {
|
||||
t.Parallel()
|
||||
items := []any{
|
||||
map[string]any{"amount": "0.000000001"},
|
||||
map[string]any{"amount": float64(0.000000002)},
|
||||
}
|
||||
if got := billingItemsFixedTotal(items).String(); got != "0.000000003" {
|
||||
t.Fatalf("total = %s", got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user