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

Function test_pattern_edge_cases

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

Source from the content-addressed store, hash-verified

486
487#[test]
488fn test_pattern_edge_cases() {
489 let fixture = TestFixture::with_fraud_data().expect("Failed to create test fixture");
490
491 // Test self-referencing patterns
492 fixture.assert_query_succeeds("INSERT (self_ref:SelfRef {id: 1})");
493
494 fixture.assert_query_succeeds("MATCH (s:SelfRef) INSERT (s)-[:SELF_LOOP]->(s)");
495
496 let result =
497 fixture.assert_query_succeeds("MATCH (n)-[r:SELF_LOOP]->(n) RETURN count(r) as self_loops");
498 assert!(!result.rows.is_empty());
499
500 // Test patterns with no matches
501 fixture.assert_first_value(
502 "MATCH (a:Account)-[:NONEXISTENT]->(b:Merchant) RETURN count(*) as no_matches",
503 "no_matches",
504 Value::Number(0.0),
505 );
506
507 // Test patterns with multiple relationship types
508 let result = fixture.assert_query_succeeds(
509 "MATCH ()-[r:Transaction|Purchase|NONEXISTENT]->() RETURN count(r) as mixed_types",
510 );
511 assert!(!result.rows.is_empty());
512
513 // Test deeply nested patterns - testing if 'level' is a reserved keyword
514 fixture.assert_query_succeeds(
515 "INSERT (deep1:DeepNode {depth: 1}), (deep2:DeepNode {depth: 2}), (deep3:DeepNode {depth: 3}), (deep4:DeepNode {depth: 4})"
516 );
517
518 fixture.assert_query_succeeds(
519 "MATCH (d1:DeepNode {depth: 1}), (d2:DeepNode {depth: 2}), (d3:DeepNode {depth: 3}), (d4:DeepNode {depth: 4}) INSERT (d1)-[:DEEPER]->(d2)-[:DEEPER]->(d3)-[:DEEPER]->(d4)"
520 );
521
522 let result = fixture.assert_query_succeeds(
523 "MATCH path = (start:DeepNode {depth: 1})-[:DEEPER]{3}->(end:DeepNode {depth: 4})
524 RETURN count(path) as deep_paths",
525 );
526 assert!(!result.rows.is_empty());
527
528 // Test patterns with property filters on relationships
529 let result = fixture.assert_query_succeeds(
530 "MATCH ()-[t:Transaction]->()
531 WHERE t.amount IS NOT NULL AND t.status IS NOT NULL
532 RETURN count(t) as filtered_transactions",
533 );
534 assert!(!result.rows.is_empty());
535}
536
537#[test]
538fn test_union_and_intersection_patterns() {

Callers

nothing calls this directly

Calls 2

assert_first_valueMethod · 0.80
assert_query_succeedsMethod · 0.45

Tested by

no test coverage detected