package condition import ( "testing" "aiaa-notification-service/internal/model" ) func TestEvaluate_Empty(t *testing.T) { if !Evaluate(nil, nil) { t.Error("empty conditions should pass") } } func TestEvaluate_Exists(t *testing.T) { conds := []model.Condition{{Field: "symbol", Op: "exists"}} data := map[string]interface{}{"symbol": "BTC"} if !Evaluate(conds, data) { t.Error("symbol exists, should pass") } } func TestEvaluate_NotExists(t *testing.T) { conds := []model.Condition{{Field: "symbol", Op: "not_exists"}} data := map[string]interface{}{"price": 100} if !Evaluate(conds, data) { t.Error("symbol not exists, should pass") } } func TestEvaluate_Gt(t *testing.T) { conds := []model.Condition{{Field: "price", Op: "gt", Value: "100"}} data := map[string]interface{}{"price": float64(200)} if !Evaluate(conds, data) { t.Error("200 > 100, should pass") } } func TestEvaluate_Fail(t *testing.T) { conds := []model.Condition{ {Field: "symbol", Op: "exists"}, {Field: "price", Op: "lt", Value: "100"}, } data := map[string]interface{}{"symbol": "BTC", "price": float64(200)} if Evaluate(conds, data) { t.Error("200 < 100 is false, should fail") } } func TestEvaluate_Contains(t *testing.T) { conds := []model.Condition{{Field: "msg", Op: "contains", Value: "error"}} data := map[string]interface{}{"msg": "connection error occurred"} if !Evaluate(conds, data) { t.Error("msg contains 'error', should pass") } }