Search in sources :

Example 21 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class PipelineScheduleQueueIntegrationTest method shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision.

@Test
public void shouldReturnNullWhenPipelineConfigOriginDoesNotMatchBuildCauseRevision() {
    PipelineConfig pipelineConfig = fixture.pipelineConfig();
    BuildCause cause = modifySomeFilesAndTriggerAs(pipelineConfig, "cruise-developer");
    MaterialConfig materialConfig = pipelineConfig.materialConfigs().first();
    cause.getMaterialRevisions().findRevisionFor(materialConfig);
    pipelineConfig.setOrigins(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig, "123"), "plug"));
    saveRev(cause);
    queue.schedule(fixture.pipelineName, cause);
    Pipeline pipeline = queue.createPipeline(cause, pipelineConfig, new DefaultSchedulingContext(cause.getApprover(), new Agents()), "md5-test", new TimeProvider());
    assertThat(pipeline, is(nullValue()));
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) BuildCause(com.thoughtworks.go.domain.buildcause.BuildCause) Test(org.junit.Test)

Example 22 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig 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) ConfigRepoConfigTest(com.thoughtworks.go.config.remote.ConfigRepoConfigTest)

Example 23 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemoteEnvironmentVariables.

@Test
public void shouldNotAllowRemovingRemoteEnvironmentVariables() throws Exception {
    String variableName = "remote-env-var-to-remove";
    BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
    local.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
    remote.addEnvironmentVariable(variableName, "bar");
    ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
    remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
    MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
    envVarsToRemove.add(variableName);
    PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
    assertFalse(cruiseConfig.getEnvironments().find(environmentName).getVariables().hasVariable(variableName));
    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 = "Environment variable with name 'remote-env-var-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) ConfigRepoConfigTest(com.thoughtworks.go.config.remote.ConfigRepoConfigTest)

Example 24 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class PatchEnvironmentCommandTest method shouldNotAllowRemovingRemotePipeline.

@Test
public void shouldNotAllowRemovingRemotePipeline() throws Exception {
    CaseInsensitiveString pipelineName = new CaseInsensitiveString("remote-pipeline-to-remove");
    BasicEnvironmentConfig local = new BasicEnvironmentConfig(environmentName);
    local.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig remote = new BasicEnvironmentConfig(environmentName);
    remote.addPipeline(pipelineName);
    ConfigRepoConfig configRepo = new ConfigRepoConfig(new GitMaterialConfig("foo/bar.git", "master"), "myPlugin");
    remote.setOrigins(new RepoConfigOrigin(configRepo, "latest"));
    MergeEnvironmentConfig mergedConfig = new MergeEnvironmentConfig(local, remote);
    pipelinesToRemove.add(pipelineName.toString());
    PatchEnvironmentCommand command = new PatchEnvironmentCommand(goConfigService, environmentConfig, pipelinesToAdd, pipelinesToRemove, agentsToAdd, agentsToRemove, envVarsToAdd, envVarsToRemove, currentUser, actionFailed, result);
    assertFalse(cruiseConfig.getEnvironments().find(environmentName).containsPipeline(new CaseInsensitiveString(pipelineName.toString())));
    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 = "Pipeline 'remote-pipeline-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) ConfigRepoConfigTest(com.thoughtworks.go.config.remote.ConfigRepoConfigTest)

Example 25 with ConfigRepoConfig

use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.

the class GoConfigWatchListTest method shouldReturnConfigRepoForMaterial.

@Test
public void shouldReturnConfigRepoForMaterial() {
    GitMaterialConfig gitrepo = new GitMaterialConfig("http://configrepo.git");
    ConfigRepoConfig repoConfig = new ConfigRepoConfig(gitrepo, "myplugin");
    when(cruiseConfig.getConfigRepos()).thenReturn(new ConfigReposConfig(repoConfig));
    watchList = new GoConfigWatchList(cachedGoConfig);
    assertThat(watchList.getConfigRepoForMaterial(gitrepo), is(repoConfig));
}
Also used : ConfigReposConfig(com.thoughtworks.go.config.remote.ConfigReposConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) ConfigRepoConfig(com.thoughtworks.go.config.remote.ConfigRepoConfig) Test(org.junit.Test)

Aggregations

ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)54 Test (org.junit.Test)34 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)32 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)27 PartialConfig (com.thoughtworks.go.config.remote.PartialConfig)10 ConfigReposConfig (com.thoughtworks.go.config.remote.ConfigReposConfig)8 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)8 Before (org.junit.Before)8 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)6 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)6 File (java.io.File)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 AbstractMaterialConfig (com.thoughtworks.go.config.materials.AbstractMaterialConfig)4 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)4 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)4 FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)4 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)3