Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #99 from mryan43/master
[JENKINS-41657] Allow filling of credential ids from admin panel
- Loading branch information
Showing
4 changed files
with
141 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/test/java/hudson/plugins/mercurial/MercurialSCMSourceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package hudson.plugins.mercurial; | ||
|
||
import hudson.FilePath; | ||
import hudson.tools.ToolProperty; | ||
import hudson.util.LogTaskListener; | ||
import hudson.util.StreamTaskListener; | ||
import jenkins.scm.api.SCMRevision; | ||
import org.junit.*; | ||
import org.junit.rules.TemporaryFolder; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import java.util.Collections; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
@Issue("JENKINS-41657") | ||
public class MercurialSCMSourceTest { | ||
|
||
@ClassRule public static JenkinsRule j = new JenkinsRule(); | ||
@ClassRule public static MercurialRule m = new MercurialRule(j); | ||
@ClassRule public static TemporaryFolder tmp = new TemporaryFolder(); | ||
|
||
private static LogTaskListener listener; | ||
private static MercurialSCMSource mercurialSCMSource; | ||
|
||
@BeforeClass | ||
public static void prepareEnvironment() throws Exception { | ||
String instName = "caching"; | ||
MercurialInstallation installation = new MercurialInstallation(instName, "", "hg", false, true, null, false, null, | ||
Collections.<ToolProperty<?>>emptyList()); | ||
listener = new LogTaskListener(Logger.getLogger(MercurialSCMSourceTest.class.getName()), Level.INFO); | ||
j.jenkins.getDescriptorByType(MercurialInstallation.DescriptorImpl.class).setInstallations(installation); | ||
FilePath repo = new FilePath(tmp.getRoot()); | ||
installation.forNode(j.jenkins, StreamTaskListener.fromStdout()); | ||
m.hg(repo, "init"); | ||
repo.child("file").write("initial content", "UTF-8"); | ||
m.hg(repo, "commit", "--addremove", "--message=initial"); | ||
m.hg(repo, "tag", "version-1.0"); | ||
m.hg(repo, "branch", "my-branch"); | ||
repo.child("file2").write("content in branch", "UTF-8"); | ||
m.hg(repo, "commit", "--addremove", "--message=branch"); | ||
m.hg(repo, "tag", "version-1.1"); | ||
|
||
|
||
installation.forNode(j.jenkins, StreamTaskListener.fromStdout()); | ||
mercurialSCMSource = new MercurialSCMSource(null, instName, tmp.getRoot().toURI().toURL().toString(), null, null, null, null, null, true); | ||
} | ||
|
||
@Test public void testRetrieveUnknownRevision() throws Exception { | ||
Assert.assertNull(mercurialSCMSource.retrieve("does_not_exist", listener)); | ||
} | ||
|
||
@Test public void testRetrieveTag() throws Exception { | ||
SCMRevision revision = mercurialSCMSource.retrieve("version-1.1", listener); | ||
assertTrue(revision.toString().startsWith("my-branch:")); | ||
revision = mercurialSCMSource.retrieve("version-1.0", listener); | ||
assertTrue(revision.toString().startsWith("default:")); | ||
} | ||
|
||
@Test public void testRetrieveBranchTip() throws Exception { | ||
SCMRevision revision = mercurialSCMSource.retrieve("my-branch", listener); | ||
assertTrue(revision.toString().startsWith("my-branch:")); | ||
} | ||
|
||
@Test public void testRetrieveRepoTip() throws Exception { | ||
SCMRevision revision = mercurialSCMSource.retrieve("tip", listener); | ||
assertTrue(revision.toString().startsWith("my-branch:")); | ||
} | ||
|
||
} |