Skip to content

Commit

Permalink
Simplify GitSCMFileSystemTest with import
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEWaite committed Jul 2, 2023
1 parent ac489cf commit e66e798
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/test/java/jenkins/plugins/git/GitSCMFileSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,17 @@ public void calculate_head_name_with_env() throws Exception {
@Test
public void calculate_head_name() throws Exception {
String remote = "origin";
GitSCMFileSystem.BuilderImpl.HeadNameResult result1 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("branch"), null, null, null, remote);
HeadNameResult result1 = HeadNameResult.calculate(new BranchSpec("branch"), null, null, null, remote);
assertEquals("branch", result1.headName);
assertEquals("refs/remotes/origin/branch", result1.remoteHeadName);
assertEquals("+refs/heads/branch:refs/remotes/origin/branch", result1.refspec);

GitSCMFileSystem.BuilderImpl.HeadNameResult result2 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("refs/heads/branch"), null, null, null, remote);
HeadNameResult result2 = HeadNameResult.calculate(new BranchSpec("refs/heads/branch"), null, null, null, remote);
assertEquals("branch", result2.headName);
assertEquals("refs/remotes/origin/branch", result2.remoteHeadName);
assertEquals("+refs/heads/branch:refs/remotes/origin/branch", result2.refspec);

GitSCMFileSystem.BuilderImpl.HeadNameResult result3 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("refs/tags/my-tag"), null, null, null, remote);
HeadNameResult result3 = HeadNameResult.calculate(new BranchSpec("refs/tags/my-tag"), null, null, null, remote);
assertEquals("my-tag", result3.headName);
assertEquals("refs/remotes/origin/my-tag", result3.remoteHeadName);
assertEquals("+refs/tags/my-tag:refs/remotes/origin/my-tag", result3.refspec);
Expand All @@ -526,12 +526,12 @@ public void calculate_head_name_with_refspec_commit() throws Exception {
String remote = "origin";
String commit = "0123456789" + "0123456789" + "0123456789" + "0123456789";
String branch = "branch";
GitSCMFileSystem.BuilderImpl.HeadNameResult result1 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec(commit), null, branch, null, remote);
HeadNameResult result1 = HeadNameResult.calculate(new BranchSpec(commit), null, branch, null, remote);
assertEquals(commit, result1.headName);
assertEquals(commit, result1.remoteHeadName);
assertEquals(branch, result1.refspec);

GitSCMFileSystem.BuilderImpl.HeadNameResult result2 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, "${REFSPEC}",
HeadNameResult result2 = HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, "${REFSPEC}",
new EnvVars("BRANCH", commit, "REFSPEC", branch), remote);
assertEquals(commit, result2.headName);
assertEquals(commit, result2.remoteHeadName);
Expand All @@ -541,12 +541,12 @@ public void calculate_head_name_with_refspec_commit() throws Exception {
@Test
public void calculate_head_name_with_refspec_FETCH_HEAD() throws Exception {
String remote = "origin";
GitSCMFileSystem.BuilderImpl.HeadNameResult result1 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec(Constants.FETCH_HEAD), null, "refs/changes/1/2/3", null, remote);
HeadNameResult result1 = HeadNameResult.calculate(new BranchSpec(Constants.FETCH_HEAD), null, "refs/changes/1/2/3", null, remote);
assertEquals(Constants.FETCH_HEAD, result1.headName);
assertEquals(Constants.FETCH_HEAD, result1.remoteHeadName);
assertEquals("refs/changes/1/2/3", result1.refspec);

GitSCMFileSystem.BuilderImpl.HeadNameResult result2 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, "${REFSPEC}",
HeadNameResult result2 = HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, "${REFSPEC}",
new EnvVars("BRANCH", Constants.FETCH_HEAD, "REFSPEC", "refs/changes/1/2/3"), remote);
assertEquals(Constants.FETCH_HEAD, result2.headName);
assertEquals(Constants.FETCH_HEAD, result2.remoteHeadName);
Expand All @@ -563,7 +563,7 @@ public void null_pointer_exception() throws Exception {
ObjectId git260 = client.revParse(GIT_2_6_0_TAG);
AbstractGitSCMSource.SCMRevisionImpl rev260 =
new AbstractGitSCMSource.SCMRevisionImpl(new SCMHead("origin"), git260.getName());
GitSCMFileSystem.BuilderImpl.HeadNameResult result1 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("master-f"), rev260, null, null, "origin");
HeadNameResult result1 = HeadNameResult.calculate(new BranchSpec("master-f"), rev260, null, null, "origin");
assertEquals("master-f", result1.headName);
assertTrue(result1.refspec.startsWith("+" + Constants.R_HEADS));
}
Expand Down

0 comments on commit e66e798

Please sign in to comment.