use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class PipelineConfigsServiceTest method shouldReturnXmlForGivenGroup_onGetXml.
@Test
public void shouldReturnXmlForGivenGroup_onGetXml() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
String groupName = "group_name";
new GoConfigMother().addPipelineWithGroup(cruiseConfig, groupName, "pipeline_name", "stage_name", "job_name");
when(goConfigService.getConfigForEditing()).thenReturn(cruiseConfig);
when(securityService.isUserAdminOfGroup(validUser.getUsername(), groupName)).thenReturn(true);
String actualXml = service.getXml(groupName, validUser, result);
String expectedXml = "<pipelines group=\"group_name\">\n <pipeline name=\"pipeline_name\">\n <materials>\n <svn url=\"file:///tmp/foo\" />\n </materials>\n <stage name=\"stage_name\">\n <jobs>\n <job name=\"job_name\">\n <tasks>\n <ant />\n </tasks>\n </job>\n </jobs>\n </stage>\n </pipeline>\n</pipelines>";
assertThat(actualXml, is(expectedXml));
assertThat(result.isSuccessful(), is(true));
verify(goConfigService, times(1)).getConfigForEditing();
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class MaterialUpdateServiceIntegrationTest method configWithMaterial.
private CruiseConfig configWithMaterial(SvnMaterialConfig goodMaterial) {
CruiseConfig config = new BasicCruiseConfig();
new GoConfigMother().addPipeline(config, "good-pipeline", "first-stage", new MaterialConfigs(goodMaterial));
return config;
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class ConfigMaterialUpdateListenerIntegrationTest method shouldCheckoutNewMaterial.
@Test
public void shouldCheckoutNewMaterial() throws Exception {
GoConfigMother mother = new GoConfigMother();
PipelineConfig pipelineConfig = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
configTestRepo.addPipelineToRepositoryAndPush("pipe1.gocd.xml", pipelineConfig);
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
File flyweightDir = materialRepository.folderFor(material);
assertThat(flyweightDir.exists(), is(true));
assertThat(new File(flyweightDir, "pipe1.gocd.xml").exists(), is(true));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class ConfigMaterialUpdateListenerIntegrationTest method shouldParseAndLoadValidPartialConfig.
@Test
public void shouldParseAndLoadValidPartialConfig() throws Exception {
String fileName = "pipe1.gocd.xml";
GoConfigMother mother = new GoConfigMother();
PipelineConfig pipelineConfig = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
PartialConfig partial = goConfigRepoConfigDataSource.latestPartialConfigForMaterial(materialConfig);
assertNotNull(partial);
assertThat(partial.getGroups().get(0).size(), is(1));
assertThat(partial.getGroups().get(0).get(0), is(pipelineConfig));
}
use of com.thoughtworks.go.helper.GoConfigMother in project gocd by gocd.
the class ConfigMaterialUpdateListenerIntegrationTest method shouldNotMergeFromInvalidConfigRepository_AndShouldKeepLastValidPart.
@Test
public void shouldNotMergeFromInvalidConfigRepository_AndShouldKeepLastValidPart() throws Exception {
String fileName = "pipe1.gocd.xml";
GoConfigMother mother = new GoConfigMother();
PipelineConfig pipelineConfig = mother.cruiseConfigWithOnePipelineGroup().getAllPipelineConfigs().get(0);
configTestRepo.addPipelineToRepositoryAndPush(fileName, pipelineConfig);
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
cachedGoConfig.forceReload();
assertThat(goConfigService.hasPipelineNamed(pipelineConfig.name()), is(true));
assertThat(goConfigService.pipelineConfigNamed(pipelineConfig.name()), is(pipelineConfig));
configTestRepo.addCodeToRepositoryAndPush("badPipe.gocd.xml", "added bad config file", "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<cruise xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"cruise-config.xsd\" schemaVersion=\"38\">\n" + "<pipelines group=\"changed\">\n" + " <pipeline name=\"badPipe\">\n" + " <materials>\n" + " <svn url=\"file:///tmp/foo\" />\n" + " <svn url=\"file:///tmp/foo\" />\n" + " </materials>\n" + " </pipeline>\n" + "</pipelines>" + "</cruise>");
materialUpdateService.updateMaterial(material);
// time for messages to pass through all services
waitForMaterialNotInProgress();
cachedGoConfig.forceReload();
// but we still have the old part
assertThat(goConfigService.hasPipelineNamed(pipelineConfig.name()), is(true));
assertThat(goConfigService.pipelineConfigNamed(pipelineConfig.name()), is(pipelineConfig));
// and no trace of badPipe
assertThat(goConfigService.hasPipelineNamed(new CaseInsensitiveString("badPipe")), is(false));
}
Aggregations