统一任务成功、Attempt 与结算 Outbox 的事务边界,增加多实例安全结算、人工复核、请求幂等与执行租约。钱包决策使用九位精确金额,并通过审计保护约束保留流水事实;同时补充管理接口、指标与 PostgreSQL 集成测试。
28 lines
722 B
Go
28 lines
722 B
Go
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)
|
|
}
|
|
}
|