MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / test_variable_length_patterns

Function test_variable_length_patterns

graphlite/tests/pattern_tests.rs:178–225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

176
177#[test]
178fn test_variable_length_patterns() {
179 let fixture = TestFixture::with_fraud_data().expect("Failed to create test fixture");
180
181 // Create a chain pattern for testing (avoid reserved keywords like 'start')
182 fixture.assert_query_succeeds(
183 "INSERT (node0:ChainNode {id: 0}),
184 (node1:ChainNode {id: 1}),
185 (node2:ChainNode {id: 2}),
186 (node3:ChainNode {id: 3}),
187 (node4:ChainNode {id: 4})",
188 );
189
190 fixture.assert_query_succeeds(
191 "MATCH (s:ChainNode {id: 0}), (n1:ChainNode {id: 1}), (n2:ChainNode {id: 2}),
192 (n3:ChainNode {id: 3}), (e:ChainNode {id: 4})
193 INSERT (s)-[:NEXT]->(n1)-[:NEXT]->(n2)-[:NEXT]->(n3)-[:NEXT]->(e)",
194 );
195
196 // Test variable length path - 1 to 3 hops
197 let result = fixture.assert_query_succeeds(
198 "MATCH path = (node0:ChainNode {id: 0})-[:NEXT]{1,3}->(node_end)
199 RETURN count(path) as one_to_three_hop_paths",
200 );
201 assert!(!result.rows.is_empty());
202
203 // Test variable length path - up to 2 hops
204 let result = fixture.assert_query_succeeds(
205 "MATCH path = (node0:ChainNode {id: 0})-[:NEXT]{,2}->(node_end)
206 RETURN count(path) as up_to_two_hop_paths",
207 );
208 assert!(!result.rows.is_empty());
209
210 // Test variable length path - at least 2 hops
211 let result = fixture.assert_query_succeeds(
212 "MATCH path = (node0:ChainNode {id: 0})-[:NEXT]{2,}->(node_end)
213 RETURN count(path) as at_least_two_hop_paths",
214 );
215 assert!(!result.rows.is_empty());
216
217 // Test variable length path on the main graph
218 let result = fixture.assert_query_succeeds(
219 "MATCH path = (a:Account)-[:Transaction|Purchase]{1,2}->(m:Merchant)
220 RETURN count(DISTINCT a) as accounts_with_paths,
221 count(DISTINCT m) as reachable_merchants
222 LIMIT 1000", // Limit to avoid very large results
223 );
224 assert!(!result.rows.is_empty());
225}
226
227#[test]
228fn test_optional_patterns() {

Callers

nothing calls this directly

Calls 1

assert_query_succeedsMethod · 0.45

Tested by

no test coverage detected