mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 14:05:44 +01:00
Refactor unit test
This commit is contained in:
@@ -8,20 +8,34 @@ import static org.junit.Assert.assertEquals;
|
|||||||
|
|
||||||
public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
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" +
|
"index 7898192..1dc60c7 100644\n" +
|
||||||
"--- a/a.txt\n" +
|
"--- a/a.txt\n" +
|
||||||
"+++ b/a.txt\n" +
|
"+++ b/a.txt\n" +
|
||||||
"@@ -1 +1 @@\n" +
|
"@@ -1 +1 @@\n" +
|
||||||
"-a\n" +
|
"-a\n" +
|
||||||
"+a and b\n" +
|
"+a and b\n";
|
||||||
"diff --git a/b.txt b/b.txt\n" +
|
public static final String DIFF_FILE_B = "diff --git a/b.txt b/b.txt\n" +
|
||||||
"deleted file mode 100644\n" +
|
"deleted file mode 100644\n" +
|
||||||
"index 6178079..0000000\n" +
|
"index 6178079..0000000\n" +
|
||||||
"--- a/b.txt\n" +
|
"--- a/b.txt\n" +
|
||||||
"+++ /dev/null\n" +
|
"+++ /dev/null\n" +
|
||||||
"@@ -1 +0,0 @@\n" +
|
"@@ -1 +0,0 @@\n" +
|
||||||
"-b\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
|
@Test
|
||||||
public void diffForOneRevisionShouldCreateDiff() {
|
public void diffForOneRevisionShouldCreateDiff() {
|
||||||
@@ -30,7 +44,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
|||||||
diffCommandRequest.setRevision("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4");
|
diffCommandRequest.setRevision("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4");
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||||
assertEquals(DIFF_LATEST_COMMIT_TEST_BRANCH, output.toString());
|
assertEquals(DIFF_FILE_A + DIFF_FILE_B, output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -40,7 +54,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
|||||||
diffCommandRequest.setRevision("test-branch");
|
diffCommandRequest.setRevision("test-branch");
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||||
assertEquals(DIFF_LATEST_COMMIT_TEST_BRANCH, output.toString());
|
assertEquals(DIFF_FILE_A + DIFF_FILE_B, output.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -51,13 +65,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
|||||||
diffCommandRequest.setPath("a.txt");
|
diffCommandRequest.setPath("a.txt");
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||||
assertEquals("diff --git a/a.txt b/a.txt\n" +
|
assertEquals(DIFF_FILE_A, output.toString());
|
||||||
"index 7898192..1dc60c7 100644\n" +
|
|
||||||
"--- a/a.txt\n" +
|
|
||||||
"+++ b/a.txt\n" +
|
|
||||||
"@@ -1 +1 @@\n" +
|
|
||||||
"-a\n" +
|
|
||||||
"+a and b\n", output.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -68,20 +76,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
|||||||
diffCommandRequest.setAncestorChangeset("test-branch");
|
diffCommandRequest.setAncestorChangeset("test-branch");
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||||
assertEquals("diff --git a/a.txt b/a.txt\n" +
|
assertEquals(DIFF_FILE_A_MULTIPLE_REVISIONS + DIFF_FILE_F_MULTIPLE_REVISIONS, output.toString());
|
||||||
"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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -93,12 +88,6 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
|||||||
diffCommandRequest.setPath("a.txt");
|
diffCommandRequest.setPath("a.txt");
|
||||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
gitDiffCommand.getDiffResult(diffCommandRequest, output);
|
||||||
assertEquals("diff --git a/a.txt b/a.txt\n" +
|
assertEquals(DIFF_FILE_A_MULTIPLE_REVISIONS, output.toString());
|
||||||
"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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user