Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 40s
feat(pay): 添加支付API基础结构 feat(miniapp): 创建支付测试小程序页面与配置 feat(wechatpay): 配置微信支付参数与证书 fix(guild): 修复成员列表查询条件 docs: 更新代码规范文档与需求文档 style: 统一前后端枚举显示与注释格式 refactor(admin): 重构用户奖励发放接口参数处理 test(title): 添加称号效果参数验证测试
19 lines
833 B
Go
19 lines
833 B
Go
package title
|
|
|
|
import "testing"
|
|
|
|
func TestValidateEffectParams_Discount(t *testing.T) {
|
|
s := &service{}
|
|
_, err := s.ValidateEffectParams(2, `{"discount_type":"invalid","value_x1000":10,"max_discount_x1000":0}`)
|
|
if err == nil { t.Fatalf("expected error for invalid discount_type") }
|
|
out, err := s.ValidateEffectParams(2, `{"discount_type":"percentage","value_x1000":1000,"max_discount_x1000":0}`)
|
|
if err != nil { t.Fatalf("unexpected error: %v", err) }
|
|
if out == "" { t.Fatalf("expected non-empty output") }
|
|
}
|
|
|
|
func TestValidateEffectParams_TargetPrizeDedup(t *testing.T) {
|
|
s := &service{}
|
|
out, err := s.ValidateEffectParams(5, `{"target_prize_ids":[1,2,2,1],"boost_x1000":100}`)
|
|
if err != nil { t.Fatalf("unexpected error: %v", err) }
|
|
if len(out) == 0 { t.Fatalf("expected sanitized json") }
|
|
} |