19 lines
833 B
Go
Executable File
19 lines
833 B
Go
Executable File
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") }
|
|
} |