Search in sources :

Example 51 with HgMaterial

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

the class AutoTriggerDependencyResolutionTest method shouldChooseTheRevisionFromSecondInAComplexSituation.

@Test
public void shouldChooseTheRevisionFromSecondInAComplexSituation() throws Exception {
    // hg -> First          git
    // |      \             |
    // |      Third  <- Second
    // |        |      /
    // |        |    /
    // +------> Last
    // 
    HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
    String[] hg_revs = { "h1", "h2" };
    u.checkinInOrder(hg, hg_revs);
    GitMaterial git = u.wf(new GitMaterial("git"), "folder2");
    String[] git_revs = { "g1", "g2" };
    u.checkinInOrder(git, git_revs);
    ScheduleTestUtil.AddedPipeline first = u.saveConfigWith("first", u.m(hg));
    ScheduleTestUtil.AddedPipeline second = u.saveConfigWith("second", u.m(git));
    ScheduleTestUtil.AddedPipeline third = u.saveConfigWith("third", u.m(first), u.m(second));
    ScheduleTestUtil.AddedPipeline last = u.saveConfigWith("last", u.m(hg), u.m(second), u.m(third));
    String first_1 = u.runAndPass(first, "h1");
    String second_1 = u.runAndPass(second, "g1");
    String second_2 = u.runAndPass(second, "g1");
    String second_3 = u.runAndPass(second, "g2");
    String second_4 = u.runAndPass(second, "g2");
    String third_1 = u.runAndPass(third, first_1, second_2);
    String third_2 = u.runAndPass(third, first_1, second_2);
    String third_3 = u.runAndPass(third, first_1, second_2);
    MaterialRevisions given = u.mrs(u.mr(hg, true, hg_revs), u.mr(second, true, second_4), u.mr(third, true, third_3));
    MaterialRevisions expected = u.mrs(u.mr(hg, true, "h1"), u.mr(second, true, second_2), u.mr(third, true, third_3));
    MaterialRevisions finalRevisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("last"));
    assertThat(finalRevisions, is(expected));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 52 with HgMaterial

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

the class AutoTriggerDependencyResolutionTest method shouldGetTheRevisionsFromTheNearestUpStreamPipeline.

@Test
public void shouldGetTheRevisionsFromTheNearestUpStreamPipeline() throws Exception {
    HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
    String[] hg_revs = { "hg1", "hg2", "hg3" };
    int i = 1;
    u.checkinInOrder(hg, u.d(i++), hg_revs);
    ScheduleTestUtil.AddedPipeline up0 = u.saveConfigWith("up0", u.m(hg));
    ScheduleTestUtil.AddedPipeline up1 = u.saveConfigWith("up1", u.m(up0), u.m(hg));
    ScheduleTestUtil.AddedPipeline current = u.saveConfigWith("current", u.m(up1), u.m(hg));
    String up0_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg1");
    String up0_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg2");
    String up0_3 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up0, u.d(i++), "hg3");
    String up1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(up1, u.d(i), up0_2, "hg2");
    MaterialRevisions given = u.mrs(u.mr(hg, true, "hg3"), u.mr(up1, true, up1_1));
    MaterialRevisions expected = u.mrs(u.mr(hg, true, "hg2"), u.mr(up1, true, up1_1));
    MaterialRevisions revisions = getRevisionsBasedOnDependencies(goConfigDao.load(), given, new CaseInsensitiveString("current"));
    assertThat(revisions, is(expected));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 53 with HgMaterial

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

the class PipelineMaterialRevisionTest method shouldNotSetFROMRevisionSameAsTORevisionWhenSCMMaterial.

@Test
public void shouldNotSetFROMRevisionSameAsTORevisionWhenSCMMaterial() {
    Material material = new HgMaterial("http://some_server/repo", null);
    Modification latestModification = modification(new Date(), "123", null, null);
    Modification earlierModification = modification(new Date(), "23", null, null);
    MaterialRevision revision = new MaterialRevision(material, latestModification, earlierModification);
    PipelineMaterialRevision pmr = new PipelineMaterialRevision(9, revision, null);
    assertThat(pmr.getToModification(), is(latestModification));
    assertThat(pmr.getFromModification(), is(earlierModification));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Date(java.util.Date) Test(org.junit.Test)

Example 54 with HgMaterial

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

the class MixedMultipleMaterialsTest method shouldGetLatestModificationswithThreeRepositories.

@Test
public void shouldGetLatestModificationswithThreeRepositories() throws Exception {
    HgMaterial hgMaterial = hgRepo.material();
    SvnMaterial svnMaterial = svnRepo.createMaterial("multiple-materials/trunk/part1", "part1");
    GitMaterial gitMaterial = gitRepo.createMaterial();
    Materials materials = new Materials(hgMaterial, svnMaterial, gitMaterial);
    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.getMaterialRevision(2).numberOfModifications(), is(1));
    assertThat(revisions.getMaterialRevision(2).getRevision(), is(new Modifications(gitRepo.latestModifications()).latestRevision(gitMaterial)));
    assertThat(revisions.toString(), revisions.totalNumberOfModifications(), is(3));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) 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)

Example 55 with HgMaterial

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

the class PipelineLabelTest method shouldReplaceTheTemplateWithMultipleMaterialRevision.

@Test
public void shouldReplaceTheTemplateWithMultipleMaterialRevision() throws Exception {
    PipelineLabel label = PipelineLabel.create("release-${svnMaterial}-${hg}");
    MaterialRevisions materialRevisions = ModificationsMother.oneUserOneFile();
    HgMaterial material = MaterialsMother.hgMaterial();
    material.setName(new CaseInsensitiveString("hg"));
    Modification modification = new Modification();
    modification.setRevision("ae09876hj");
    materialRevisions.addRevision(material, modification);
    label.updateLabel(materialRevisions.getNamedRevisions());
    assertThat(label.toString(), is("release-" + ModificationsMother.currentRevision() + "-ae09876hj"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PipelineLabel(com.thoughtworks.go.domain.label.PipelineLabel) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)121 Test (org.junit.Test)107 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)34 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)29 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)23 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)20 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)18 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)16 Material (com.thoughtworks.go.domain.materials.Material)15 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)10 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)10 Date (java.util.Date)10 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)9 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)9 TimeProvider (com.thoughtworks.go.util.TimeProvider)8 Pagination (com.thoughtworks.go.server.util.Pagination)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)6 Modification (com.thoughtworks.go.domain.materials.Modification)6 File (java.io.File)6