Search in sources :

Example 6 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class FetchPluggableArtifactBuilderTest method shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact.

@Test
public void shouldRegisterAndDeRegisterArtifactRequestProcessBeforeAndAfterPublishingPluggableArtifact() throws IOException {
    final FetchPluggableArtifactBuilder builder = new FetchPluggableArtifactBuilder(new RunIfConfigs(), new NullBuilder(), "", jobIdentifier, artifactStore, fetchPluggableArtifactTask.getConfiguration(), fetchPluggableArtifactTask.getArtifactId(), sourceOnServer, metadataDest, checksumFileHandler);
    final Map<String, Object> metadata = Collections.singletonMap("Version", "10.12.0");
    FileUtils.writeStringToFile(metadataDest, new Gson().toJson(metadata), StandardCharsets.UTF_8);
    builder.build(publisher, new EnvironmentVariableContext(), null, artifactExtension, registry, "utf-8");
    InOrder inOrder = inOrder(registry, artifactExtension);
    inOrder.verify(registry, times(1)).registerProcessorFor(eq(CONSOLE_LOG.requestName()), ArgumentMatchers.any(ArtifactRequestProcessor.class));
    inOrder.verify(artifactExtension).fetchArtifact(eq(PLUGIN_ID), eq(artifactStore), eq(fetchPluggableArtifactTask.getConfiguration()), any(), eq(metadataDest.getParent()));
    inOrder.verify(registry, times(1)).removeProcessorFor(CONSOLE_LOG.requestName());
}
Also used : InOrder(org.mockito.InOrder) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Gson(com.google.gson.Gson) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) ArtifactRequestProcessor(com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor) Test(org.junit.jupiter.api.Test)

Example 7 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class ConfigConverterTest method shouldMigrateAntTaskToCR.

@Test
void shouldMigrateAntTaskToCR() {
    RakeTask rakeTask = new RakeTask();
    rakeTask.setBuildFile("Rakefile.rb");
    rakeTask.setWorkingDirectory("src");
    rakeTask.setTarget("build");
    rakeTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
    AntTask antTask = new AntTask();
    antTask.setBuildFile("ant");
    antTask.setWorkingDirectory("src");
    antTask.setTarget("build");
    antTask.setOnCancelConfig(new OnCancelConfig(rakeTask));
    antTask.setConditions(new RunIfConfigs(RunIfConfig.FAILED));
    CRBuildTask result = (CRBuildTask) configConverter.taskToCRTask(antTask);
    CRBuildTask onCancel = (CRBuildTask) result.getOnCancel();
    assertThat(result.getRunIf()).isEqualTo(CRRunIf.failed);
    assertThat(result.getBuildFile()).isEqualTo("ant");
    assertThat(result.getTarget()).isEqualTo("build");
    assertThat(result.getWorkingDirectory()).isEqualTo("src");
    assertThat(onCancel.getType()).isEqualTo(CRBuildFramework.rake);
    assertThat(onCancel.getBuildFile()).isEqualTo("Rakefile.rb");
    assertThat(onCancel.getTarget()).isEqualTo("build");
    assertThat(onCancel.getWorkingDirectory()).isEqualTo("src");
    assertThat(onCancel.getRunIf()).isEqualTo(CRRunIf.failed);
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 8 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class ConfigConverterTest method shouldConvertFetchArtifactTaskWhenSourceIsDirectoryToCR.

@Test
void shouldConvertFetchArtifactTaskWhenSourceIsDirectoryToCR() {
    FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("stage"), new CaseInsensitiveString("job"), "", "dest");
    fetchTask.setSrcdir("src");
    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()).isTrue();
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 9 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class ConfigConverterTest method shouldConvertExecTaskWhenOldArgsAreUsed.

@Test
void shouldConvertExecTaskWhenOldArgsAreUsed() {
    ExecTask execTask = new ExecTask("bash", "1 2 \"file name\"", "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.getArguments()).contains("file name");
    assertThat(result.getWorkingDirectory()).isEqualTo("work");
    assertThat(result.getTimeout()).isEqualTo(120L);
    assertThat(result.getOnCancel()).isNull();
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) Test(org.junit.jupiter.api.Test)

Example 10 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class ConfigConverterTest method shouldMigratePluggableTasktoCR.

@Test
void shouldMigratePluggableTasktoCR() {
    ArrayList<CRConfigurationProperty> configs = new ArrayList<>();
    configs.add(new CRConfigurationProperty("k", "m", null));
    ConfigurationProperty prop = new ConfigurationProperty(new ConfigurationKey("k"), new ConfigurationValue("m"));
    Configuration config = new Configuration(prop);
    PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration("myplugin", "1"), config);
    pluggableTask.setConditions(new RunIfConfigs(RunIfConfig.ANY));
    CRPluggableTask result = (CRPluggableTask) configConverter.taskToCRTask(pluggableTask);
    assertThat(result.getPluginConfiguration().getId()).isEqualTo("myplugin");
    assertThat(result.getPluginConfiguration().getVersion()).isEqualTo("1");
    assertThat(result.getConfiguration()).contains(new CRConfigurationProperty("k", "m", null));
    assertThat(result.getRunIf()).isEqualTo(CRRunIf.any);
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) 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