use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.
the class PipelineBeanTest method shouldReturnExecTasksWithoutParameters.
@Test
public void shouldReturnExecTasksWithoutParameters() {
PipelineBean execBean = execBean("exec", "ls", null);
ExecTask execTask = new ExecTask("ls", "", (String) null);
assertThat(execBean.getTasks().get(0), is(execTask));
execBean = execBean("exec", " ls ", null);
execTask = new ExecTask("ls", "", (String) null);
assertThat(execBean.getTasks().get(0), is(execTask));
}
use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.
the class ExecTaskTest method validateTask_shouldValidateThatCommandIsRequired.
@Test
public void validateTask_shouldValidateThatCommandIsRequired() {
ExecTask execTask = new ExecTask();
execTask.validateTask(null);
assertThat(execTask.errors().isEmpty(), is(false));
assertThat(execTask.errors().on(ExecTask.COMMAND), is("Command cannot be empty"));
}
use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.
the class ExecTaskBuilderTest method shouldUseProjectDefaultWorkingDirectoryIfNotSpecified.
@Test
public void shouldUseProjectDefaultWorkingDirectoryIfNotSpecified() throws Exception {
ExecTask task = new ExecTask("command", "", (String) null);
final File defaultWorkingDir = new File("foo");
CommandBuilder builder = (CommandBuilder) execTaskBuilder.createBuilder(builderFactory, task, TasksTest.pipelineStub("label", "foo"), resolver);
assertThat(builder.getWorkingDir(), isSamePath(defaultWorkingDir));
}
use of com.thoughtworks.go.config.ExecTask in project gocd by gocd.
the class TaskViewServiceTest method shouldGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOn.
@Test
public void shouldGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOn() {
List<Class<? extends Task>> taskClasses = taskImplementations();
taskClasses.add(FetchPluggableArtifactTask.class);
when(featureToggleService.isToggleOn(Toggles.ARTIFACT_EXTENSION_KEY)).thenReturn(true);
when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
when(registry.getViewModelFor(new FetchPluggableArtifactTask(), "new")).thenReturn(viewModel(new FetchPluggableArtifactTask()));
when(registry.getViewModelFor(new ExecTask(), "new")).thenReturn(new TaskViewModel(new ExecTask(), ""));
List<PluggableViewModel> taskViewModels = taskViewService.getTaskViewModels();
assertThat(taskViewModels.size(), is(4));
assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new ExecTask(), "")));
assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new FetchPluggableArtifactTask(), "")));
}
Aggregations