Search in sources :

Example 1 with FileConfigOrigin

use of com.thoughtworks.go.config.remote.FileConfigOrigin 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 2 with FileConfigOrigin

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

the class BasicPipelineConfigsTest method shouldReturnSelfForGetLocalPartsWhenOriginIsFile.

@Test
public void shouldReturnSelfForGetLocalPartsWhenOriginIsFile() {
    PipelineConfigs pipelineConfigs = createEmpty();
    pipelineConfigs.setOrigins(new FileConfigOrigin());
    assertThat(pipelineConfigs.getLocal().size(), is(0));
    assertSame(pipelineConfigs, pipelineConfigs.getLocal());
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) Test(org.junit.Test)

Example 3 with FileConfigOrigin

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

the class PipelineConfigTest method shouldReturnFalseIfOneOfPipelineMaterialsIsTheSameAsConfigOrigin_WhenOriginIsFile.

@Test
public void shouldReturnFalseIfOneOfPipelineMaterialsIsTheSameAsConfigOrigin_WhenOriginIsFile() {
    PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "build");
    pipelineConfig.setOrigin(new FileConfigOrigin());
    assertThat(pipelineConfig.isConfigOriginSameAsOneOfMaterials(), is(false));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.Test)

Example 4 with FileConfigOrigin

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

the class EnvironmentsConfigTest method shouldGetLocalPartsWhenOriginIsMixed.

@Test
public void shouldGetLocalPartsWhenOriginIsMixed() {
    env.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig prodLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("PROD"));
    prodLocalPart.addAgent("1235");
    prodLocalPart.setOrigins(new FileConfigOrigin());
    BasicEnvironmentConfig prodRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("PROD"));
    prodRemotePart.setOrigins(new RepoConfigOrigin());
    MergeEnvironmentConfig pairEnvironmentConfig = new MergeEnvironmentConfig(prodLocalPart, prodRemotePart);
    configs.add(pairEnvironmentConfig);
    assertThat(configs.getLocal().size(), is(2));
    assertThat(configs.getLocal(), hasItem(env));
    assertThat(configs.getLocal(), hasItem(prodLocalPart));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) BasicEnvironmentConfig(com.thoughtworks.go.config.BasicEnvironmentConfig) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) MergeEnvironmentConfig(com.thoughtworks.go.config.merge.MergeEnvironmentConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 5 with FileConfigOrigin

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

the class EnvironmentsConfigTest method shouldGetLocalPartsWhenOriginIsFile.

@Test
public void shouldGetLocalPartsWhenOriginIsFile() {
    env.setOrigins(new FileConfigOrigin());
    assertThat(configs.getLocal().size(), is(1));
    assertThat(configs.getLocal().get(0), Is.<EnvironmentConfig>is(env));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.Test)

Aggregations

FileConfigOrigin (com.thoughtworks.go.config.remote.FileConfigOrigin)72 Test (org.junit.jupiter.api.Test)48 RepoConfigOrigin (com.thoughtworks.go.config.remote.RepoConfigOrigin)25 Test (org.junit.Test)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)6 MergeEnvironmentConfig (com.thoughtworks.go.config.merge.MergeEnvironmentConfig)4 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)3 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)3 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)3 ConfigOrigin (com.thoughtworks.go.config.remote.ConfigOrigin)3 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 MergePipelineConfigs (com.thoughtworks.go.config.merge.MergePipelineConfigs)2 UIConfigOrigin (com.thoughtworks.go.config.remote.UIConfigOrigin)2 GoCipher (com.thoughtworks.go.security.GoCipher)2 BasicEnvironmentConfig (com.thoughtworks.go.config.BasicEnvironmentConfig)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 RecordNotFoundException (com.thoughtworks.go.config.exceptions.RecordNotFoundException)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)1