add total test
This commit is contained in:
@@ -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) {
|
func TestParseRules_CategoryAndSkuMixedSeparators(t *testing.T) {
|
||||||
rs, err := ParseRules(" category=Shoes|Bags ; sku= A | B , min_total>=1000\nmin_item_price>=500")
|
rs, err := ParseRules(" category=Shoes|Bags ; sku= A | B , min_total>=1000\nmin_item_price>=500")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user