Skip to content
Permalink
Browse files

[JENKINS-43507] Fix up tests after consolidation of PR fixes

  • Loading branch information...
stephenc committed Jun 15, 2017
1 parent 8648609 commit f2d4d3f07ab28ed3fe709def14b444159590d54d
@@ -25,6 +25,7 @@

package integration;

import hudson.model.FreeStyleProject;
import hudson.model.TopLevelItem;
import integration.harness.BasicBranchProjectFactory;
import integration.harness.BasicDummyStepBranchProperty;
@@ -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;
@@ -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 {
@@ -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"));
}
}

@@ -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("")));

0 comments on commit f2d4d3f

Please sign in to comment.
You can’t perform that action at this time.