Move helped test methods

This commit is contained in:
Paul Campbell 2018-06-15 14:49:03 +01:00
parent 9c6c2bc247
commit 002429e978

View file

@ -172,6 +172,11 @@ class GitDBTest implements WithAssertions {
}
// Given a valid GitDb handle
private GitDB gitDB(final Path dbDir) throws IOException {
return GitDB.initLocal(dbDir, userName, userEmailAddress);
}
// When select a branch that doesn't exist then an empty Optional is returned
@Test
void selectBranch_whenBranchNotExist_thenEmptyOptional() throws IOException {
@ -183,10 +188,6 @@ class GitDBTest implements WithAssertions {
assertThat(branch).isEmpty();
}
private GitDB gitDB(final Path dbDir) throws IOException {
return GitDB.initLocal(dbDir, userName, userEmailAddress);
}
// When select a valid branch then a GitDbBranch is returned
@Test
void selectBranch_branchExists_thenReturnBranch() throws IOException {
@ -200,6 +201,14 @@ class GitDBTest implements WithAssertions {
}
// Given a valid GitDbBranch handle
private GitDBBranch gitDBBranch() throws IOException {
final GitDB gitDB = gitDB(dirDoesNotExist());
final Optional<GitDBBranch> branchOptional = gitDB.branch("master");
assumeThat(branchOptional).isNotEmpty();
return branchOptional.get();
}
// When getting a key that does not exist then return an empty Optional
@Test
void getKey_whenKeyNotExist_thenReturnEmptyOptional() throws IOException, ClassNotFoundException {
@ -211,13 +220,6 @@ class GitDBTest implements WithAssertions {
assertThat(value).isEmpty();
}
private GitDBBranch gitDBBranch() throws IOException {
final GitDB gitDB = gitDB(dirDoesNotExist());
final Optional<GitDBBranch> branchOptional = gitDB.branch("master");
assumeThat(branchOptional).isNotEmpty();
return branchOptional.get();
}
// When getting the format version it matches expected
@Test
void getVersionFormat_thenFormatIsSet() throws IOException {