When start an anonymous transaction in a transaction then a new transaction is created

This commit is contained in:
Paul Campbell 2018-06-15 19:04:08 +01:00
parent cdd35e8008
commit c01936e55f
2 changed files with 15 additions and 2 deletions

View file

@ -64,8 +64,8 @@ class GitDBTransactionImpl implements GitDBTransaction {
}
@Override
public GitDBTransaction transaction() {
return null;
public GitDBTransaction transaction() throws IOException {
return branch.transaction();
}
@Override

View file

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