Skip to content

Commit

Permalink
[JENKINS-30785] Integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed May 5, 2017
1 parent 1940694 commit 9eb3cbf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/java/org/jenkinsci/plugins/workflow/job/CLITest.java
Expand Up @@ -25,6 +25,8 @@
package org.jenkinsci.plugins.workflow.job;

import hudson.cli.CLICommandInvoker;
import java.io.File;
import org.apache.commons.io.FileUtils;
import static org.hamcrest.Matchers.*;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.junit.ClassRule;
Expand Down Expand Up @@ -69,4 +71,18 @@ public class CLITest {
assertThat(res.stdout(), containsString("this is what I said"));
}

@Issue("JENKINS-30785")
@Test public void reload() throws Exception {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("echo 'first version'", true));
r.assertLogContains("first version", r.buildAndAssertSuccess(p));
File configXml = new File(p.getRootDir(), "config.xml");
FileUtils.write(configXml, FileUtils.readFileToString(configXml).replace("first version", "second version"));
assertThat(new CLICommandInvoker(r, "reload-job").invokeWithArgs("p"), CLICommandInvoker.Matcher.succeededSilently());
r.assertLogContains("second version", r.buildAndAssertSuccess(p));
CLICommandInvoker.Result res = new CLICommandInvoker(r, "reload-job").invokeWithArgs("q");
assertThat(res, CLICommandInvoker.Matcher.failedWith(3));
assertThat(res.stderr(), containsString("No such item ‘q’ exists. Perhaps you meant ‘p’?"));
}

}

0 comments on commit 9eb3cbf

Please sign in to comment.