use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.
the class GoConfigRepoConfigDataSourceTest method shouldSetOKHealthState_AtConfigRepoScope_WhenPluginHasParsed.
@Test
public void shouldSetOKHealthState_AtConfigRepoScope_WhenPluginHasParsed() {
ScmMaterialConfig material = git("http://my.git");
ConfigRepoConfig configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
configWatchList.onConfigChange(cruiseConfig);
// set error state to simulate previously failed parse
HealthStateScope scope = HealthStateScope.forPartialConfigRepo(configRepoConfig);
serverHealthService.update(ServerHealthState.error("Parse failed", "Bad config format", HealthStateType.general(scope)));
// verify error health
assertFalse(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(configRepoConfig)).isEmpty());
// now this should fix health
repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
assertTrue(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(configRepoConfig)).isEmpty());
}
use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.
the class GoConfigRepoConfigDataSourceTest method shouldAssignConfigOriginInPipelines.
@Test
public void shouldAssignConfigOriginInPipelines() throws Exception {
ScmMaterialConfig material = git("http://my.git");
ConfigRepoConfig configRepo = ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepo));
configWatchList.onConfigChange(cruiseConfig);
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenReturn(PartialConfigMother.withPipeline("pipe1"));
repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
PartialConfig partialConfig = repoConfigDataSource.latestPartialConfigForMaterial(material);
RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(configRepo, "7a8f");
assertNotNull(partialConfig.getOrigin());
assertThat(partialConfig.getOrigin(), is(repoConfigOrigin));
PipelineConfig pipe = partialConfig.getGroups().get(0).get(0);
assertThat(pipe.getOrigin(), is(repoConfigOrigin));
}
use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.
the class GoConfigRepoConfigDataSourceTest method shouldThrowWhenGettingLatestPartialConfig_WhenInitializingPluginHasFailed.
@Test
public void shouldThrowWhenGettingLatestPartialConfig_WhenInitializingPluginHasFailed() throws Exception {
when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenThrow(new RuntimeException("Failed to initialize plugin"));
ScmMaterialConfig material = git("http://my.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id")));
configWatchList.onConfigChange(cruiseConfig);
repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
assertTrue(repoConfigDataSource.latestParseHasFailedForMaterial(material));
try {
repoConfigDataSource.latestPartialConfigForMaterial(material);
} catch (RuntimeException ex) {
assertThat(ex.getMessage(), is("Failed to initialize plugin"));
}
}
use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.
the class GoConfigRepoConfigDataSourceTest method shouldAssignConfigOrigin.
@Test
public void shouldAssignConfigOrigin() throws Exception {
ScmMaterialConfig material = git("http://my.git");
ConfigRepoConfig configRepo = ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepo));
configWatchList.onConfigChange(cruiseConfig);
repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
PartialConfig partialConfig = repoConfigDataSource.latestPartialConfigForMaterial(material);
assertNotNull(partialConfig.getOrigin());
RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(configRepo, "7a8f");
assertThat(partialConfig.getOrigin(), is(repoConfigOrigin));
}
use of com.thoughtworks.go.config.remote.ConfigReposConfig in project gocd by gocd.
the class GoConfigRepoConfigDataSourceTest method shouldThrowWhenGettingLatestPartialConfig_WhenPluginHasFailed.
@Test
public void shouldThrowWhenGettingLatestPartialConfig_WhenPluginHasFailed() throws Exception {
// use broken plugin now
when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenReturn(new BrokenConfigPlugin());
ScmMaterialConfig material = git("http://my.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(ConfigRepoConfig.createConfigRepoConfig(material, "myplugin", "id")));
configWatchList.onConfigChange(cruiseConfig);
repoConfigDataSource.onCheckoutComplete(material, folder, getModificationFor("7a8f"));
assertTrue(repoConfigDataSource.latestParseHasFailedForMaterial(material));
try {
repoConfigDataSource.latestPartialConfigForMaterial(material);
} catch (BrokenConfigPluginException ex) {
return;
}
fail("should have thrown BrokenConfigPluginException");
}
Aggregations