Search in sources :

Example 21 with ScmMaterialConfig

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");
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 22 with ScmMaterialConfig

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));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) File(java.io.File) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 23 with ScmMaterialConfig

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));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 24 with ScmMaterialConfig

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));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Example 25 with ScmMaterialConfig

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));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) ArrayList(java.util.ArrayList) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) Test(org.junit.Test)

Aggregations

ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)25 Test (org.junit.Test)20 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)16 File (java.io.File)7 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)5 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)4 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)2 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)1 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)1 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)1 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)1 MergePipelineConfigs (com.thoughtworks.go.config.merge.MergePipelineConfigs)1 ArrayList (java.util.ArrayList)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1