use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method getAllUniquePostCommitSchedulableMaterials_shouldReturnMaterialsAndConfigReposWithAutoUpdateFalse.
@Test
public void getAllUniquePostCommitSchedulableMaterials_shouldReturnMaterialsAndConfigReposWithAutoUpdateFalse() {
GitMaterialConfig gitMaterialAuto = MaterialConfigsMother.gitMaterialConfig("url");
PipelineConfig pipelineAuto = pipelineConfig("pipelineAuto", new MaterialConfigs(gitMaterialAuto));
GitMaterialConfig gitMaterialManual = git(new UrlArgument("other-url"), null, null, "master", "dest", false, null, false, null, new CaseInsensitiveString("git"), false);
PipelineConfig pipelineTriggerable = pipelineConfig("pipelineTriggerable", new MaterialConfigs(gitMaterialManual));
PipelineConfigs defaultGroup = createGroup("defaultGroup", pipelineAuto, pipelineTriggerable);
cruiseConfig = new BasicCruiseConfig(defaultGroup);
ConfigReposConfig reposConfig = new ConfigReposConfig();
GitMaterialConfig configRepoMaterialAutoUpdate = git("http://git");
GitMaterialConfig configRepoMaterialManual = tap(git("http://git2"), g -> g.setAutoUpdate(false));
reposConfig.add(ConfigRepoConfig.createConfigRepoConfig(configRepoMaterialAutoUpdate, "myplug", "exclude"));
reposConfig.add(ConfigRepoConfig.createConfigRepoConfig(configRepoMaterialManual, "myplug", "include"));
cruiseConfig.setConfigRepos(reposConfig);
Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
assertThat(materials.size(), is(2));
assertThat(materials, hasItem(gitMaterialManual));
assertThat(materials, hasItem(configRepoMaterialManual));
assertThat(materials, not(hasItem(configRepoMaterialAutoUpdate)));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method getAllUniquePostCommitSchedulableMaterials_shouldReturnMaterialsWithAutoUpdateFalse.
@Test
public void getAllUniquePostCommitSchedulableMaterials_shouldReturnMaterialsWithAutoUpdateFalse() {
GitMaterialConfig gitAutoMaterial = MaterialConfigsMother.gitMaterialConfig("url");
PipelineConfig pipelineAuto = pipelineConfig("pipelineAuto", new MaterialConfigs(gitAutoMaterial));
GitMaterialConfig gitNonAutoMaterial = git(new UrlArgument("other-url"), null, null, "master", "dest", false, null, false, null, new CaseInsensitiveString("git"), false);
PipelineConfig pipelineTriggerable = pipelineConfig("pipelineTriggerable", new MaterialConfigs(gitNonAutoMaterial));
PipelineConfigs defaultGroup = createGroup("defaultGroup", pipelineAuto, pipelineTriggerable);
cruiseConfig.getGroups().add(defaultGroup);
Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
assertThat(materials.size(), is(1));
assertThat(materials, hasItem(gitNonAutoMaterial));
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class ConfigRepoConfigTest method validateTree_configRepoShouldBeInvalidIfMaterialConfigHasErrors.
@Test
public void validateTree_configRepoShouldBeInvalidIfMaterialConfigHasErrors() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
// should be invalid since URL is not set
MaterialConfig materialConfig = new GitMaterialConfig();
ConfigRepoConfig configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(materialConfig, "plug", "id");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
ConfigSaveValidationContext validationContext = ConfigSaveValidationContext.forChain(cruiseConfig);
configRepoConfig.validateTree(validationContext);
assertThat(configRepoConfig.errors().isEmpty()).isTrue();
assertThat(configRepoConfig.getRepo().errors().isEmpty()).isFalse();
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class ConfigRepoConfigTest method hasMaterialWithFingerprint_shouldReturnTrueWhenFingerprintEquals.
@Test
public void hasMaterialWithFingerprint_shouldReturnTrueWhenFingerprintEquals() {
MaterialConfig configRepo = git("url", "branch");
GitMaterialConfig someRepo = git("url", "branch");
someRepo.setFolder("someFolder");
ConfigRepoConfig config = ConfigRepoConfig.createConfigRepoConfig(configRepo, "myplugin", "id");
assertThat(config.hasMaterialWithFingerprint(someRepo.getFingerprint())).isTrue();
}
use of com.thoughtworks.go.config.materials.git.GitMaterialConfig in project gocd by gocd.
the class ConfigRepoConfigTest method validate_shouldValidateTheMaterialConfig.
@Test
public void validate_shouldValidateTheMaterialConfig() {
CruiseConfig cruiseConfig = new BasicCruiseConfig();
GitMaterialConfig materialConfig = git(null, "master");
ConfigRepoConfig configRepoConfig = ConfigRepoConfig.createConfigRepoConfig(materialConfig, "plug", "id");
cruiseConfig.setConfigRepos(new ConfigReposConfig(configRepoConfig));
ConfigSaveValidationContext validationContext = ConfigSaveValidationContext.forChain(cruiseConfig);
configRepoConfig.validate(validationContext);
assertThat(configRepoConfig.getRepo().errors().on("url")).isEqualTo("URL cannot be blank");
}
Aggregations