Search in sources :

Example 66 with FileConfigOrigin

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

the class MergeEnvironmentConfigTest method shouldReturnTrueWhenOnlyPartIsLocal.

@Test
void shouldReturnTrueWhenOnlyPartIsLocal() {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    environmentConfig = new MergeEnvironmentConfig(uatLocalPart);
    assertThat(environmentConfig.isLocal()).isTrue();
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.jupiter.api.Test)

Example 67 with FileConfigOrigin

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

the class MergeEnvironmentConfigTest method shouldReturnCorrectOriginOfDefinedPipeline.

@Test
void shouldReturnCorrectOriginOfDefinedPipeline() {
    BasicEnvironmentConfig uatLocalPart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatLocalPart.setOrigins(new FileConfigOrigin());
    String localPipeline = "local-pipeline";
    uatLocalPart.addPipeline(new CaseInsensitiveString(localPipeline));
    BasicEnvironmentConfig uatRemotePart = new BasicEnvironmentConfig(new CaseInsensitiveString("UAT"));
    uatRemotePart.setOrigins(new RepoConfigOrigin());
    String remotePipeline = "remote-pipeline";
    uatRemotePart.addPipeline(new CaseInsensitiveString(remotePipeline));
    MergeEnvironmentConfig environmentConfig = new MergeEnvironmentConfig(uatLocalPart, uatRemotePart);
    assertThat(environmentConfig.getOriginForPipeline(new CaseInsensitiveString(localPipeline))).isEqualTo(new FileConfigOrigin());
    assertThat(environmentConfig.getOriginForPipeline(new CaseInsensitiveString(remotePipeline))).isEqualTo(new RepoConfigOrigin());
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) RepoConfigOrigin(com.thoughtworks.go.config.remote.RepoConfigOrigin) Test(org.junit.jupiter.api.Test)

Example 68 with FileConfigOrigin

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

the class MagicalGoConfigXmlLoaderTest method shouldSetConfigOriginInEnvironment_AfterLoadingConfigFile.

@Test
void shouldSetConfigOriginInEnvironment_AfterLoadingConfigFile() throws Exception {
    String content = configWithEnvironments("<environments>" + "  <environment name='uat'>" + "  </environment>" + "</environments>", CONFIG_SCHEMA_VERSION);
    EnvironmentsConfig environmentsConfig = xmlLoader.deserializeConfig(content).getEnvironments();
    EnvironmentConfig uat = environmentsConfig.get(0);
    assertThat(uat.getOrigin()).isEqualTo(new FileConfigOrigin());
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) Test(org.junit.jupiter.api.Test)

Example 69 with FileConfigOrigin

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

the class DependencyMaterialConfigTest method shouldValidateTree.

@Test
void shouldValidateTree() {
    DependencyMaterialConfig dependencyMaterialConfig = new DependencyMaterialConfig(new CaseInsensitiveString("upstream_stage"), new CaseInsensitiveString("upstream_pipeline"), new CaseInsensitiveString("stage"));
    PipelineConfig pipeline = new PipelineConfig(new CaseInsensitiveString("p"), new MaterialConfigs());
    pipeline.setOrigin(new FileConfigOrigin());
    dependencyMaterialConfig.validateTree(PipelineConfigSaveValidationContext.forChain(true, "group", config, pipeline));
    assertThat(dependencyMaterialConfig.errors().on(DependencyMaterialConfig.PIPELINE_STAGE_NAME)).isEqualTo("Pipeline with name 'upstream_pipeline' does not exist, it is defined as a dependency for pipeline 'p' (cruise-config.xml)");
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.jupiter.api.Test)

Example 70 with FileConfigOrigin

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

the class MaterialConfigsTest method shouldAllowToDependOnPipelineDefinedInFile_WhenInFile.

@Test
public void shouldAllowToDependOnPipelineDefinedInFile_WhenInFile() throws Exception {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
    PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
    goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
    pipeline1.setOrigin(new FileConfigOrigin());
    pipeline2.setOrigin(new FileConfigOrigin());
    pipeline1.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline1));
    assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(true));
    pipeline2.materialConfigs().validate(ConfigSaveValidationContext.forChain(cruiseConfig, new BasicPipelineConfigs(), pipeline2));
    DependencyMaterialConfig dep = pipeline2.materialConfigs().findDependencyMaterial(new CaseInsensitiveString("pipeline1"));
    assertThat(dep.errors().isEmpty(), is(true));
}
Also used : FileConfigOrigin(com.thoughtworks.go.config.remote.FileConfigOrigin) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) Test(org.junit.jupiter.api.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