use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.
the class BasicCruiseConfigTest method shouldListAllPipelinesAssociatedWithThePackageRepository.
@Test
public void shouldListAllPipelinesAssociatedWithThePackageRepository() {
GitMaterialConfig git = git("http://example.com");
PackageMaterialConfig packageMaterialConfig = packageMaterialConfig();
PipelineConfig p1 = pipelineConfig("p1", new MaterialConfigs(git, packageMaterialConfig));
PipelineConfig p2 = pipelineConfig("p2", new MaterialConfigs(git));
PipelineConfig p3 = pipelineConfig("p3", new MaterialConfigs(packageMaterialConfig));
PipelineConfigs group1 = createGroup("group1", p1, p2);
PipelineConfigs group2 = createGroup("group2", p3);
CruiseConfig config = createCruiseConfig();
config.setGroup(new PipelineGroups(group1, group2));
List<PipelineConfig> pipelineConfigs = config.pipelinesAssociatedWithPackageRepository(packageMaterialConfig.getPackageDefinition().getRepository());
assertThat(pipelineConfigs.size(), is(2));
assertThat(pipelineConfigs.get(0).getName(), is(new CaseInsensitiveString("p1")));
assertThat(pipelineConfigs.get(1).getName(), is(new CaseInsensitiveString("p3")));
}
use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.
the class PipelineConfigValidationTest method isValid_shouldAllowColonForLabelTemplate.
@Test
void isValid_shouldAllowColonForLabelTemplate() {
pipeline.addMaterialConfig(new PackageMaterialConfig(new CaseInsensitiveString("repo:name"), "package-id", PackageDefinitionMother.create("package-id")));
assertLabelTemplate("pipeline-${COUNT}-${repo:name}", emptyCheck);
}
use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.
the class ConfigConverterTest method shouldConvertPackageMaterialConfig.
@Test
void shouldConvertPackageMaterialConfig() {
PackageRepositories repositories = new PackageRepositories();
PackageRepository packageRepository = new PackageRepository();
PackageDefinition definition = new PackageDefinition("package-id", "n", new Configuration());
packageRepository.addPackage(definition);
repositories.add(packageRepository);
BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setPackageRepositories(repositories);
when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(new CaseInsensitiveString("name"), "package-id", definition);
CRPackageMaterial crPackageMaterial = (CRPackageMaterial) configConverter.materialToCRMaterial(packageMaterialConfig);
assertThat(crPackageMaterial.getName()).isEqualTo("name");
assertThat(crPackageMaterial.getPackageId()).isEqualTo("package-id");
}
use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.
the class UpdatePackageRepositoryCommandTest method shouldUpdatePackageRepositoryConfigurationOnAssociatedPipelines.
@Test
public void shouldUpdatePackageRepositoryConfigurationOnAssociatedPipelines() {
GitMaterialConfig git = git("http://example.com");
PackageMaterialConfig packageMaterial = packageMaterialConfig();
PipelineConfig p1 = pipelineConfig("p1", new MaterialConfigs(git, packageMaterial));
PipelineConfig p2 = pipelineConfig("p2", new MaterialConfigs(git));
PipelineConfig p3 = pipelineConfig("p3", new MaterialConfigs(packageMaterial));
PipelineConfigs group1 = createGroup("group1", p1, p2);
PipelineConfigs group2 = createGroup("group2", p3);
cruiseConfig.setGroup(new PipelineGroups(group1, group2));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageMaterial.getPackageDefinition().getRepository()));
Configuration updatedConfiguration = new Configuration(create("new_key1", "new_value1"), create("new_key2", "new_value2"));
PackageRepository updatePackageRepo = PackageRepositoryMother.create(packageMaterial.getPackageDefinition().getRepository().getId(), "repo", "id", "version", updatedConfiguration);
UpdatePackageRepositoryCommand command = new UpdatePackageRepositoryCommand(goConfigService, packageRepositoryService, updatePackageRepo, currentUser, "digest", entityHashingService, result, repoId);
command.update(cruiseConfig);
PackageMaterialConfig materialConfig1 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p1")).packageMaterialConfigs().get(0);
assertThat(materialConfig1.getPackageDefinition().getRepository(), is(updatePackageRepo));
PackageMaterialConfig materialConfig2 = cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("p3")).packageMaterialConfigs().get(0);
assertThat(materialConfig2.getPackageDefinition().getRepository(), is(updatePackageRepo));
}
use of com.thoughtworks.go.config.materials.PackageMaterialConfig in project gocd by gocd.
the class PipelineConfigServiceIntegrationTest method shouldMapErrorsBackToPackageMaterials.
@Test
public void shouldMapErrorsBackToPackageMaterials() throws Exception {
GoConfigHolder goConfigHolder = goConfigDao.loadConfigHolder();
String packageid = "packageid";
saveScmMaterialToConfig(packageid);
PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(packageid);
String digest = entityHashingService.hashForEntity(pipelineConfig, groupName);
pipelineConfig.materialConfigs().add(packageMaterialConfig);
pipelineConfigService.updatePipelineConfig(user, pipelineConfig, groupName, digest, result);
assertThat(result.toString(), result.isSuccessful(), is(false));
assertThat(result.message(), is(String.format("Validations failed for pipeline '%s'. Error(s): [Validation failed.]. Please correct and resubmit.", pipelineConfig.name())));
assertThat(packageMaterialConfig.errors().on(PackageMaterialConfig.PACKAGE_ID), is("Could not find repository for given package id:[packageid]"));
assertThat(configRepository.getCurrentRevCommit().name(), is(headCommitBeforeUpdate));
assertThat(goConfigDao.loadConfigHolder().configForEdit, is(goConfigHolder.configForEdit));
assertThat(goConfigDao.loadConfigHolder().config, is(goConfigHolder.config));
}
Aggregations