use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class CreateTemplateConfigCommandTest method setup.
@BeforeEach
public void setup() {
result = new HttpLocalizedOperationResult();
currentUser = new Username(new CaseInsensitiveString("user"));
cruiseConfig = new GoConfigMother().defaultCruiseConfig();
pipelineTemplateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("template"), StageConfigMother.oneBuildPlanWithResourcesAndMaterials("stage", "job"));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnSpecificPipelinesForAGroupAdmin.
@Test
public void shouldReturnSpecificPipelinesForAGroupAdmin() throws Exception {
GoConfigMother configMother = new GoConfigMother();
BasicCruiseConfig config = GoConfigMother.defaultCruiseConfig();
GoConfigMother.enableSecurityWithPasswordFilePlugin(config);
GoConfigMother.addUserAsSuperAdmin(config, "superadmin");
PipelineConfig pipelineConfig1 = configMother.addPipelineWithGroup(config, "group1", "p1", "s1", "j1");
PipelineConfig pipelineConfig2 = configMother.addPipelineWithGroup(config, "group2", "p2", "s1", "j1");
configMother.addAdminUserForPipelineGroup(config, "groupAdmin", "group1");
when(goConfigDao.loadForEditing()).thenReturn(config);
expectLoad(config);
List<PipelineConfig> pipelines = goConfigService.getAllPipelineConfigsForEditForUser(new Username("groupAdmin"));
assertThat(pipelines, contains(pipelineConfig1));
assertThat(pipelines, not(contains(pipelineConfig2)));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnNullIfNoPipelineExistByPipelineName.
@Test
public void shouldReturnNullIfNoPipelineExistByPipelineName() throws Exception {
GoConfigMother configMother = new GoConfigMother();
BasicCruiseConfig config = GoConfigMother.defaultCruiseConfig();
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1", "job1");
configMother.addPipelineWithGroup(config, "group1", "pipeline2", "stage1", "job1");
configMother.addPipelineWithGroup(config, "group2", "pipeline3", "stage1", "job1");
expectLoad(config);
assertThat(goConfigService.findPipelineByName(new CaseInsensitiveString("invalid")), is(nullValue()));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldReturnInvalidWhenPipelineGroupPartialHasInvalidAttributeValue.
@Test
public void shouldReturnInvalidWhenPipelineGroupPartialHasInvalidAttributeValue() throws Exception {
String groupName = "group_name";
String md5 = "md5";
cruiseConfig = new BasicCruiseConfig();
expectLoad(cruiseConfig);
new GoConfigMother().addPipelineWithGroup(cruiseConfig, groupName, "pipeline_name", "stage_name", "job_name");
expectLoadForEditing(cruiseConfig);
when(goConfigDao.md5OfConfigFile()).thenReturn(md5);
String pipelineGroupContent = groupXmlWithInvalidAttributeValue(groupName);
GoConfigValidity validity = goConfigService.groupSaver(groupName).saveXml(pipelineGroupContent, "md5");
assertThat(validity.isValid(), Matchers.is(false));
assertThat(((GoConfigValidity.InvalidGoConfig) validity).errorMessage(), containsString("Name is invalid. \"pipeline@$^\""));
verify(goConfigDao, never()).updateConfig(any(UpdateConfigCommand.class));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class GoConfigServiceTest method shouldIncludeAllLocalPipelinesWithSpecificFingerprint.
@Test
public void shouldIncludeAllLocalPipelinesWithSpecificFingerprint() throws Exception {
cruiseConfig = new BasicCruiseConfig();
expectLoad(cruiseConfig);
PipelineConfig pipelineConfig = new GoConfigMother().addPipelineWithGroup(cruiseConfig, "group", "pipeline_name", "stage_name", "job_name");
GitMaterialConfig gitMaterialConfig = git("https://foo");
MaterialConfigs materialConfigs = new MaterialConfigs(gitMaterialConfig);
pipelineConfig.setMaterialConfigs(materialConfigs);
List<CaseInsensitiveString> pipelineNames = goConfigService.pipelinesWithMaterial(gitMaterialConfig.getFingerprint());
assertThat(pipelineNames, contains(new CaseInsensitiveString("pipeline_name")));
}
Aggregations