use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class ConfigReposConfigTest method shouldErrorWhenDuplicateIdsExist.
@Test
public void shouldErrorWhenDuplicateIdsExist() {
ConfigRepoConfig repo1 = new ConfigRepoConfig(new GitMaterialConfig("http://git1"), "myplugin", "id");
ConfigRepoConfig repo2 = new ConfigRepoConfig(new GitMaterialConfig("http://git2"), "myotherplugin", "id");
repos.add(repo1);
repos.add(repo2);
repos.validate(null);
assertThat(repo2.errors().on("unique_id"), is("You have defined multiple configuration repositories with the same id - id"));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class ConfigReposConfigTest method shouldErrorWhenDuplicateReposExist.
@Test
public void shouldErrorWhenDuplicateReposExist() {
ConfigRepoConfig repo1 = new ConfigRepoConfig(new GitMaterialConfig("http://git"), "myplugin");
ConfigRepoConfig repo2 = new ConfigRepoConfig(new GitMaterialConfig("http://git"), "myotherplugin");
repos.add(repo1);
repos.add(repo2);
// this is a limitation, we identify config repos by material fingerprint later
// so there cannot be one repository parsed by 2 plugins.
// This also does not seem like practical use case anyway
repos.validate(null);
assertThat(repo1.errors().on(ConfigRepoConfig.UNIQUE_REPO), is("You have defined multiple configuration repositories with the same repository - http://git"));
assertThat(repo2.errors().on(ConfigRepoConfig.UNIQUE_REPO), is("You have defined multiple configuration repositories with the same repository - http://git"));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemoteAgents.
@Test
public void shouldNotAllowRemovingRemoteAgents() throws Exception {
String agentUUID = "remote-agent-to-remove";
BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
local.setOrigins(new FileConfigOrigin());
BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
remote.addAgent(agentUUID);
ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
agentsToRemove.add(agentUUID);
PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
assertFalse(cruiseConfig.getEnvironments().find(environmentName).containsPipeline(new CaseInsensitiveString(agentUUID)));
command.update(cruiseConfig);
// preprocess
cruiseConfig.getEnvironments().replace(cruiseConfig.getEnvironments().find(environmentName), mergedConfig);
boolean isValid = command.isValid(cruiseConfig);
assertFalse(isValid);
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
String message = "Agent with uuid 'remote-agent-to-remove' cannot be removed from environment 'Dev' as the association has been defined remotely in [foo/bar.git at latest]";
expectedResult.unprocessableEntity(actionFailed.addParam(message));
assertThat(result, is(expectedResult));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class UpdateConfigRepoCommandTest method shouldValidateDuplicateRepoId.
@Test
public void shouldValidateDuplicateRepoId() throws Exception {
newConfigRepo.setMaterialConfig(new GitMaterialConfig("foobar.git", "master"));
cruiseConfig.getConfigRepos().add(newConfigRepo);
UpdateConfigRepoCommand command = new UpdateConfigRepoCommand(securityService, entityHashingService, oldConfigRepoId, newConfigRepo, actionFailed, md5, currentUser, result);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(newConfigRepo.errors().size(), is(2));
assertThat(newConfigRepo.errors().firstError(), is("You have defined multiple configuration repositories with the same id - new-repo"));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldRemovePartialWhenNoLongerInWatchList.
@Test
public void shouldRemovePartialWhenNoLongerInWatchList() throws Exception {
ScmMaterialConfig material = setOneConfigRepo();
PartialConfig part = new PartialConfig();
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(part);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
assertThat(partialConfig.lastPartials().size(), is(1));
assertThat(partialConfig.lastPartials().get(0), is(part));
// we change current configuration
ScmMaterialConfig othermaterial = new GitMaterialConfig("http://myother.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(othermaterial, "myplugin")));
configWatchList.onConfigChange(cruiseConfig);
assertThat(partialConfig.lastPartials().size(), is(0));
}
Aggregations