use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldAssignConfigOriginInEnvironments.
@Test
public void shouldAssignConfigOriginInEnvironments() throws Exception {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
ConfigRepoConfig configRepo = new ConfigRepoConfig(material, "myplugin");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepo));
configWatchList.onConfigChange(cruiseConfig);
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(PartialConfigMother.withEnvironment("UAT"));
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
PartialConfig partialConfig = repoConfigDataSource.latestPartialConfigForMaterial(material);
RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(configRepo, "7a8f");
assertNotNull(partialConfig.getOrigin());
assertThat(partialConfig.getOrigin(), Is.<ConfigOrigin>is(repoConfigOrigin));
EnvironmentConfig environmentConfig = partialConfig.getEnvironments().get(0);
assertThat(environmentConfig.getOrigin(), Is.<ConfigOrigin>is(repoConfigOrigin));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldProvideParseContextWhenCallingPlugin.
@Test
public void shouldProvideParseContextWhenCallingPlugin() throws Exception {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
ConfigRepoConfig repoConfig = new ConfigRepoConfig(material, "myplugin");
cruiseConfig.setConfigRepos(new ConfigReposConfig(repoConfig));
configWatchList.onConfigChange(cruiseConfig);
when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenReturn(plugin);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
verify(plugin, times(1)).load(eq(folder), notNull(PartialConfigLoadContext.class));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldRemovePartialsWhenRemovedFromWatchList.
@Test
public void shouldRemovePartialsWhenRemovedFromWatchList() throws Exception {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(material, "myplugin")));
configWatchList.onConfigChange(cruiseConfig);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
assertNotNull(repoConfigDataSource.latestPartialConfigForMaterial(material));
// we change current configuration
ScmMaterialConfig othermaterial = new GitMaterialConfig("http://myother.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(othermaterial, "myplugin")));
configWatchList.onConfigChange(cruiseConfig);
assertNull(repoConfigDataSource.latestPartialConfigForMaterial(material));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class CreateConfigRepoCommandTest method shouldValidateDuplicateRepoId.
@Test
public void shouldValidateDuplicateRepoId() throws Exception {
ConfigRepoConfig anotherconfigRepo = new ConfigRepoConfig(new GitMaterialConfig("https://foos.git", "master"), "json-plugin", repoId);
cruiseConfig.getConfigRepos().add(anotherconfigRepo);
String error = "You have defined multiple configuration repositories with the same id - repo-1";
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.unprocessableEntity(actionFailed.addParam(Arrays.asList(error)));
CreateConfigRepoCommand command = new CreateConfigRepoCommand(securityService, configRepo, actionFailed, currentUser, result);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(configRepo.errors().firstError(), is(error));
assertThat(result, is(expectedResult));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class CreateConfigRepoCommandTest method shouldValidateDuplicateMaterial.
@Test
public void shouldValidateDuplicateMaterial() throws Exception {
ConfigRepoConfig anotherConfigRepo = new ConfigRepoConfig(new GitMaterialConfig("https://foo.git", "master"), "json-plugin", "anotherid");
cruiseConfig.getConfigRepos().add(anotherConfigRepo);
String error = "You have defined multiple configuration repositories with the same repository - https://foo.git";
HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
expectedResult.unprocessableEntity(actionFailed.addParam(Arrays.asList(error)));
CreateConfigRepoCommand command = new CreateConfigRepoCommand(securityService, configRepo, actionFailed, currentUser, result);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
assertThat(configRepo.errors().size(), is(1));
assertThat(configRepo.errors().firstError(), is(error));
assertThat(result, is(expectedResult));
}
Aggregations