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()));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class ConfigRepoServiceIntegrationTest method shouldUpdateSpecifiedConfigRepository.
@Test
public void shouldUpdateSpecifiedConfigRepository() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
configHelper.enableSecurity();
goConfigDao.updateConfig(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
cruiseConfig.getConfigRepos().add(configRepo);
return cruiseConfig;
}
});
String newRepoId = "repo-2";
ConfigRepoConfig toUpdateWith = new ConfigRepoConfig(new GitMaterialConfig("http://bar.git", "master"), "yaml-plugin", newRepoId);
assertThat(configRepoService.getConfigRepos().size(), is(1));
assertThat(configRepoService.getConfigRepo(repoId), is(configRepo));
configRepoService.updateConfigRepo(repoId, toUpdateWith, entityHashingService.md5ForEntity(configRepo), user, result);
assertThat(result.toString(), result.isSuccessful(), Is.is(true));
assertThat(configRepoService.getConfigRepos().size(), is(1));
assertThat(configRepoService.getConfigRepo(newRepoId), is(toUpdateWith));
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class ConfigRepoServiceIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
user = new Username(new CaseInsensitiveString("current"));
UpdateConfigCommand command = goConfigService.modifyAdminPrivilegesCommand(asList(user.getUsername().toString()), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.add));
goConfigService.updateConfig(command);
this.repoId = "repo-1";
this.pluginId = "json-config-repo-plugin";
MaterialConfig repoMaterial = new GitMaterialConfig("https://foo.git", "master");
this.configRepo = new ConfigRepoConfig(repoMaterial, pluginId, repoId);
configHelper.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
configHelper.onSetUp();
goConfigService.forceNotifyListeners();
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class ConfigSaveDeadlockDetectionIntegrationTest method configRepoDeleteThread.
private Thread configRepoDeleteThread(final ConfigRepoConfig configRepoToBeDeleted, final int counter) throws InterruptedException {
return createThread(new Runnable() {
@Override
public void run() {
goConfigService.updateConfig(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
ConfigRepoConfig repoConfig = cruiseConfig.getConfigRepos().stream().filter(new Predicate<ConfigRepoConfig>() {
@Override
public boolean test(ConfigRepoConfig item) {
return configRepoToBeDeleted.getMaterialConfig().equals(item.getMaterialConfig());
}
}).findFirst().orElse(null);
cruiseConfig.getConfigRepos().remove(repoConfig);
return cruiseConfig;
}
});
}
}, "config-repo-delete-thread" + counter);
}
use of com.thoughtworks.go.config.remote.ConfigRepoConfig in project gocd by gocd.
the class BuildCauseTest method shouldThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenAutoTrigger.
@Test
public void shouldThrowWhenMaterialAndConfigOriginRevisionDontMatch_WhenAutoTrigger() {
SvnMaterial material = MaterialsMother.svnMaterial();
MaterialConfig materialConfig = material.config();
MaterialRevisions first = new MaterialRevisions(new MaterialRevision(material, oneModifiedFile("revision1")));
BuildCause buildCause = BuildCause.createWithModifications(first, "");
buildCause.setMaterialRevisions(first);
PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfigWithStages("pipe1", "build");
pipelineConfig.materialConfigs().clear();
pipelineConfig.materialConfigs().add(materialConfig);
pipelineConfig.setOrigin(new RepoConfigOrigin(new ConfigRepoConfig(materialConfig, "plug"), "revision2"));
try {
buildCause.assertPipelineConfigAndMaterialRevisionMatch(pipelineConfig);
} catch (BuildCauseOutOfDateException ex) {
// good
return;
}
fail("should have thrown");
}
Aggregations