Search in sources :

Example 1 with RunIfConfigs

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(""));
}
Also used : BuildLogElement(com.thoughtworks.go.domain.BuildLogElement) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) File(java.io.File) Test(org.junit.Test)

Example 2 with RunIfConfigs

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'"));
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) File(java.io.File) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 3 with RunIfConfigs

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();
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 4 with RunIfConfigs

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");
}
Also used : HgUrlArgument(com.thoughtworks.go.util.command.HgUrlArgument) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 5 with RunIfConfigs

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"));
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.jupiter.api.Test)

Aggregations

RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)29 Test (org.junit.jupiter.api.Test)22 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)10 File (java.io.File)9 Test (org.junit.Test)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 OnCancelConfig (com.thoughtworks.go.config.OnCancelConfig)3 RunIfConfig (com.thoughtworks.go.config.RunIfConfig)3 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)3 StubBuilder (com.thoughtworks.go.domain.builder.StubBuilder)3 Gson (com.google.gson.Gson)2 StubGoPublisher (com.thoughtworks.go.domain.StubGoPublisher)2 Builder (com.thoughtworks.go.domain.builder.Builder)2 HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)2 RunIf (com.googlecode.junit.ext.RunIf)1 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)1 BuildLogElement (com.thoughtworks.go.domain.BuildLogElement)1 FetchArtifactEnvironmentVariable (com.thoughtworks.go.plugin.access.artifact.models.FetchArtifactEnvironmentVariable)1 ArtifactRequestProcessor (com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1