When removing a key in a transaction then the transaction branch no longer finds it

This commit is contained in:
Paul Campbell 2018-06-15 18:48:42 +01:00
parent cd700c0130
commit 791f82e16f
2 changed files with 16 additions and 2 deletions

View file

@ -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

View file

@ -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