use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldReturnLatestPartialAfterCheckout_AndWatchListNotEmpty.
@Test
public void shouldReturnLatestPartialAfterCheckout_AndWatchListNotEmpty() 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));
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldReturnEmptyList_WhenFirstParsingFailed.
@Test
public void shouldReturnEmptyList_WhenFirstParsingFailed() {
ScmMaterialConfig material = setOneConfigRepo();
PartialConfig part = new PartialConfig();
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenThrow(new RuntimeException("Failed parsing"));
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
assertThat(repoConfigDataSource.latestParseHasFailedForMaterial(material), is(true));
assertThat(partialConfig.lastPartials().size(), is(0));
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoPartialConfigTest method shouldReturnFirstPartial_WhenFirstParsedSucceed_ButSecondFailed.
@Test
public void shouldReturnFirstPartial_WhenFirstParsedSucceed_ButSecondFailed() 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");
when(plugin.load(any(File.class), any(PartialConfigLoadContext.class))).thenThrow(new RuntimeException("Failed parsing"));
repoConfigDataSource.onCheckoutComplete(material, folder, "6354");
assertThat(repoConfigDataSource.latestParseHasFailedForMaterial(material), is(true));
assertThat(partialConfig.lastPartials().size(), is(1));
assertThat(partialConfig.lastPartials().get(0), is(part));
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest 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 = 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 (RuntimeException ex) {
assertThat(ex.getMessage(), is("Failed to initialize plugin"));
}
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldAssignConfigOriginInPipelines.
@Test
public void shouldAssignConfigOriginInPipelines() 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.withPipeline("pipe1"));
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));
PipelineConfig pipe = partialConfig.getGroups().get(0).get(0);
assertThat(pipe.getOrigin(), Is.<ConfigOrigin>is(repoConfigOrigin));
}
Aggregations