Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-40707
tidying
  • Loading branch information
prospero238 committed Dec 30, 2016
1 parent ae1ff90 commit 085707e
Showing 1 changed file with 13 additions and 9 deletions.
Expand Up @@ -4,7 +4,6 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.ExecutionException;

import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -39,14 +38,9 @@ public class LiquibaseUpdateBuildStepTest {
@Before
public void setup() throws IOException {
File workspace = temporaryFolder.newFolder("workspace");
InputStream resourceAsStream = getClass().getResourceAsStream("/pipeline-with-ws-token.groovy");
String template = IOUtils.toString(resourceAsStream);
pipelineScript = template.replaceAll("@WORKSPACE@", workspace.getAbsolutePath());

String projectName = RandomStringUtils.randomAlphabetic(8);
job = jenkinsRule.jenkins.createProject(WorkflowJob.class, projectName);

LiquibaseTestUtil.createFileFromResource(workspace, "/example-changesets/sunny-day-changeset.xml");
pipelineScript = generatePipelineScript(workspace);
copyChangeLogFileToWorkspace(workspace);
job = jenkinsRule.jenkins.createProject(WorkflowJob.class, RandomStringUtils.randomAlphabetic(8));
}

@Test
Expand All @@ -55,4 +49,14 @@ public void should_allow_friendly_update_name() throws ExecutionException, Inter
WorkflowRun workflowRun = job.scheduleBuild2(0).get();
assertThat(workflowRun.getResult(), is(Result.SUCCESS));
}

private static void copyChangeLogFileToWorkspace(File workspace) throws IOException {
LiquibaseTestUtil.createFileFromResource(workspace, "/example-changesets/sunny-day-changeset.xml");
}

private String generatePipelineScript(File workspace) throws IOException {
String template = IOUtils.toString(getClass().getResourceAsStream("/pipeline-with-ws-token.groovy"));
return template.replaceAll("@WORKSPACE@", workspace.getAbsolutePath());

}
}

0 comments on commit 085707e

Please sign in to comment.