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

Function test_unwind_remove_basic

graphlite/tests/match_with_tests.rs:1709–1783  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1707
1708#[test]
1709fn test_unwind_remove_basic() {
1710 let fixture = TestFixture::empty().expect("Failed to create test fixture");
1711
1712 // Create test graph
1713 fixture
1714 .query(&format!(
1715 "CREATE SCHEMA IF NOT EXISTS /{}",
1716 fixture.schema_name()
1717 ))
1718 .unwrap();
1719 fixture
1720 .query(&format!(
1721 "CREATE GRAPH /{}/unwind_remove_basic",
1722 fixture.schema_name()
1723 ))
1724 .unwrap();
1725 fixture
1726 .query(&format!(
1727 "SESSION SET GRAPH /{}/unwind_remove_basic",
1728 fixture.schema_name()
1729 ))
1730 .unwrap();
1731
1732 // Insert test nodes with temp_flag - using id field like other tests
1733 fixture.assert_query_succeeds(
1734 "INSERT (p1:Product {id: 1, name: 'Product1', price: 30.0, temp_flag: true}),
1735 (p2:Product {id: 2, name: 'Product2', price: 20.0, temp_flag: true})",
1736 );
1737
1738 // Verify initial state
1739 let result = fixture
1740 .query("MATCH (p:Product) RETURN p.name as name, p.temp_flag as flag ORDER BY p.name")
1741 .unwrap();
1742 for row in &result.rows {
1743 assert_eq!(row.values.get("flag").unwrap(), &Value::Boolean(true));
1744 }
1745
1746 // Test UNWIND REMOVE - should use UNWIND preprocessor
1747 fixture.assert_query_succeeds(
1748 "MATCH (p:Product)
1749 WITH collect(p) as products
1750 UNWIND products as product
1751 WHERE product.price > 25
1752 REMOVE product.temp_flag",
1753 );
1754
1755 // Verify result - should be Null for expensive products, true for others
1756 let result = fixture
1757 .query("MATCH (p:Product) RETURN p.name as name, p.temp_flag as flag ORDER BY p.name")
1758 .unwrap();
1759
1760 for row in &result.rows {
1761 let name = match row.values.get("name").unwrap() {
1762 Value::String(s) => s.as_str(),
1763 _ => panic!("Expected string name"),
1764 };
1765 let flag = row.values.get("flag").unwrap();
1766

Callers

nothing calls this directly

Calls 5

unwrapMethod · 0.80
queryMethod · 0.45
assert_query_succeedsMethod · 0.45
getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected