Add unit test for diff command

This new tests ensures, that changes on a feature branch will be shown
in a diff even though the integration branch has been merged into the
feature branch.
This commit is contained in:
Rene Pfeuffer
2020-01-07 15:49:35 +01:00
parent 348e08cd33
commit 88fb31c47b
2 changed files with 25 additions and 0 deletions

View File

@@ -37,6 +37,20 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
"+++ b/f.txt\n" +
"@@ -0,0 +1 @@\n" +
"+f\n";
public static final String DIFF_FILE_PARTIAL_MERGE = "diff --git a/a.txt b/a.txt\n" +
"index 7898192..8cd63ec 100644\n" +
"--- a/a.txt\n" +
"+++ b/a.txt\n" +
"@@ -1 +1,2 @@\n" +
" a\n" +
"+change\n" +
"diff --git a/b.txt b/b.txt\n" +
"index 6178079..09ccdf0 100644\n" +
"--- a/b.txt\n" +
"+++ b/b.txt\n" +
"@@ -1 +1,2 @@\n" +
" b\n" +
"+change\n";
@Test
public void diffForOneRevisionShouldCreateDiff() throws IOException {
@@ -91,4 +105,15 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
gitDiffCommand.getDiffResult(diffCommandRequest).accept(output);
assertEquals(DIFF_FILE_A_MULTIPLE_REVISIONS, output.toString());
}
@Test
public void diffBetweenTwoBranchesWithMergedIntegrationBranchShouldCreateDiffOfAllIncomingChanges() throws IOException {
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
diffCommandRequest.setRevision("partially_merged");
diffCommandRequest.setAncestorChangeset("master");
ByteArrayOutputStream output = new ByteArrayOutputStream();
gitDiffCommand.getDiffResult(diffCommandRequest).accept(output);
assertEquals(DIFF_FILE_PARTIAL_MERGE, output.toString());
}
}