use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotAllowPackagesWithInvalidId.
@Test
public void shouldNotAllowPackagesWithInvalidId() throws Exception {
Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name", repositoryConfiguration, new Packages(new PackageDefinition("id with space", "name", packageConfiguration)));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not have allowed two repositories with same id");
} catch (XsdValidationException e) {
assertThat(e.getMessage(), is("Package id is invalid. \"id with space\" should conform to the pattern - [a-zA-Z0-9_\\-]{1}[a-zA-Z0-9_\\-.]*"));
}
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotAllowPackagesWithInvalidName.
@Test
public void shouldNotAllowPackagesWithInvalidName() throws Exception {
Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name", repositoryConfiguration, new Packages(new PackageDefinition("id", "name with space", packageConfiguration)));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not have allowed two repositories with same id");
} catch (GoConfigInvalidException e) {
assertThat(e.getMessage(), is("Invalid Package name 'name with space'. This must be alphanumeric and can contain underscores, hyphens and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldWriteToFileWithValueOfFalseForPackageDefinitionAutoUpdateWhenFalse.
@Test
public void shouldWriteToFileWithValueOfFalseForPackageDefinitionAutoUpdateWhenFalse() throws Exception {
Configuration configuration = new Configuration(getConfigurationProperty("url", false, "http://go"));
Packages packages = new Packages();
PackageDefinition aPackage = new PackageDefinition("package-id", "package-name", configuration);
aPackage.setAutoUpdate(false);
packages.add(aPackage);
PackageRepository repository = createPackageRepository("plugin-id", "version", "id", "name", configuration, packages);
cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
xmlWriter.write(cruiseConfig, output, false);
assertThat(output.toString().contains("autoUpdate=\"false\""), is(true));
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class MagicalGoConfigXmlWriterTest method shouldNotAllowPackagesRepositoryWithInvalidName.
@Test
public void shouldNotAllowPackagesRepositoryWithInvalidName() throws Exception {
Configuration packageConfiguration = new Configuration(getConfigurationProperty("name", false, "go-agent"));
Configuration repositoryConfiguration = new Configuration(getConfigurationProperty("url", false, "http://go"));
PackageRepository packageRepository = createPackageRepository("plugin-id", "version", "id", "name with space", repositoryConfiguration, new Packages(new PackageDefinition("id", "name", packageConfiguration)));
cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));
try {
xmlWriter.write(cruiseConfig, output, false);
fail("should not have allowed two repositories with same id");
} catch (GoConfigInvalidException e) {
assertThat(e.getMessage(), is("Invalid PackageRepository name 'name with space'. This must be alphanumeric and can contain underscores, hyphens and periods (however, it cannot start with a period). The maximum allowed length is 255 characters."));
}
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepositories in project gocd by gocd.
the class PackageDefinitionCreatorTest method setup.
@BeforeEach
public void setup() {
packageDefinitionService = mock(PackageDefinitionService.class);
doNothing().when(packageDefinitionService).performPluginValidationsFor(any(PackageDefinition.class));
cruiseConfig = mock(BasicCruiseConfig.class);
packageRepository = PackageRepositoryMother.create(repoId);
packageDefinition = PackageDefinitionMother.create(pkgId);
packageRepository.addPackage(packageDefinition);
when(cruiseConfig.getPackageRepositories()).thenReturn(new PackageRepositories(packageRepository));
doNothing().when(cruiseConfig).savePackageDefinition(any(PackageDefinition.class));
}
Aggregations