cart and checkout
Build and Publish / BuildAndDeployAmd64 (push) Failing after 4s
Build and Publish / BuildAndDeployArm64 (push) Failing after 6s

This commit is contained in:
2026-06-27 19:49:00 +02:00
parent 492f54ff45
commit 528c59bfd3
67 changed files with 3618 additions and 1031 deletions
+39
View File
@@ -442,6 +442,45 @@ func TestDateRangeCondition(t *testing.T) {
}
}
func TestCouponCodeCondition(t *testing.T) {
rule := PromotionRule{
ID: "coupon-promo",
Name: "Coupon Promo",
Status: StatusActive,
Conditions: Conditions{
BaseCondition{
ID: "c",
Type: CondCouponCode,
Operator: OpEquals,
Value: cvString("SAVE50"),
},
},
Actions: []Action{{ID: "a", Type: ActionFixedDiscount, Value: 500}},
}
svc := NewPromotionService(nil)
// Context with matching coupon code
ctxMatched := &PromotionEvalContext{
CouponCodes: []string{"SAVE50"},
Now: time.Now(),
}
resMatched := svc.EvaluateRule(rule, ctxMatched)
if !resMatched.Applicable {
t.Errorf("expected coupon code rule to apply with SAVE50")
}
// Context without matching coupon code
ctxUnmatched := &PromotionEvalContext{
CouponCodes: []string{"SAVE20"},
Now: time.Now(),
}
resUnmatched := svc.EvaluateRule(rule, ctxUnmatched)
if resUnmatched.Applicable {
t.Errorf("expected coupon code rule NOT to apply with SAVE20")
}
}
// --- Utilities -------------------------------------------------------------
func ptr(s string) *string { return &s }