use of com.thoughtworks.go.config.materials.ScmMaterialConfig in project gocd by gocd.
the class GoRepoConfigDataSourceTest method shouldProvideConfigurationInParseContextWhenCallingPlugin.
@Test
public void shouldProvideConfigurationInParseContextWhenCallingPlugin() throws Exception {
ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
ConfigRepoConfig repoConfig = new ConfigRepoConfig(material, "myplugin");
cruiseConfig.setConfigRepos(new ConfigReposConfig(repoConfig));
configWatchList.onConfigChange(cruiseConfig);
repoConfig.getConfiguration().addNewConfigurationWithValue("key", "value", false);
plugin = new AssertingConfigPlugin(repoConfig.getConfiguration());
when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenReturn(plugin);
repoConfigDataSource.onCheckoutComplete(material, folder, "7a8f");
}
use of com.thoughtworks.go.config.materials.ScmMaterialConfig 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.ScmMaterialConfig 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.ScmMaterialConfig 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.ScmMaterialConfig in project gocd by gocd.
the class FanInGraphTest method shouldConstructAFaninGraph.
@Test
public void shouldConstructAFaninGraph() throws Exception {
GitMaterialConfig git = new GitMaterialConfig("giturl", "dest");
HgMaterialConfig hg = new HgMaterialConfig("hgurl", "dest");
PipelineConfig p1 = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(git));
DependencyMaterialConfig p1Dep = new DependencyMaterialConfig(p1.name(), p1.get(0).name());
PipelineConfig p2 = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(p1Dep));
PipelineConfig p3 = PipelineConfigMother.pipelineConfig("p3", new MaterialConfigs(p1Dep, hg));
DependencyMaterialConfig p2Dep = new DependencyMaterialConfig(p2.name(), p2.get(0).name());
DependencyMaterialConfig p3Dep = new DependencyMaterialConfig(p3.name(), p3.get(0).name());
PipelineConfig p4 = PipelineConfigMother.pipelineConfig("p4", new MaterialConfigs(p2Dep, p3Dep));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1, p2, p3, p4));
FanInGraph faninGraph = new FanInGraph(cruiseConfig, p4.name(), null, null, null, null);
List<ScmMaterialConfig> scmMaterialNodes = faninGraph.getScmMaterials();
List<String> scmMaterialUrls = new ArrayList<>();
for (ScmMaterialConfig scmMaterialNode : scmMaterialNodes) {
scmMaterialUrls.add(scmMaterialNode.getUrl().toString());
}
assertThat(scmMaterialUrls.contains("giturl"), is(true));
assertThat(scmMaterialUrls.contains("hgurl"), is(true));
}
Aggregations