mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 13:35:44 +01:00
Enhance unit test
This commit is contained in:
@@ -43,6 +43,23 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
||||
assertEquals(DIFF_LATEST_COMMIT_TEST_BRANCH, output.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffForPathShouldCreateLimitedDiff() {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("test-branch");
|
||||
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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffBetweenTwoBranchesShouldCreateDiff() {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
|
||||
@@ -66,4 +83,22 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
|
||||
"@@ -0,0 +1 @@\n" +
|
||||
"+f\n", output.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffBetweenTwoBranchesForPathShouldCreateLimitedDiff() {
|
||||
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
|
||||
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
|
||||
diffCommandRequest.setRevision("master");
|
||||
diffCommandRequest.setAncestorChangeset("test-branch");
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user