forked from bklarson/Jenkins-repo-plugin
-
Notifications
You must be signed in to change notification settings - Fork 84
/
RepoScmTest.java
48 lines (43 loc) · 1.58 KB
/
RepoScmTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package hudson.plugins.repo;
import hudson.AbortException;
import hudson.model.FreeStyleProject;
import hudson.tasks.Shell;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* {@link JenkinsRule} based tests for {@link RepoScm}
*/
public class RepoScmTest {
@Rule
public JenkinsRule j = new JenkinsRule();
@Test
public void configRoundTrip() throws Exception {
FreeStyleProject project = j.createFreeStyleProject();
final String manifestRepositoryUrl = "https://gerrit/projects/platform.git";
RepoScm scm = new RepoScm(manifestRepositoryUrl);
scm.setCleanFirst(true);
project.setScm(scm);
project.getBuildersList().add(new Shell("ecgo hello"));
project.save();
j.configRoundtrip(project);
project = j.jenkins.getItemByFullName(project.getFullName(), FreeStyleProject.class);
scm = (RepoScm) project.getScm();
assertTrue(scm.isCleanFirst());
assertEquals(manifestRepositoryUrl, scm.getManifestRepositoryUrl());
}
@Issue("JENKINS-68562")
@Test
public void abortIfUrlLocal() throws Exception {
final String manifestRepositoryUrl = "https://gerrit/projects/platform.git";
try {
new RepoScm(manifestRepositoryUrl).abortIfUrlLocal();
} catch (AbortException e) {
fail("https manifest URLs should always be valid");
}
}
}