From 791f82e16f5bd24fc87580ea657d968f4e21b9d3 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 15 Jun 2018 18:48:42 +0100 Subject: [PATCH] When removing a key in a transaction then the transaction branch no longer finds it --- .../kemitix/gitdb/impl/GitDBTransactionImpl.java | 4 ++-- .../java/net/kemitix/gitdb/test/GitDBTest.java | 14 ++++++++++++++ 2 files changed, 16 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 28687d9..262a8ef 100644 --- a/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java +++ b/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java @@ -54,8 +54,8 @@ class GitDBTransactionImpl implements GitDBTransaction { } @Override - public GitDBBranch remove(String key) { - return null; + public GitDBBranch remove(String key) throws IOException { + return branch.remove(key); } @Override diff --git a/src/test/java/net/kemitix/gitdb/test/GitDBTest.java b/src/test/java/net/kemitix/gitdb/test/GitDBTest.java index 2738670..92b4339 100644 --- a/src/test/java/net/kemitix/gitdb/test/GitDBTest.java +++ b/src/test/java/net/kemitix/gitdb/test/GitDBTest.java @@ -408,6 +408,20 @@ class GitDBTest implements WithAssertions { assertThat(originalBranch.get(key)).contains(value); } + // When removing a key in a transaction then the transaction branch no longer finds it + @Test + void removeKey_whenTransaction_thenTransactionNotFind() throws IOException { + //given + final String key = stringSupplier.get(); + final String value = stringSupplier.get(); + final GitDBBranch originalBranch = gitDBBranchWithKeyValue(key, value); + final GitDBTransaction transaction = originalBranch.transaction(); + //when + final GitDBBranch removed = transaction.remove(key); + //then + assertThat(removed.get(key)).isEmpty(); + } + // 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