add total test
Some checks are pending
Build and Publish / BuildAndDeployAmd64 (push) Blocked by required conditions
Build and Publish / Metadata (push) Successful in 13s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m35s

This commit is contained in:
matst80
2025-10-18 15:14:22 +02:00
parent 2ce45656d9
commit d58409e3fc

View File

@@ -28,6 +28,32 @@ func TestParseRules_SimpleSku(t *testing.T) {
}
}
func TestRuleCartTotal(t *testing.T) {
rs, err := ParseRules("min_total>=500000")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if len(rs.Conditions) != 1 {
t.Fatalf("expected 1 condition got %d", len(rs.Conditions))
}
c := rs.Conditions[0]
if c.Kind != RuleMinTotal {
t.Fatalf("expected kind cart total got %s", c.Kind)
}
ctx := EvalContext{
Items: []Item{
Item{
Sku: "123",
},
},
CartTotalInc: 400000,
}
applied := rs.Applies(ctx)
if applied {
t.Fatalf("expected")
}
}
func TestParseRules_CategoryAndSkuMixedSeparators(t *testing.T) {
rs, err := ParseRules(" category=Shoes|Bags ; sku= A | B , min_total>=1000\nmin_item_price>=500")
if err != nil {