Skip to content

Commit

Permalink
Add test coverage for foreach clause
Browse files Browse the repository at this point in the history
  • Loading branch information
alyaa999 committed Jul 30, 2024
1 parent c96c358 commit 2d073db
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,22 @@ assert containsNodes( res, true,
TestNode.from( List.of( "Person" ), Pair.of( "name", "Hans" ), Pair.of( "status", "active" ) ) );
}


@Test
public void nestedForeachTest() {
execute( SINGLE_NODE_PERSON_1 );
execute( SINGLE_NODE_PERSON_2 );
execute( "MATCH (p:Person)\n"
+ "WITH collect(p) AS people\n"
+ "FOREACH (p1 IN people |\n"
+ " FOREACH (p2 IN people |\n"
+ " CREATE (p1)-[:KNOWS]->(p2)\n"
+ " )\n"
+ ")" );
GraphResult res = execute( "MATCH (p1)-[r:KNOWS]->(p2) RETURN r" );
assert res.getData().length == 4;
res = execute( "MATCH (p1)-[r:KNOWS]-(p2) RETURN r" );
assert res.getData().length == 6;
}

}

0 comments on commit 2d073db

Please sign in to comment.