Skip to content

Commit

Permalink
Add test case for transactional rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
bsimpson committed Sep 15, 2022
1 parent 1d8f1ea commit 41cc584
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions spec/neo4j/http/cypher_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@
},
{
statement: statement3,
parameters: { name: "Baz" }
parameters: {name: "Baz"}
},
{
statement: statement4,
parameters: { name: "Qux" }
parameters: {name: "Qux"}
}
])

Expand All @@ -115,6 +115,35 @@
expect(results[2][0]["node"]["name"]).to eq("Baz")
expect(results[3][0]["node"]["name"]).to eq("Qux")
end

it "handles error and rolls back" do
good_statement = "MERGE (node:Test {uuid: 'Uuid1', name: 'Foo'}) return node"
bad_statement = "MERGE (node:Test {uuid: 'Uuid2', name: 'Bar'}) BAD SYNTAX"
good_statement2 = "MERGE (node:Test {uuid: 'Uuid3', name: 'Baz'}) return node"

expect {
client.execute_batch_cypher([
{
statement: good_statement,
parameters: {}
},
{
statement: bad_statement,
parameters: {}
},
{
statement: good_statement2,
parameters: {}
}
])
}.to raise_error Neo4j::Http::Errors::Neo::ClientError::Statement::SyntaxError

results = client.execute_cypher("MATCH (node:Test { uuid: 'Uuid1' }) return node")
expect(results).to be_empty

results = client.execute_cypher("MATCH (node:Test { uuid: 'Uuid3' }) return node")
expect(results).to be_empty
end
end
end
end

0 comments on commit 41cc584

Please sign in to comment.