Search in sources :

Example 16 with ScmMaterialConfig

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

Example 17 with ScmMaterialConfig

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

Example 18 with ScmMaterialConfig

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

Example 19 with ScmMaterialConfig

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

Example 20 with ScmMaterialConfig

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));
}
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)

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