Skip to content

Commit

Permalink
Use an import to simplify reading the test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEWaite committed Jul 1, 2023
1 parent 6d0daaf commit fb0afc9
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/test/java/jenkins/plugins/git/GitSCMFileSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;

import jenkins.plugins.git.GitSCMFileSystem.BuilderImpl.HeadNameResult;

/**
* Tests for {@link AbstractGitSCMSource}
*/
Expand Down Expand Up @@ -475,33 +477,27 @@ public void filesystem_supports_descriptor() throws Exception {
@Test
public void calculate_head_name_with_env() throws Exception {
String remote = "origin";
GitSCMFileSystem.BuilderImpl.HeadNameResult result1 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, null,
new EnvVars("BRANCH", "master-a"), remote);
HeadNameResult result1 = HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, null, new EnvVars("BRANCH", "master-a"), remote);
assertEquals("master-a", result1.headName);
assertTrue(result1.refspec.startsWith("+" + Constants.R_HEADS));

GitSCMFileSystem.BuilderImpl.HeadNameResult result2 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, null,
new EnvVars("BRANCH", "refs/heads/master-b"), remote);
HeadNameResult result2 = HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, null, new EnvVars("BRANCH", "refs/heads/master-b"), remote);
assertEquals("master-b", result2.headName);
assertTrue(result2.refspec.startsWith("+" + Constants.R_HEADS));

GitSCMFileSystem.BuilderImpl.HeadNameResult result3 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("refs/heads/${BRANCH}"), null,null,
new EnvVars("BRANCH", "master-c"), remote);
HeadNameResult result3 = HeadNameResult.calculate(new BranchSpec("refs/heads/${BRANCH}"), null, null, new EnvVars("BRANCH", "master-c"), remote);
assertEquals("master-c", result3.headName);
assertTrue(result3.refspec.startsWith("+" + Constants.R_HEADS));

GitSCMFileSystem.BuilderImpl.HeadNameResult result4 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, null,
null, remote);
HeadNameResult result4 = HeadNameResult.calculate(new BranchSpec("${BRANCH}"), null, null, null, remote);
assertEquals("${BRANCH}", result4.headName);
assertTrue(result4.refspec.startsWith("+" + Constants.R_HEADS));

GitSCMFileSystem.BuilderImpl.HeadNameResult result5 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("*/${BRANCH}"), null, null,
new EnvVars("BRANCH", "master-d"), remote);
HeadNameResult result5 = HeadNameResult.calculate(new BranchSpec("*/${BRANCH}"), null, null, new EnvVars("BRANCH", "master-d"), remote);
assertEquals("master-d", result5.headName);
assertTrue(result5.refspec.startsWith("+" + Constants.R_HEADS));

GitSCMFileSystem.BuilderImpl.HeadNameResult result6 = GitSCMFileSystem.BuilderImpl.HeadNameResult.calculate(new BranchSpec("*/master-e"), null, null,
new EnvVars("BRANCH", "dummy"), remote);
HeadNameResult result6 = HeadNameResult.calculate(new BranchSpec("*/master-e"), null, null, new EnvVars("BRANCH", "dummy"), remote);
assertEquals("master-e", result6.headName);
assertTrue(result6.refspec.startsWith("+" + Constants.R_HEADS));
}
Expand Down

0 comments on commit fb0afc9

Please sign in to comment.