This is an automated email from the ASF dual-hosted git repository. valentyn pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 93bada28eadd7fca71e11030f3d924e24e1aad83 Merge: 6493d68dc9 0756e12f89 Author: Valentyn Kahamlyk <valentyn.kaham...@improving.com> AuthorDate: Wed Dec 6 12:16:35 2023 -0800 Merge branch '3.7-dev' CHANGELOG.asciidoc | 1 + .../DriverRemoteConnection/GraphTraversalTests.cs | 20 ++++++++++ gremlin-go/driver/traversal_test.go | 44 ++++++++++++++++++++++ .../gremlin-javascript/lib/process/transaction.js | 12 +++++- .../test/integration/traversal-test.js | 26 +++++++++++++ .../gremlin-javascript/test/unit/traversal-test.js | 23 +++++++++++ .../gremlin_python/process/graph_traversal.py | 2 +- .../tests/driver/test_driver_remote_connection.py | 31 +++++++++++++++ 8 files changed, 156 insertions(+), 3 deletions(-) diff --cc gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js index 302d6862df,c6b899971c..b051f5bd96 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/unit/traversal-test.js @@@ -274,9 -274,32 +274,32 @@@ describe('Traversal', function () }); }); + describe('not opened transactions', function() { + it('should not allow commit for not opened transactions', async function() { + const g = anon.traversal().withRemote(new MockRemoteConnection()); + const tx = g.tx(); + try { + await tx.commit(); + assert.fail("should throw error"); + } catch (err) { + assert.strictEqual('Cannot commit a transaction that is not started', err.message); + } + }); + it('should not allow rollback for not opened transactions', async function() { + const g = anon.traversal().withRemote(new MockRemoteConnection()); + const tx = g.tx(); + try { + await tx.rollback(); + assert.fail("should throw error"); + } catch (err) { + assert.strictEqual('Cannot rollback a transaction that is not started', err.message); + } + }); + }); + describe('tx#begin()', function() { it("should not allow a transaction to begin more than once", function() { - const g = anon.traversal().withRemote(new MockRemoteConnection()); + const g = anon.traversal().with_(new MockRemoteConnection()); const tx = g.tx(); tx.begin(); assert.throws(function () { diff --cc gremlin-python/src/main/python/tests/driver/test_driver_remote_connection.py index 5dae118cf4,961b1b7089..56e45a770a --- a/gremlin-python/src/main/python/tests/driver/test_driver_remote_connection.py +++ b/gremlin-python/src/main/python/tests/driver/test_driver_remote_connection.py @@@ -228,8 -228,39 +228,39 @@@ class TestDriverRemoteConnection(object # after closing transaction we should remove spawned_session assert 0 == len(remote_transaction_connection._DriverRemoteConnection__spawned_sessions) + def test_tx_on_graph_without_tx_support(self, remote_connection): + g = traversal().withRemote(remote_connection) + tx = g.tx() + try: + # tx is just a session, so no exception here + gtx = tx.begin() + # read operation is ok for sessioned connection + assert 6 == gtx.V().count().next() + tx.commit().all().result() + assert False + except GremlinServerError as ex: + assert "500: Graph does not support transactions" == str(ex) + + def test_tx_commit_on_graph_without_tx_support(self, remote_connection): + g = traversal().withRemote(remote_connection) + tx = g.tx() + try: + tx.commit() + assert False + except Exception as ex: + assert "Cannot commit a transaction that is not started." == str(ex) + + def test_tx_rollback_on_graph_without_tx_support(self, remote_connection): + g = traversal().withRemote(remote_connection) + tx = g.tx() + try: + tx.rollback() + assert False + except Exception as ex: + assert "Cannot rollback a transaction that is not started." == str(ex) + def test_clone(self, remote_connection): - g = traversal().withRemote(remote_connection) + g = traversal().with_(remote_connection) t = g.V().both() assert 12 == len(t.toList()) assert 5 == t.clone().limit(5).count().next()