Search in sources :

Example 1 with GitMaterialConfig

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

the class ConfigReposConfigTest method shouldErrorWhenDuplicateIdsExist.

@Test
public void shouldErrorWhenDuplicateIdsExist() {
    ConfigRepoConfig repo1 = new ConfigRepoConfig(new GitMaterialConfig("http://git1"), "myplugin", "id");
    ConfigRepoConfig repo2 = new ConfigRepoConfig(new GitMaterialConfig("http://git2"), "myotherplugin", "id");
    repos.add(repo1);
    repos.add(repo2);
    repos.validate(null);
    assertThat(repo2.errors().on("unique_id"), is("You have defined multiple configuration repositories with the same id - id"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.Test)

Example 2 with GitMaterialConfig

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

the class ConfigReposConfigTest method shouldErrorWhenDuplicateReposExist.

@Test
public void shouldErrorWhenDuplicateReposExist() {
    ConfigRepoConfig repo1 = new ConfigRepoConfig(new GitMaterialConfig("http://git"), "myplugin");
    ConfigRepoConfig repo2 = new ConfigRepoConfig(new GitMaterialConfig("http://git"), "myotherplugin");
    repos.add(repo1);
    repos.add(repo2);
    // this is a limitation, we identify config repos by material fingerprint later
    // so there cannot be one repository parsed by 2 plugins.
    // This also does not seem like practical use case anyway
    repos.validate(null);
    assertThat(repo1.errors().on(ConfigRepoConfig.UNIQUE_REPO), is("You have defined multiple configuration repositories with the same repository - http://git"));
    assertThat(repo2.errors().on(ConfigRepoConfig.UNIQUE_REPO), is("You have defined multiple configuration repositories with the same repository - http://git"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.Test)

Example 3 with GitMaterialConfig

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

the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemoteAgents.

@Test
public void shouldNotAllowRemovingRemoteAgents() throws Exception {
    String agentUUID = "remote-agent-to-remove";
    BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
    local.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
    remote.addAgent(agentUUID);
    ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
    remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
    MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
    agentsToRemove.add(agentUUID);
    PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
    assertFalse(cruiseConfig.getEnvironments().find(environmentName).containsPipeline(new CaseInsensitiveString(agentUUID)));
    command.update(cruiseConfig);
    // preprocess
    cruiseConfig.getEnvironments().replace(cruiseConfig.getEnvironments().find(environmentName), mergedConfig);
    boolean isValid = command.isValid(cruiseConfig);
    assertFalse(isValid);
    HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
    String message = "Agent with uuid 'remote-agent-to-remove' cannot be removed from environment 'Dev' as the association has been defined remotely in [foo/bar.git at latest]";
    expectedResult.unprocessableEntity(actionFailed.addParam(message));
    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) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) MergeEnvironmentConfig(com.thoughtworks.go.config.merge.MergeEnvironmentConfig) Test(org.junit.Test)

Example 4 with GitMaterialConfig

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

the class UpdateConfigRepoCommandTest method shouldValidateDuplicateRepoId.

@Test
public void shouldValidateDuplicateRepoId() throws Exception {
    newConfigRepo.setMaterialConfig(new GitMaterialConfig("foobar.git", "master"));
    cruiseConfig.getConfigRepos().add(newConfigRepo);
    UpdateConfigRepoCommand command = new UpdateConfigRepoCommand(securityService, entityHashingService, oldConfigRepoId, newConfigRepo, actionFailed, md5, currentUser, result);
    command.update(cruiseConfig);
    assertFalse(command.isValid(cruiseConfig));
    assertThat(newConfigRepo.errors().size(), is(2));
    assertThat(newConfigRepo.errors().firstError(), is("You have defined multiple configuration repositories with the same id - new-repo"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.Test)

Example 5 with GitMaterialConfig

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

the class GoPartialConfigTest method shouldRemovePartialWhenNoLongerInWatchList.

@Test
public void shouldRemovePartialWhenNoLongerInWatchList() 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));
    // we change current configuration
    ScmMaterialConfig othermaterial = new GitMaterialConfig("http://myother.git");
    cruiseConfig.setConfigRepos(new ConfigReposConfig(new ConfigRepoConfig(othermaterial, "myplugin")));
    configWatchList.onConfigChange(cruiseConfig);
    assertThat(partialConfig.lastPartials().size(), is(0));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) PartialConfig(com.thoughtworks.go.config.remote.PartialConfig) File(java.io.File) 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