From c50680222479b04ac28975055d31a7487c0f9b55 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 15 Jun 2018 18:53:50 +0100 Subject: [PATCH] When get format version in transaction then the version is the same --- .../net/kemitix/gitdb/impl/GitDBTransactionImpl.java | 4 ++-- src/test/java/net/kemitix/gitdb/test/GitDBTest.java | 12 ++++++++++++ 2 files changed, 14 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 262a8ef..a71f5ab 100644 --- a/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java +++ b/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java @@ -59,8 +59,8 @@ class GitDBTransactionImpl implements GitDBTransaction { } @Override - public Optional getFormatVersion() { - return Optional.empty(); + public Optional getFormatVersion() throws IOException { + return branch.getFormatVersion(); } @Override diff --git a/src/test/java/net/kemitix/gitdb/test/GitDBTest.java b/src/test/java/net/kemitix/gitdb/test/GitDBTest.java index 92b4339..cb00ece 100644 --- a/src/test/java/net/kemitix/gitdb/test/GitDBTest.java +++ b/src/test/java/net/kemitix/gitdb/test/GitDBTest.java @@ -422,6 +422,18 @@ class GitDBTest implements WithAssertions { assertThat(removed.get(key)).isEmpty(); } + // When get format version in transaction then the version is the same + @Test + void getFormatVersion_whenTransaction_thenFormatIsSame() throws IOException { + //given + final GitDBBranch gitDBBranch = gitDBBranch(); + final GitDBTransaction transaction = gitDBBranch.transaction(); + //when + final Optional formatVersion = transaction.getFormatVersion(); + //then + assertThat(formatVersion).contains(GitDB.VERSION); + } + // 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