use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class BuilderTest method shouldNotBuildIfTheJobIsCancelled.
@Test
public void shouldNotBuildIfTheJobIsCancelled() throws Exception {
CommandBuilder builder = new CommandBuilder("echo", "", new File("."), new RunIfConfigs(FAILED), new StubBuilder(), "");
builder.build(new BuildLogElement(), PASSED, goPublisher, environmentVariableContext, null);
assertThat(goPublisher.getMessage(), is(""));
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class BuilderTest method shouldReportErrorWhenCancelCommandDoesNotExists.
@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void shouldReportErrorWhenCancelCommandDoesNotExists() throws Exception {
StubBuilder stubBuilder = new StubBuilder();
CommandBuilder cancelBuilder = new CommandBuilder("echo2", "cancel task", new File("."), new RunIfConfigs(FAILED), stubBuilder, "");
CommandBuilder builder = new CommandBuilder("echo", "normal task", new File("."), new RunIfConfigs(FAILED), cancelBuilder, "");
builder.cancel(goPublisher, new EnvironmentVariableContext(), null);
assertThat(goPublisher.getMessage(), containsString("Error happened while attempting to execute 'echo2 cancel task'"));
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class ConfigConverterTest method shouldConvertFetchPluggableArtifactTaskToCRFetchPluggableArtifactTask.
@Test
void shouldConvertFetchPluggableArtifactTaskToCRFetchPluggableArtifactTask() {
FetchPluggableArtifactTask fetchPluggableArtifactTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("stage"), new CaseInsensitiveString("job"), "artifactId");
fetchPluggableArtifactTask.setConditions(new RunIfConfigs(RunIfConfig.PASSED));
CRFetchPluggableArtifactTask result = (CRFetchPluggableArtifactTask) configConverter.taskToCRTask(fetchPluggableArtifactTask);
assertThat(result.getRunIf()).isEqualTo(CRRunIf.passed);
assertThat(result.getJob()).isEqualTo("job");
assertThat(result.getPipeline()).isEqualTo("upstream");
assertThat(result.getStage()).isEqualTo("stage");
assertThat(result.getArtifactId()).isEqualTo("artifactId");
assertThat(result.getConfiguration().isEmpty()).isTrue();
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class ConfigConverterTest method shouldConvertExecTaskWhenCancelIsSpecifiedToCR.
@Test
void shouldConvertExecTaskWhenCancelIsSpecifiedToCR() {
ExecTask onCancel = new ExecTask();
onCancel.setCommand("kill");
ExecTask execTask = new ExecTask("bash", new Arguments(new Argument("1"), new Argument("2")), "work");
execTask.setOnCancelConfig(new OnCancelConfig(onCancel));
execTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
execTask.setTimeout(120L);
CRExecTask result = (CRExecTask) configConverter.taskToCRTask(execTask);
CRExecTask crOnCancel = (CRExecTask) result.getOnCancel();
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(crOnCancel.getCommand()).isEqualTo("kill");
}
use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.
the class FetchPluggableArtifactBuilderTest method shouldCallPublisherToFetchMetadataFile.
@Test
public void shouldCallPublisherToFetchMetadataFile() {
final FetchPluggableArtifactBuilder builder = new FetchPluggableArtifactBuilder(new RunIfConfigs(), new NullBuilder(), "", jobIdentifier, artifactStore, fetchPluggableArtifactTask.getConfiguration(), fetchPluggableArtifactTask.getArtifactId(), sourceOnServer, metadataDest, checksumFileHandler);
builder.build(publisher, new EnvironmentVariableContext(), null, artifactExtension, registry, "utf-8");
final ArgumentCaptor<FetchArtifactBuilder> argumentCaptor = ArgumentCaptor.forClass(FetchArtifactBuilder.class);
verify(publisher).fetch(argumentCaptor.capture());
final FetchArtifactBuilder fetchArtifactBuilder = argumentCaptor.getValue();
assertThat(fetchArtifactBuilder.getSrc(), is("pluggable-artifact-metadata/cd.go.s3.json"));
assertThat(fetchArtifactBuilder.getDest(), is("cd.go.s3.json"));
}
Aggregations