Search in sources :

Example 11 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class AutoBuildCauseTest method shouldReturnCorrectRevisionsIfUpstreamIgnoresAllTheModificationsAndFirstOrderMaterialNotChanged.

@Test
public void shouldReturnCorrectRevisionsIfUpstreamIgnoresAllTheModificationsAndFirstOrderMaterialNotChanged() throws Exception {
    PipelineConfigDependencyGraph dependencyGraph = dependencyGraphOfDepthOne(MaterialConfigsMother.hgMaterialConfig(), MaterialConfigsMother.svnMaterialConfig());
    String targetPipeline = dependencyGraph.getCurrent().name().toLower();
    firstHgMaterial(dependencyGraph).setFilter(new Filter(new IgnoredFiles("**/*.xml")));
    MaterialRevisions revisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
    MaterialRevisions firstOrderRevision = createSvnMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
    MaterialRevision dependencyRevision = dependencyMaterialRevision("up1", 1, "label", "first", 1, new Date());
    revisions.addAll(firstOrderRevision);
    revisions.addRevision(dependencyRevision);
    dependencyRevision.markAsNotChanged();
    firstOrderRevision.getMaterialRevision(0).markAsNotChanged();
    revisions.getMaterialRevision(0).markAsChanged();
    MaterialRevisions expectedRevisions = createHgMaterialWithMultipleRevisions(1, oneModifiedFile("2"));
    expectedRevisions.addRevision(dependencyRevision);
    when(goConfigService.upstreamDependencyGraphOf(targetPipeline, cruiseConfig)).thenReturn(dependencyGraph);
    when(pipelineService.getRevisionsBasedOnDependencies(eq(revisions), eq(cruiseConfig), eq(dependencyGraph.getCurrent().name()))).thenReturn(expectedRevisions);
    assertThat(new AutoBuild(goConfigService, pipelineService, targetPipeline, new SystemEnvironment(), materialChecker, serverHealthService).onModifications(revisions, false, null).getMaterialRevisions(), is(expectedRevisions));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) Filter(com.thoughtworks.go.config.materials.Filter) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 12 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class FilterTest method shouldInitializeFromDisplayString.

@Test
public void shouldInitializeFromDisplayString() {
    assertThat(Filter.fromDisplayString("/foo/**.*,/another/**.*,bar"), is(new Filter(new IgnoredFiles("/foo/**.*"), new IgnoredFiles("/another/**.*"), new IgnoredFiles("bar"))));
    assertThat(Filter.fromDisplayString("/foo/**.* , /another/**.*,     bar     "), is(new Filter(new IgnoredFiles("/foo/**.*"), new IgnoredFiles("/another/**.*"), new IgnoredFiles("bar"))));
}
Also used : Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) Test(org.junit.Test)

Example 13 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class FilterTest method shouldConcatenateIgnoredFilesWithCommaWhenDisplaying.

@Test
public void shouldConcatenateIgnoredFilesWithCommaWhenDisplaying() {
    Filter filter = new Filter(new IgnoredFiles("/foo/**.*"), new IgnoredFiles("/another/**.*"), new IgnoredFiles("bar"));
    assertThat(filter.getStringForDisplay(), is("/foo/**.*,/another/**.*,bar"));
}
Also used : Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) Test(org.junit.Test)

Example 14 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class FilterTest method shouldAddErrorToItsErrorCollection.

@Test
public void shouldAddErrorToItsErrorCollection() {
    IgnoredFiles ignore = new IgnoredFiles("helper/*.*");
    Filter filter = new Filter(ignore);
    filter.addError("key", "some error");
    assertThat(filter.errors().on("key"), is("some error"));
}
Also used : Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) Test(org.junit.Test)

Example 15 with IgnoredFiles

use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.

the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsGitWithBlacklist.

@Test
public void shouldConvertConfigMaterialWhenConfigRepoIsGitWithBlacklist() {
    // this url would be configured inside xml config-repo section
    GitMaterialConfig configRepoMaterial = new GitMaterialConfig("url");
    when(context.configMaterial()).thenReturn(configRepoMaterial);
    CRConfigMaterial crConfigMaterial = new CRConfigMaterial();
    crConfigMaterial.setFilter(new CRFilter(filter, false));
    MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context);
    assertNull("shouldSetEmptyMaterialNameAsInConfigRepoSourceCode", materialConfig.getName());
    GitMaterialConfig gitMaterialConfig = (GitMaterialConfig) materialConfig;
    assertThat(gitMaterialConfig.getAutoUpdate(), is(true));
    assertThat(gitMaterialConfig.getUrl(), is("url"));
    assertNull(gitMaterialConfig.getFolder());
    assertThat(gitMaterialConfig.getAutoUpdate(), is(true));
    assertThat(gitMaterialConfig.isShallowClone(), is(false));
    Filter blacklistFilter = new Filter(new IgnoredFiles("filter"));
    assertThat(gitMaterialConfig.filter(), is(blacklistFilter));
    assertThat(gitMaterialConfig.getUrl(), is("url"));
    assertThat(gitMaterialConfig.getBranch(), is("master"));
}
Also used : GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) PluggableSCMMaterialConfig(com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig) GitMaterialConfig(com.thoughtworks.go.config.materials.git.GitMaterialConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) P4MaterialConfig(com.thoughtworks.go.config.materials.perforce.P4MaterialConfig) TfsMaterialConfig(com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig) DependencyMaterialConfig(com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig) SvnMaterialConfig(com.thoughtworks.go.config.materials.svn.SvnMaterialConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Test(org.junit.Test)

Aggregations

Filter (com.thoughtworks.go.config.materials.Filter)25 IgnoredFiles (com.thoughtworks.go.config.materials.IgnoredFiles)25 Test (org.junit.Test)23 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)9 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)6 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)6 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)6 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)5 P4MaterialConfig (com.thoughtworks.go.config.materials.perforce.P4MaterialConfig)5 SvnMaterialConfig (com.thoughtworks.go.config.materials.svn.SvnMaterialConfig)5 HashMap (java.util.HashMap)5 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)4 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)4 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)4 TfsMaterialConfig (com.thoughtworks.go.config.materials.tfs.TfsMaterialConfig)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)4 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)3 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)3