diff --git a/scm-plugins/scm-git-plugin/src/test/java/sonia/scm/repository/spi/GitDiffCommandTest.java b/scm-plugins/scm-git-plugin/src/test/java/sonia/scm/repository/spi/GitDiffCommandTest.java index 84088ba4ef..f6e462f968 100644 --- a/scm-plugins/scm-git-plugin/src/test/java/sonia/scm/repository/spi/GitDiffCommandTest.java +++ b/scm-plugins/scm-git-plugin/src/test/java/sonia/scm/repository/spi/GitDiffCommandTest.java @@ -8,20 +8,34 @@ import static org.junit.Assert.assertEquals; public class GitDiffCommandTest extends AbstractGitCommandTestBase { - private static final String DIFF_LATEST_COMMIT_TEST_BRANCH = "diff --git a/a.txt b/a.txt\n" + + public static final String DIFF_FILE_A = "diff --git a/a.txt b/a.txt\n" + "index 7898192..1dc60c7 100644\n" + "--- a/a.txt\n" + "+++ b/a.txt\n" + "@@ -1 +1 @@\n" + "-a\n" + - "+a and b\n" + - "diff --git a/b.txt b/b.txt\n" + + "+a and b\n"; + public static final String DIFF_FILE_B = "diff --git a/b.txt b/b.txt\n" + "deleted file mode 100644\n" + "index 6178079..0000000\n" + "--- a/b.txt\n" + "+++ /dev/null\n" + "@@ -1 +0,0 @@\n" + "-b\n"; + public static final String DIFF_FILE_A_MULTIPLE_REVISIONS = "diff --git a/a.txt b/a.txt\n" + + "index 7898192..2f8bc28 100644\n" + + "--- a/a.txt\n" + + "+++ b/a.txt\n" + + "@@ -1 +1,2 @@\n" + + " a\n" + + "+line for blame\n"; + public static final String DIFF_FILE_F_MULTIPLE_REVISIONS = "diff --git a/f.txt b/f.txt\n" + + "new file mode 100644\n" + + "index 0000000..6a69f92\n" + + "--- /dev/null\n" + + "+++ b/f.txt\n" + + "@@ -0,0 +1 @@\n" + + "+f\n"; @Test public void diffForOneRevisionShouldCreateDiff() { @@ -30,7 +44,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase { diffCommandRequest.setRevision("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4"); ByteArrayOutputStream output = new ByteArrayOutputStream(); gitDiffCommand.getDiffResult(diffCommandRequest, output); - assertEquals(DIFF_LATEST_COMMIT_TEST_BRANCH, output.toString()); + assertEquals(DIFF_FILE_A + DIFF_FILE_B, output.toString()); } @Test @@ -40,7 +54,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase { diffCommandRequest.setRevision("test-branch"); ByteArrayOutputStream output = new ByteArrayOutputStream(); gitDiffCommand.getDiffResult(diffCommandRequest, output); - assertEquals(DIFF_LATEST_COMMIT_TEST_BRANCH, output.toString()); + assertEquals(DIFF_FILE_A + DIFF_FILE_B, output.toString()); } @Test @@ -51,13 +65,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase { diffCommandRequest.setPath("a.txt"); ByteArrayOutputStream output = new ByteArrayOutputStream(); gitDiffCommand.getDiffResult(diffCommandRequest, output); - assertEquals("diff --git a/a.txt b/a.txt\n" + - "index 7898192..1dc60c7 100644\n" + - "--- a/a.txt\n" + - "+++ b/a.txt\n" + - "@@ -1 +1 @@\n" + - "-a\n" + - "+a and b\n", output.toString()); + assertEquals(DIFF_FILE_A, output.toString()); } @Test @@ -68,20 +76,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase { diffCommandRequest.setAncestorChangeset("test-branch"); ByteArrayOutputStream output = new ByteArrayOutputStream(); gitDiffCommand.getDiffResult(diffCommandRequest, output); - assertEquals("diff --git a/a.txt b/a.txt\n" + - "index 7898192..2f8bc28 100644\n" + - "--- a/a.txt\n" + - "+++ b/a.txt\n" + - "@@ -1 +1,2 @@\n" + - " a\n" + - "+line for blame\n" + - "diff --git a/f.txt b/f.txt\n" + - "new file mode 100644\n" + - "index 0000000..6a69f92\n" + - "--- /dev/null\n" + - "+++ b/f.txt\n" + - "@@ -0,0 +1 @@\n" + - "+f\n", output.toString()); + assertEquals(DIFF_FILE_A_MULTIPLE_REVISIONS + DIFF_FILE_F_MULTIPLE_REVISIONS, output.toString()); } @Test @@ -93,12 +88,6 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase { diffCommandRequest.setPath("a.txt"); ByteArrayOutputStream output = new ByteArrayOutputStream(); gitDiffCommand.getDiffResult(diffCommandRequest, output); - assertEquals("diff --git a/a.txt b/a.txt\n" + - "index 7898192..2f8bc28 100644\n" + - "--- a/a.txt\n" + - "+++ b/a.txt\n" + - "@@ -1 +1,2 @@\n" + - " a\n" + - "+line for blame\n", output.toString()); + assertEquals(DIFF_FILE_A_MULTIPLE_REVISIONS, output.toString()); } }