use anyhow::Result;
use uni_db::Uni;
#[tokio::test]
async fn test_vlp_simple() -> Result<()> {
let db = Uni::in_memory().build().await?;
let tx = db.session().tx().await?;
tx.execute("CREATE (a:A)-[:REL]->(b:B)").await?;
tx.commit().await?;
let all_nodes = db.session().query("MATCH (n) RETURN n").await?;
println!("Total nodes: {}", all_nodes.len());
assert_eq!(all_nodes.len(), 2, "Should have 2 nodes");
let cartesian = db.session().query("MATCH (n), (m) RETURN n, m").await?;
println!("Cartesian product: {}", cartesian.len());
for (i, row) in cartesian.iter().enumerate() {
println!("Row {}: {:?}", i, row);
}
assert_eq!(cartesian.len(), 4, "Cartesian should be 4 (2x2)");
let single_hop = db
.session()
.query("MATCH (n), (m) WHERE (n)-[:REL]->(m) RETURN n, m")
.await?;
println!("Single-hop pattern predicate: {}", single_hop.len());
for (i, row) in single_hop.iter().enumerate() {
println!("Single-hop row {}: {:?}", i, row);
}
assert_eq!(single_hop.len(), 1, "Should have 1 match (A->B)");
let vlp = db
.session()
.query("MATCH (n), (m) WHERE (n)-[:REL*1..1]->(m) RETURN n, m")
.await?;
println!("VLP pattern predicate: {}", vlp.len());
for (i, row) in vlp.iter().enumerate() {
println!("VLP row {}: {:?}", i, row);
}
assert_eq!(vlp.len(), 1, "Should have 1 match (A->B)");
Ok(())
}