use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldWriteConfigWithTaskExecutionConditions.
@Test
public void shouldWriteConfigWithTaskExecutionConditions() throws Exception {
CruiseConfig cruiseConfig = ConfigMigrator.load(ConfigFileFixture.TASKS_WITH_CONDITION);
xmlWriter.write(cruiseConfig, output, false);
final ByteArrayInputStream inputStream = new ByteArrayInputStream(output.toByteArray());
CruiseConfig config = xmlLoader.loadConfigHolder(IOUtils.toString(inputStream, UTF_8)).config;
JobConfig job = config.jobConfigByName("pipeline1", "mingle", "cardlist", true);
assertThat(job.tasks().size(), is(2));
assertThat(job.tasks().findFirstByType(AntTask.class).getConditions().get(0), is(new RunIfConfig("failed")));
RunIfConfigs conditions = job.tasks().findFirstByType(NantTask.class).getConditions();
assertThat(conditions.get(0), is(new RunIfConfig("failed")));
assertThat(conditions.get(1), is(new RunIfConfig("any")));
assertThat(conditions.get(2), is(new RunIfConfig("passed")));
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class ConfigConverterTest method shouldMigrateNantTaskToCR.
@Test
void shouldMigrateNantTaskToCR() {
NantTask nantTask = new NantTask();
nantTask.setBuildFile("nant");
nantTask.setWorkingDirectory("src");
nantTask.setTarget("build");
nantTask.setNantPath("path");
nantTask.setConditions(new RunIfConfigs(RunIfConfig.PASSED));
CRNantTask result = (CRNantTask) configConverter.taskToCRTask(nantTask);
assertThat(result.getRunIf()).isEqualTo(CRRunIf.passed);
assertThat(result.getBuildFile()).isEqualTo("nant");
assertThat(result.getTarget()).isEqualTo("build");
assertThat(result.getWorkingDirectory()).isEqualTo("src");
assertThat(result.getNantPath()).isEqualTo("path");
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class ConfigConverterTest method shouldConvertExecTaskWhenCancelIsNotSpecifiedToCR.
@Test
void shouldConvertExecTaskWhenCancelIsNotSpecifiedToCR() {
ExecTask execTask = new ExecTask("bash", new Arguments(new Argument("1"), new Argument("2")), "work");
execTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
execTask.setTimeout(120L);
CRExecTask result = (CRExecTask) configConverter.taskToCRTask(execTask);
assertThat(result.getRunIf()).isEqualTo(CRRunIf.failed);
assertThat(result.getCommand()).isEqualTo("bash");
assertThat(result.getArguments()).contains("1");
assertThat(result.getArguments()).contains("2");
assertThat(result.getWorkingDirectory()).isEqualTo("work");
assertThat(result.getTimeout()).isEqualTo(120L);
assertThat(result.getOnCancel()).isNull();
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class ConfigConverterTest method shouldConvertFetchArtifactTaskWhenSourceIsFileToCR.
@Test
void shouldConvertFetchArtifactTaskWhenSourceIsFileToCR() {
FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("stage"), new CaseInsensitiveString("job"), "src", "dest");
fetchTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
CRFetchArtifactTask result = (CRFetchArtifactTask) configConverter.taskToCRTask(fetchTask);
assertThat(result.getRunIf()).isEqualTo(CRRunIf.failed);
assertThat(result.getDestination()).isEqualTo("dest");
assertThat(result.getJob()).isEqualTo("job");
assertThat(result.getPipeline()).isEqualTo("upstream");
assertThat(result.getSource()).isEqualTo("src");
assertThat(result.sourceIsDirectory()).isFalse();
}
Aggregations