@Test
public void shouldErrorOutForTemplates_WhenItHasATaskWithInvalidWorkingDirectory() {
CruiseConfig cruiseConfig = GoConfigMother.configWithPipelines("some_pipeline");
StageConfig templateStage = StageConfigMother.stageWithTasks("templateStage");
ExecTask execTask = new ExecTask("ls", "-la", "/");
templateStage.getJobs().first().addTask(execTask);
PipelineTemplateConfig template = new PipelineTemplateConfig(new CaseInsensitiveString("template_name"), templateStage);
cruiseConfig.addTemplate(template);
try {
execTask.validateTask(ConfigSaveValidationContext.forChain(cruiseConfig, template, templateStage, templateStage.getJobs().first()));
assertThat(execTask.errors().isEmpty(), is(false));
assertThat(execTask.errors().on(ExecTask.WORKING_DIR), is("The path of the working directory for the custom command in job 'job' in stage 'templateStage' of template 'template_name' is outside the agent sandbox."));
} catch (Exception e) {
fail("should not have failed. Exception: " + e.getMessage());
}
}