From 53596f425449db921d255406029a1864abb0ca04 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 15 Jun 2018 19:06:14 +0100 Subject: [PATCH] When start a named transaction in a transaction then a new transaction is created --- .../kemitix/gitdb/impl/GitDBTransactionImpl.java | 4 ++-- .../java/net/kemitix/gitdb/test/GitDBTest.java | 15 +++++++++++++++ 2 files changed, 17 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 6afa39f..4fa6db1 100644 --- a/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java +++ b/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java @@ -69,8 +69,8 @@ class GitDBTransactionImpl implements GitDBTransaction { } @Override - public GitDBTransaction transaction(String name) { - return null; + public GitDBTransaction transaction(String name) throws IOException { + return branch.transaction(name); } @Override diff --git a/src/test/java/net/kemitix/gitdb/test/GitDBTest.java b/src/test/java/net/kemitix/gitdb/test/GitDBTest.java index f54dac5..c68a10f 100644 --- a/src/test/java/net/kemitix/gitdb/test/GitDBTest.java +++ b/src/test/java/net/kemitix/gitdb/test/GitDBTest.java @@ -461,6 +461,21 @@ class GitDBTest implements WithAssertions { assertThat(secondTransaction).isNotSameAs(firstTransaction); } + // When start a named transaction in a transaction then a new transaction is created + @Test + void startNamedTransaction_whenTransaction_thenReturnAnotherTransaction() throws IOException { + //given + final GitDBBranch initialBranch = gitDBBranch(); + final GitDBTransaction firstTransaction = initialBranch.transaction(); + final String name = stringSupplier.get(); + //when + final GitDBTransaction secondTransaction = firstTransaction.transaction(name); + //then + assertThat(secondTransaction).isNotNull(); + assertThat(secondTransaction).isNotSameAs(firstTransaction); + assertThat(secondTransaction.name()).isEqualTo(name); + } + // 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