use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldSetOKHealthState_AtConfigRepoScope_WhenPluginHasParsed.
@Test
public void shouldSetOKHealthState_AtConfigRepoScope_WhenPluginHasParsed() {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
ConfigRepoConfig configRepoConfig = new ConfigRepoConfig(material, "myplugin");
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, "7a8f");
assertTrue(serverHealthService.filterByScope(HealthStateScope.forPartialConfigRepo(configRepoConfig)).isEmpty());
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldReturnLatestPartialConfigForMaterial_WhenPartialExists.
@Test
public void shouldReturnLatestPartialConfigForMaterial_WhenPartialExists() 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));
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest 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 = new GitMaterialConfig("http://my.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(material, "myplugin")));
configWatchList.onConfigChange(cruiseConfig);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
assertTrue(repoConfigDataSource.latestParseHasFailedForMaterial(material));
try {
repoConfigDataSource.latestPartialConfigForMaterial(material);
} catch (BrokenConfigPluginException ex) {
return;
}
fail("should have thrown BrokenConfigPluginException");
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldCallPluginLoadOnCheckout_WhenMaterialInWatchList.
@Test
public void shouldCallPluginLoadOnCheckout_WhenMaterialInWatchList() {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(material, "myplugin")));
configWatchList.onConfigChange(cruiseConfig);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
verify(plugin, times(1)).load(eq(folder), any(PartialConfigLoadContext.class));
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldAssignConfigOrigin.
@Test
public void shouldAssignConfigOrigin() throws Exception {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
ConfigRepoConfig configRepo = new ConfigRepoConfig(material, "myplugin");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepo));
configWatchList.onConfigChange(cruiseConfig);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
PartialConfig partialConfig = repoConfigDataSource.latestPartialConfigForMaterial(material);
assertNotNull(partialConfig.getOrigin());
RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(configRepo, "7a8f");
assertThat(partialConfig.getOrigin(), Is.<ConfigOrigin>is(repoConfigOrigin));
}
Aggregations