From c01936e55f7d3868bbf3fa37484ce6db4b7bd002 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 15 Jun 2018 19:04:08 +0100 Subject: [PATCH] When start an anonymous transaction in a transaction then a new transaction is created --- .../kemitix/gitdb/impl/GitDBTransactionImpl.java | 4 ++-- src/test/java/net/kemitix/gitdb/test/GitDBTest.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java b/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java index 0a16247..6afa39f 100644 --- a/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java +++ b/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java @@ -64,8 +64,8 @@ class GitDBTransactionImpl implements GitDBTransaction { } @Override - public GitDBTransaction transaction() { - return null; + public GitDBTransaction transaction() throws IOException { + return branch.transaction(); } @Override diff --git a/src/test/java/net/kemitix/gitdb/test/GitDBTest.java b/src/test/java/net/kemitix/gitdb/test/GitDBTest.java index 974a65d..f54dac5 100644 --- a/src/test/java/net/kemitix/gitdb/test/GitDBTest.java +++ b/src/test/java/net/kemitix/gitdb/test/GitDBTest.java @@ -448,6 +448,19 @@ class GitDBTest implements WithAssertions { assertThat(result).contains(value); } + // When start an anonymous transaction in a transaction then a new transaction is created + @Test + void startAnonymousTransaction_whenTransaction_thenReturnAnotherTransaction() throws IOException { + //given + final GitDBBranch initialBranch = gitDBBranch(); + final GitDBTransaction firstTransaction = initialBranch.transaction(); + //when + final GitDBTransaction secondTransaction = firstTransaction.transaction(); + //then + assertThat(secondTransaction).isNotNull(); + assertThat(secondTransaction).isNotSameAs(firstTransaction); + } + // Given a GitDbTransaction handle with a added, updated and removed keys // When closing the transaction an GitDbBranch is returned // When closing the transaction the added key/value is found