fix(billing): 保留规则集未覆盖的基础资源价格
ci / verify (pull_request) Successful in 12m21s
ci / verify (pull_request) Successful in 12m21s
This commit is contained in:
@@ -62,6 +62,31 @@ func TestResolveEffectiveBillingConfigAppliesOverrideLast(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveEffectiveBillingConfigPreservesBaseResourcesMissingFromRuleSet(t *testing.T) {
|
||||
config := ResolveEffectiveBillingConfig(EffectiveBillingConfigInput{
|
||||
BaseConfig: map[string]any{
|
||||
"music": map[string]any{"basePrice": float64(20)},
|
||||
"audio": map[string]any{"basePrice": float64(1)},
|
||||
"video": map[string]any{"basePrice": float64(100)},
|
||||
},
|
||||
InheritedRuleSetConfig: map[string]any{
|
||||
"video": map[string]any{"basePrice": float64(416)},
|
||||
},
|
||||
})
|
||||
|
||||
assertBillingBasePrice(t, config, "music", 20)
|
||||
assertBillingBasePrice(t, config, "audio", 1)
|
||||
assertBillingBasePrice(t, config, "video", 416)
|
||||
}
|
||||
|
||||
func assertBillingBasePrice(t *testing.T, config map[string]any, resource string, want float64) {
|
||||
t.Helper()
|
||||
resourceConfig, ok := config[resource].(map[string]any)
|
||||
if !ok || resourceConfig["basePrice"] != want {
|
||||
t.Fatalf("%s base price = %#v, want %v", resource, config[resource], want)
|
||||
}
|
||||
}
|
||||
|
||||
func videoBillingConfig(basePrice float64) map[string]any {
|
||||
return map[string]any{
|
||||
"video": map[string]any{"basePrice": basePrice},
|
||||
|
||||
Reference in New Issue
Block a user