use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldNotSaveConfigIfValidationOfLastKnownValidPartialsMergedWithMainConfigFails.
@Test
public void shouldNotSaveConfigIfValidationOfLastKnownValidPartialsMergedWithMainConfigFails() {
final PipelineConfig upstream = PipelineConfigMother.createPipelineConfig(UUID.randomUUID().toString(), "s1", "j1");
configHelper.addPipeline(upstream);
String remotePipeline = "remote_pipeline";
RepoConfigOrigin repoConfigOrigin = new RepoConfigOrigin(this.repoConfig, "1");
PartialConfig partialConfig = PartialConfigMother.pipelineWithDependencyMaterial(remotePipeline, upstream, repoConfigOrigin);
cachedGoPartials.addOrUpdate(this.repoConfig.getMaterialConfig().getFingerprint(), partialConfig);
cachedGoPartials.markAllKnownAsValid();
thrown.expect(RuntimeException.class);
thrown.expectCause(any(GoConfigInvalidException.class));
thrown.expectMessage(String.format("Stage with name 's1' does not exist on pipeline '%s', it is being referred to from pipeline '%s' (%s)", upstream.name(), remotePipeline, repoConfigOrigin.displayName()));
dataSource.writeWithLock(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
PipelineConfig pipelineConfig = cruiseConfig.getPipelineConfigByName(upstream.name());
pipelineConfig.clear();
pipelineConfig.add(new StageConfig(new CaseInsensitiveString("new_stage"), new JobConfigs(new JobConfig("job"))));
return cruiseConfig;
}
}, new GoConfigHolder(configHelper.currentConfig(), configHelper.currentConfig()));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldValidateConfigRepoLastKnownPartialsWithMainConfigAndUpdateConfigToIncludePipelinesFromPartials.
@Test
public void shouldValidateConfigRepoLastKnownPartialsWithMainConfigAndUpdateConfigToIncludePipelinesFromPartials() {
String pipelineFromConfigRepo = "pipeline_from_config_repo";
final String pipelineInMain = "pipeline_in_main";
PartialConfig partialConfig = PartialConfigMother.withPipeline(pipelineFromConfigRepo, new RepoConfigOrigin(repoConfig, "1"));
cachedGoPartials.addOrUpdate(repoConfig.getMaterialConfig().getFingerprint(), partialConfig);
assertThat(cachedGoPartials.lastValidPartials().isEmpty(), is(true));
GoFileConfigDataSource.GoConfigSaveResult result = dataSource.writeWithLock(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
cruiseConfig.addPipeline("default", PipelineConfigMother.createPipelineConfig(pipelineInMain, "stage", "job"));
return cruiseConfig;
}
}, new GoConfigHolder(configHelper.currentConfig(), configHelper.currentConfig()));
assertThat(result.getConfigHolder().config.getAllPipelineNames().contains(new CaseInsensitiveString(pipelineFromConfigRepo)), is(true));
assertThat(result.getConfigHolder().config.getAllPipelineNames().contains(new CaseInsensitiveString(pipelineInMain)), is(true));
assertThat(cachedGoPartials.lastValidPartials().size(), is(1));
PartialConfig actualPartial = cachedGoPartials.lastValidPartials().get(0);
assertThat(actualPartial.getGroups(), is(partialConfig.getGroups()));
assertThat(actualPartial.getEnvironments(), is(partialConfig.getEnvironments()));
assertThat(actualPartial.getOrigin(), is(partialConfig.getOrigin()));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class PipelineConfigTest method shouldReturnFalseWhenConfigRevisionIsNotEqualToQuery.
@Test
public void shouldReturnFalseWhenConfigRevisionIsNotEqualToQuery() {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "build");
MaterialConfig material = pipelineConfig.materialConfigs().first();
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(material, "plugin"), "1233"));
assertThat(pipelineConfig.isConfigOriginFromRevision("32"), is(false));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class PipelineConfigTest method shouldReturnTrueWhenConfigRevisionIsEqualToQuery.
@Test
public void shouldReturnTrueWhenConfigRevisionIsEqualToQuery() {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "build");
MaterialConfig material = pipelineConfig.materialConfigs().first();
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(material, "plugin"), "1233"));
assertThat(pipelineConfig.isConfigOriginFromRevision("1233"), is(true));
}
use of com.thoughtworks.go.config.remote.RepoConfigOrigin in project gocd by gocd.
the class PipelineConfigTest method shouldReturnTrueWhenOneOfPipelineMaterialsIsTheSameAsConfigOriginButDestinationIsDifferent.
@Test
public void shouldReturnTrueWhenOneOfPipelineMaterialsIsTheSameAsConfigOriginButDestinationIsDifferent() {
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("pipeline", "stage", "build");
pipelineConfig.materialConfigs().clear();
GitMaterialConfig pipeMaterialConfig = new GitMaterialConfig("http://git");
pipeMaterialConfig.setFolder("dest1");
pipelineConfig.materialConfigs().add(pipeMaterialConfig);
GitMaterialConfig repoMaterialConfig = new GitMaterialConfig("http://git");
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(repoMaterialConfig, "plugin"), "1233"));
assertThat(pipelineConfig.isConfigOriginSameAsOneOfMaterials(), is(true));
}
Aggregations