When start a named transaction in a transaction then a new transaction is created

This commit is contained in:
Paul Campbell 2018-06-15 19:06:14 +01:00
parent c01936e55f
commit 53596f4254
2 changed files with 17 additions and 2 deletions

View file

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

View file

@ -461,6 +461,21 @@ class GitDBTest implements WithAssertions {
assertThat(secondTransaction).isNotSameAs(firstTransaction); 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 // Given a GitDbTransaction handle with a added, updated and removed keys
// When closing the transaction an GitDbBranch is returned // When closing the transaction an GitDbBranch is returned
// When closing the transaction the added key/value is found // When closing the transaction the added key/value is found