use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.
the class PipelineConfigDependencyGraphTest method shouldReturnIfSharedRevisionsAreIgnoredByAllDaddys.
@Test
public void shouldReturnIfSharedRevisionsAreIgnoredByAllDaddys() throws Exception {
SvnMaterialConfig firstOrderSVNMaterial = MaterialConfigsMother.svnMaterialConfig();
GitMaterialConfig firstOrderGitMaterial = MaterialConfigsMother.gitMaterialConfig("url");
P4MaterialConfig firstOrderP4Material = MaterialConfigsMother.p4MaterialConfig();
firstOrderP4Material.setFilter(new Filter(new IgnoredFiles("foo")));
PipelineConfig current = GoConfigMother.createPipelineConfigWithMaterialConfig("current", MaterialConfigsMother.hgMaterialConfig(), new DependencyMaterialConfig(new CaseInsensitiveString("up1"), new CaseInsensitiveString("first")), new DependencyMaterialConfig(new CaseInsensitiveString("up2"), new CaseInsensitiveString("first")));
PipelineConfig up1 = GoConfigMother.createPipelineConfigWithMaterialConfig("up1", filteredHgMaterialConfig("phigar"), firstOrderGitMaterial, new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
PipelineConfig up2 = GoConfigMother.createPipelineConfigWithMaterialConfig("up2", firstOrderSVNMaterial, firstOrderP4Material, filteredHgMaterialConfig("phigar"), new DependencyMaterialConfig(new CaseInsensitiveString("uppest"), new CaseInsensitiveString("first")));
PipelineConfig uppest = GoConfigMother.createPipelineConfigWithMaterialConfig("uppest", filteredHgMaterialConfig("phigar"), firstOrderP4Material);
PipelineConfigDependencyGraph uppestGraph = new PipelineConfigDependencyGraph(uppest);
PipelineConfigDependencyGraph up1Graph = new PipelineConfigDependencyGraph(up1, uppestGraph);
PipelineConfigDependencyGraph up2Graph = new PipelineConfigDependencyGraph(up2, uppestGraph);
PipelineConfigDependencyGraph dependencyGraph = new PipelineConfigDependencyGraph(current, up1Graph, up2Graph);
Modification modification = new Modification("user", "comment", "i@u.com", new Date(), "foo");
modification.createModifiedFile("phigar", "", ModifiedAction.added);
boolean ignored = dependencyGraph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, modification));
assertThat(ignored, is(true));
ignored = dependencyGraph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, ModificationsMother.oneModifiedFile("Silly")));
assertThat(ignored, is(false));
MaterialRevisions materialRevisions = ModificationsMother.createSvnMaterialRevisions(modification);
materialRevisions.addAll(ModificationsMother.createP4MaterialRevisions(modification));
materialRevisions.addAll(ModificationsMother.createHgMaterialWithMultipleRevisions(1, modification));
ignored = up2Graph.isRevisionsOfSharedMaterialsIgnored(materialRevisions);
assertThat(ignored, is(true));
ignored = up2Graph.isRevisionsOfSharedMaterialsIgnored(ModificationsMother.createHgMaterialWithMultipleRevisions(1, ModificationsMother.oneModifiedFile("Silly")));
assertThat(ignored, is(false));
}
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"));
}
use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.
the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHgWithDestination.
@Test
public void shouldConvertConfigMaterialWhenConfigRepoIsHgWithDestination() {
// these parameters would be configured inside xml config-repo section
HgMaterialConfig configRepoMaterial = new HgMaterialConfig(new HgUrlArgument("url"), true, new Filter(new IgnoredFiles("ignore")), false, "folder", new CaseInsensitiveString("name"));
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", "dest1", null);
MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context);
assertThat("shouldSetMaterialNameAsInConfigRepoSourceCode", materialConfig.getName().toLower(), is("example"));
assertThat("shouldUseFolderFromConfigRepoWhenSpecified", materialConfig.getFolder(), is("dest1"));
HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
assertThat(hgMaterialConfig.getAutoUpdate(), is(true));
assertThat(hgMaterialConfig.getFilterAsString(), is("ignore"));
assertThat(hgMaterialConfig.getUrl(), is("url"));
}
use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.
the class ConfigConverterTest method shouldConvertConfigMaterialWhenConfigRepoIsHg.
@Test
public void shouldConvertConfigMaterialWhenConfigRepoIsHg() {
// these parameters would be configured inside xml config-repo section
HgMaterialConfig configRepoMaterial = new HgMaterialConfig(new HgUrlArgument("url"), true, new Filter(new IgnoredFiles("ignore")), false, "folder", new CaseInsensitiveString("name"));
when(context.configMaterial()).thenReturn(configRepoMaterial);
CRConfigMaterial crConfigMaterial = new CRConfigMaterial("example", null, null);
MaterialConfig materialConfig = configConverter.toMaterialConfig(crConfigMaterial, context);
assertThat("shouldSetMaterialNameAsInConfigRepoSourceCode", materialConfig.getName().toLower(), is("example"));
assertThat("shouldUseFolderFromXMLWhenConfigRepoHasNone", materialConfig.getFolder(), is("folder"));
HgMaterialConfig hgMaterialConfig = (HgMaterialConfig) materialConfig;
assertThat(hgMaterialConfig.getAutoUpdate(), is(true));
assertThat(hgMaterialConfig.getFilterAsString(), is("ignore"));
assertThat(hgMaterialConfig.getUrl(), is("url"));
}
use of com.thoughtworks.go.config.materials.IgnoredFiles in project gocd by gocd.
the class MaterialRevisionTest method shouldIgnoreDocumentCheckin.
@Test
public void shouldIgnoreDocumentCheckin() throws Exception {
MaterialRevision previousRevision = new MaterialRevision(hgMaterial, hgMaterial.modificationsSince(workingFolder, REVISION_0, new TestSubprocessExecutionContext()));
Filter filter = new Filter(new IgnoredFiles("**/*.doc"));
hgMaterial.setFilter(filter);
checkInFiles(hgMaterial, "user.doc");
MaterialRevision newRevision = findNewRevision(previousRevision, hgMaterial, workingFolder, new TestSubprocessExecutionContext());
assertThat(newRevision.filter(previousRevision), is(previousRevision));
}
Aggregations