Search in sources :

Example 81 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig 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 82 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig 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 83 with GitMaterialConfig

use of com.thoughtworks.go.config.materials.git.GitMaterialConfig 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 84 with GitMaterialConfig

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

the class CreateConfigRepoCommandTest method shouldValidateDuplicateRepoId.

@Test
public void shouldValidateDuplicateRepoId() throws Exception {
    ConfigRepoConfig anotherconfigRepo = new ConfigRepoConfig(new GitMaterialConfig("https://foos.git", "master"), "json-plugin", repoId);
    cruiseConfig.getConfigRepos().add(anotherconfigRepo);
    String error = "You have defined multiple configuration repositories with the same id - repo-1";
    HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
    expectedResult.unprocessableEntity(actionFailed.addParam(Arrays.asList(error)));
    CreateConfigRepoCommand command = new CreateConfigRepoCommand(securityService, configRepo, actionFailed, currentUser, result);
    command.update(cruiseConfig);
    assertFalse(command.isValid(cruiseConfig));
    assertThat(configRepo.errors().firstError(), is(error));
    assertThat(result, is(expectedResult));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 85 with GitMaterialConfig

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

the class CreateConfigRepoCommandTest method shouldValidateDuplicateMaterial.

@Test
public void shouldValidateDuplicateMaterial() throws Exception {
    ConfigRepoConfig anotherConfigRepo = new ConfigRepoConfig(new GitMaterialConfig("https://foo.git", "master"), "json-plugin", "anotherid");
    cruiseConfig.getConfigRepos().add(anotherConfigRepo);
    String error = "You have defined multiple configuration repositories with the same repository - https://foo.git";
    HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
    expectedResult.unprocessableEntity(actionFailed.addParam(Arrays.asList(error)));
    CreateConfigRepoCommand command = new CreateConfigRepoCommand(securityService, configRepo, actionFailed, currentUser, result);
    command.update(cruiseConfig);
    assertFalse(command.isValid(cruiseConfig));
    assertThat(configRepo.errors().size(), is(1));
    assertThat(configRepo.errors().firstError(), is(error));
    assertThat(result, is(expectedResult));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) 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