From 78f55f3d83aa9e907a2d841a36703876a8f14b69 Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Sat, 15 Oct 2022 16:02:18 -0500 Subject: [PATCH] wip: test for complex conditions --- src/delegation.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/delegation.rs b/src/delegation.rs index 4e12112..9fc9eab 100644 --- a/src/delegation.rs +++ b/src/delegation.rs @@ -227,4 +227,37 @@ mod tests { assert_eq!(parsed, kind_cq); Ok(()) } + // parse multiple conditions + #[test] + fn parse_multi_conditions() -> Result<()> { + // given an empty condition query, produce an empty vector + let kind_cq = ConditionQuery { + conditions: vec![ + Condition { + field: Field::Kind, + operator: Operator::GreaterThan, + values: vec![10000], + }, + Condition { + field: Field::Kind, + operator: Operator::LessThan, + values: vec![20000], + }, + Condition { + field: Field::Kind, + operator: Operator::NotEquals, + values: vec![10001], + }, + Condition { + field: Field::CreatedAt, + operator: Operator::LessThan, + values: vec![1665867123], + }, + ], + }; + let parsed = + "kind>10000&kind<20000&kind!10001&created_at<1665867123".parse::()?; + assert_eq!(parsed, kind_cq); + Ok(()) + } }