Skip to content
Permalink
Browse files

[JENKINS-30357] Fixed failing tests.

  • Loading branch information...
ikedam committed Sep 21, 2015
1 parent 43699c2 commit d7df521bde6fe4dae57ad16c962e1957435b70e1
Showing with 21 additions and 8 deletions.
  1. +21 −8 src/test/java/hudson/plugins/copyartifact/ParameterizedBuildSelectorTest.java
@@ -25,6 +25,9 @@
package hudson.plugins.copyartifact;

import static org.junit.Assert.*;

import java.io.IOException;

import jenkins.util.VirtualFile;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
@@ -52,6 +55,10 @@
@ClassRule
public static JenkinsRule j = new JenkinsRule();

private WorkflowJob createWorkflowJob() throws IOException {
return j.jenkins.createProject(WorkflowJob.class, "test"+j.jenkins.getItems().size());
}

/**
* Should not cause a fatal error even for an undefined variable.
*
@@ -87,22 +94,25 @@ public void testUndefinedParameter() throws Exception {
@Test
public void testWorkflow() throws Exception {
// Prepare an artifact to be copied.
FreeStyleProject copiee = j.createFreeStyleProject("copiee");
FreeStyleProject copiee = j.createFreeStyleProject();
copiee.getBuildersList().add(new FileWriteBuilder("artifact.txt", "foobar"));
copiee.getPublishersList().add(new ArtifactArchiver("artifact.txt"));
j.assertBuildStatusSuccess(copiee.scheduleBuild2(0));

WorkflowJob copier = j.jenkins.createProject(WorkflowJob.class, "copier");
WorkflowJob copier = createWorkflowJob();
copier.setDefinition(new CpsFlowDefinition(
String.format(
"node {"
+ "step([$class: 'CopyArtifact',"
+ "projectName: 'copiee',"
+ "projectName: '%1$s',"
+ "filter: '**/*',"
+ "selector: [$class: 'ParameterizedBuildSelector', parameterName: 'SELECTOR'],"
+ "]);"
+ "step([$class: 'ArtifactArchiver', artifacts: '**/*']);"
+ "}",
true
copiee.getFullName()
),
true
));

WorkflowRun b = j.assertBuildStatusSuccess(copier.scheduleBuild2(
@@ -217,22 +227,25 @@ public void testEmptySelector() throws Exception {
@Test
public void testImmediateValue() throws Exception {
// Prepare an artifact to be copied.
FreeStyleProject copiee = j.createFreeStyleProject("copiee");
FreeStyleProject copiee = j.createFreeStyleProject();
copiee.getBuildersList().add(new FileWriteBuilder("artifact.txt", "foobar"));
copiee.getPublishersList().add(new ArtifactArchiver("artifact.txt"));
j.assertBuildStatusSuccess(copiee.scheduleBuild2(0));

WorkflowJob copier = j.jenkins.createProject(WorkflowJob.class, "copier");
WorkflowJob copier = createWorkflowJob();
copier.setDefinition(new CpsFlowDefinition(
String.format(
"node {"
+ "step([$class: 'CopyArtifact',"
+ "projectName: 'copiee',"
+ "projectName: '%1$s',"
+ "filter: '**/*',"
+ "selector: [$class: 'ParameterizedBuildSelector', parameterName: '${SELECTOR}'],"
+ "]);"
+ "step([$class: 'ArtifactArchiver', artifacts: '**/*']);"
+ "}",
true
copiee.getFullName()
),
true
));

WorkflowRun b = j.assertBuildStatusSuccess(copier.scheduleBuild2(

0 comments on commit d7df521

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