Search in sources :

Example 6 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class GoPartialConfigTest method setUp.

@Before
public void setUp() {
    serverHealthService = mock(ServerHealthService.class);
    configPluginService = mock(GoConfigPluginService.class);
    plugin = mock(PartialConfigProvider.class);
    when(configPluginService.partialConfigProviderFor(any(ConfigRepoConfig.class))).thenReturn(plugin);
    cruiseConfig = new BasicCruiseConfig();
    configRepoConfig = new ConfigRepoConfig(new GitMaterialConfig("url"), "plugin");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
    cachedGoConfig = mock(CachedGoConfig.class);
    when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
    configWatchList = new GoConfigWatchList(cachedGoConfig, mock(GoConfigService.class));
    repoConfigDataSource = new GoRepoConfigDataSource(configWatchList, configPluginService, serverHealthService);
    cachedGoPartials = new CachedGoPartials(serverHealthService);
    goConfigService = mock(GoConfigService.class);
    serverHealthService = mock(ServerHealthService.class);
    partialConfig = new GoPartialConfig(repoConfigDataSource, configWatchList, goConfigService, cachedGoPartials, serverHealthService);
}
Also used : ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) Before(org.junit.Before)

Example 7 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.

the class GoPartialConfigTest method setOneConfigRepo.

private ScmMaterialConfig setOneConfigRepo() {
    ScmMaterialConfig material = new GitMaterialConfig("http://my.git");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(material, "myplugin")));
    configWatchList.onConfigChange(cruiseConfig);
    return material;
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig)

Example 8 with GitMaterialConfig

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

Example 9 with GitMaterialConfig

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

Example 10 with GitMaterialConfig

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

Aggregations

GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)138 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)21 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)20 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)14 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)11 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 Material (com.thoughtworks.go.domain.materials.Material)8 SCMs (com.thoughtworks.go.domain.scm.SCMs)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7