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());
}
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);
}
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();
}
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();
}
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);
}
Aggregations