Search in sources :

Example 91 with GitMaterialConfig

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)));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) Test(org.junit.jupiter.api.Test)

Example 92 with GitMaterialConfig

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));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) ScmMaterialConfig(com.thoughtworks.go.config.materials.ScmMaterialConfig) MergePipelineConfigs(com.thoughtworks.go.config.merge.MergePipelineConfigs) Test(org.junit.jupiter.api.Test)

Example 93 with GitMaterialConfig

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();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.jupiter.api.Test)

Example 94 with GitMaterialConfig

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();
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) Test(org.junit.jupiter.api.Test)

Example 95 with GitMaterialConfig

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");
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Test(org.junit.jupiter.api.Test)

Aggregations

GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)138 Test (org.junit.jupiter.api.Test)73 Test (org.junit.Test)37 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)21 ScmMaterialConfig (com.thoughtworks.go.config.materials.ScmMaterialConfig)21 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)20 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ConfigRepoConfig (com.thoughtworks.go.config.remote.ConfigRepoConfig)17 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)16 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)14 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)11 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)10 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)9 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)8 Material (com.thoughtworks.go.domain.materials.Material)8 SCMs (com.thoughtworks.go.domain.scm.SCMs)8 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)7