Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-43507] Fix up tests after consolidation of PR fixes
  • Loading branch information
stephenc committed Jun 15, 2017
1 parent 8648609 commit f2d4d3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/test/java/integration/EnvironmentTest.java
Expand Up @@ -25,6 +25,7 @@

package integration;

import hudson.model.FreeStyleProject;
import hudson.model.TopLevelItem;
import integration.harness.BasicBranchProjectFactory;
import integration.harness.BasicDummyStepBranchProperty;
Expand All @@ -35,6 +36,7 @@
import jenkins.scm.impl.mock.MockSCMController;
import jenkins.scm.impl.mock.MockSCMDiscoverBranches;
import jenkins.scm.impl.mock.MockSCMDiscoverChangeRequests;
import jenkins.scm.impl.mock.MockSCMDiscoverTags;
import jenkins.scm.impl.mock.MockSCMSource;
import org.junit.Before;
import org.junit.ClassRule;
Expand All @@ -44,6 +46,7 @@
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;

public class EnvironmentTest {
Expand Down Expand Up @@ -131,20 +134,24 @@ public void given_multibranch_when_buildingAChangeRequest_then_environmentContai
}
}

@Test
public void given_multibranch_when_buildingATag_then_environmentContainsTagName() throws Exception {
try (MockSCMController c = MockSCMController.create()) {
c.createRepository("foo");
c.createTag("foo", "master", "release");
BasicMultiBranchProject prj = r.jenkins.createProject(BasicMultiBranchProject.class, "foo");
prj.setCriteria(null);
prj.setProjectFactory(new BasicBranchProjectFactory());
BranchSource source = new BranchSource(new MockSCMSource(null, c, "foo", true, true, false));
BranchSource source = new BranchSource(new MockSCMSource(c, "foo", new MockSCMDiscoverBranches(), new MockSCMDiscoverTags()));
source.setStrategy(
new DefaultBranchPropertyStrategy(new BranchProperty[]{new BasicDummyStepBranchProperty()}));
prj.getSourcesList().add(source);
prj.scheduleBuild2(0).getFuture().get();
r.waitUntilNoActivity();
assertThat(r.getLog(prj.getItem("release").getBuildByNumber(1)), containsString("TAG_NAME=release"));
FreeStyleProject job = prj.getItem("release");
assertThat(job.getLastBuild(), nullValue());
r.buildAndAssertSuccess(job);
assertThat(r.getLog(job.getBuildByNumber(1)), containsString("TAG_NAME=release"));
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/java/jenkins/branch/BranchNameContributorTest.java
Expand Up @@ -165,11 +165,13 @@ public void buildEnvironmentFor() throws Exception {
instance.buildEnvironmentFor(tag, env, new LogTaskListener(LOGGER, Level.FINE));
assertThat(env.keySet(), containsInAnyOrder(
is("BRANCH_NAME"),
is("TAG_NAME"),
is("TAG_TIMESTAMP"),
is("TAG_UNIXTIME"),
is("TAG_DATE")
));
assertThat(env.get("BRANCH_NAME"), is("v1.0"));
assertThat(env.get("TAG_NAME"), is("v1.0"));
assertThat(env.get("TAG_TIMESTAMP"), not(is("")));
assertThat(env.get("TAG_UNIXTIME"), not(is("")));
assertThat(env.get("TAG_DATE"), not(is("")));
Expand Down

0 comments on commit f2d4d3f

Please sign in to comment.