Search in sources :

Example 46 with Materials

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

the class HgMultipleMaterialsTest method shouldFindModificationsForBothMaterials.

@Test
public void shouldFindModificationsForBothMaterials() throws Exception {
    Materials materials = new Materials(repo.createMaterial("dest1"), repo.createMaterial("dest2"));
    repo.commitAndPushFile("SomeDocumentation.txt");
    MaterialRevisions materialRevisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.getRevisions().size(), is(2));
    assertThat(materialRevisions, containsModifiedBy("SomeDocumentation.txt", "user"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 47 with Materials

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

the class SvnMultipleMaterialsTest method shouldNotThrowNPEIfTheWorkingDirectoryIsEmpty.

@Test
public void shouldNotThrowNPEIfTheWorkingDirectoryIsEmpty() throws Exception {
    SvnMaterial svnMaterial1 = repo.createMaterial("multiple-materials/trunk/part1", "part1");
    SvnMaterial svnMaterial2 = repo.createMaterial("multiple-materials/trunk/part2", "part2");
    Materials materials = new Materials(svnMaterial1, svnMaterial2);
    Revision revision = latestRevision(svnMaterial1, pipelineDir, new TestSubprocessExecutionContext());
    updateMaterials(materials, revision);
    FileUtils.deleteQuietly(pipelineDir);
    updateMaterials(materials, revision);
}
Also used : MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 48 with Materials

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

the class SvnMultipleMaterialsTest method shouldFindModificationForEachMaterial.

@Test
public void shouldFindModificationForEachMaterial() throws Exception {
    SvnMaterial material1 = repo.createMaterial("multiple-materials/trunk/part1", "part1");
    SvnMaterial material2 = repo.createMaterial("multiple-materials/trunk/part2", "part2");
    Materials materials = new Materials(material1, material2);
    repo.checkInOneFile("filename.txt", material1);
    repo.checkInOneFile("filename2.txt", material2);
    MaterialRevisions materialRevisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.getRevisions().size(), is(2));
    assertThat(materialRevisions, containsModifiedFile("/trunk/part1/filename.txt"));
    assertThat(materialRevisions, containsModifiedFile("/trunk/part2/filename2.txt"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Materials(com.thoughtworks.go.config.materials.Materials) Test(org.junit.Test)

Example 49 with Materials

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

the class SvnMultipleMaterialsTest method shouldNotDeleteWorkingDirIfMaterialsAreCheckedOutToSubfoldersWithTheSameRootBug2320.

// This is bug #2320 - Cruise doing full checkouts most times
@Test
public void shouldNotDeleteWorkingDirIfMaterialsAreCheckedOutToSubfoldersWithTheSameRootBug2320() throws Exception {
    SvnMaterial svnMaterial1 = repo.createMaterial("multiple-materials/trunk/part1", "root/part1");
    SvnMaterial svnMaterial2 = repo.createMaterial("multiple-materials/trunk/part2", "root/part2");
    Materials materials = new Materials(svnMaterial1, svnMaterial2);
    Revision revision = latestRevision(svnMaterial1, pipelineDir, new TestSubprocessExecutionContext());
    updateMaterials(materials, revision);
    assertThat(new File(pipelineDir, "root/part1").exists(), is(true));
    assertThat(new File(pipelineDir, "root/part2").exists(), is(true));
    File testFile = new File(pipelineDir, "root/part1/test-file");
    testFile.createNewFile();
    assertThat(testFile.exists(), is(true));
    // simulates what a build will do
    new File(pipelineDir, ArtifactLogUtil.CRUISE_OUTPUT_FOLDER).mkdir();
    assertThat(pipelineDir.listFiles().length, is(2));
    updateMaterials(materials, revision);
    assertThat(new File(pipelineDir, "root/part1").exists(), is(true));
    assertThat(new File(pipelineDir, "root/part2").exists(), is(true));
    assertThat("Should not delete the part1 directory", testFile.exists(), is(true));
}
Also used : MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Materials(com.thoughtworks.go.config.materials.Materials) MaterialRevisionsMatchers.containsModifiedFile(com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile) File(java.io.File) Test(org.junit.Test)

Example 50 with Materials

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

the class MixedMultipleMaterialsTest method shouldGetLatestModifications.

@Test
public void shouldGetLatestModifications() throws Exception {
    HgMaterial hgMaterial = hgRepo.material();
    SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
    Materials materials = new Materials(hgMaterial, svnMaterial);
    MaterialRevisions revisions = materials.latestModification(pipelineDir, new TestSubprocessExecutionContext());
    assertThat(revisions.getMaterialRevision(0).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(0).getRevision(), is(new Modifications(hgRepo.latestModifications()).latestRevision(hgMaterial)));
    assertThat(revisions.getMaterialRevision(1).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(1).getRevision(), is(latestRevision(svnMaterial, pipelineDir, new TestSubprocessExecutionContext())));
    assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(2));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Aggregations

Materials (com.thoughtworks.go.config.materials.Materials)63 Test (org.junit.Test)47 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)27 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)19 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)17 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)13 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)12 Material (com.thoughtworks.go.domain.materials.Material)11 Modification (com.thoughtworks.go.domain.materials.Modification)11 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)10 TimeProvider (com.thoughtworks.go.util.TimeProvider)10 File (java.io.File)10 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)9 Date (java.util.Date)8 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)7 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)5 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)5 Stage (com.thoughtworks.go.domain.Stage)5