When putting an existing key/value pair then the original GitDbBranch finds the original value

This commit is contained in:
Paul Campbell 2018-06-15 18:41:09 +01:00
parent 1a65fb9123
commit 0e5d5d4a31
2 changed files with 16 additions and 2 deletions

View file

@ -25,6 +25,7 @@ import com.github.zafarkhaja.semver.Version;
import net.kemitix.gitdb.GitDBBranch;
import net.kemitix.gitdb.GitDBTransaction;
import java.io.IOException;
import java.util.Optional;
/**
@ -48,8 +49,8 @@ class GitDBTransactionImpl implements GitDBTransaction {
}
@Override
public GitDBBranch put(String key, String value) {
return null;
public GitDBBranch put(String key, String value) throws IOException {
return branch.put(key, value);
}
@Override

View file

@ -381,6 +381,19 @@ class GitDBTest implements WithAssertions {
}
// When putting an existing key/value pair then the original GitDbBranch finds the original value
@Test
void putValue_whenTransaction_thenUpdatedBranchFinds() throws IOException {
//given
final GitDBBranch originalBranch = gitDBBranch();
final GitDBTransaction transaction = originalBranch.transaction();
final String key = stringSupplier.get();
final String value = stringSupplier.get();
//when
final GitDBBranch updatedBranch = transaction.put(key, value);
//then
assertThat(updatedBranch.get(key)).contains(value);
}
// When removing a key then the original GitDbBRanch still finds it
// Given a GitDbTransaction handle with a added, updated and removed keys