Search in sources :

Example 16 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class HgMultipleMaterialsTest method shouldIgnoreDestinationFolderWhenServerSide.

@Test
public void shouldIgnoreDestinationFolderWhenServerSide() throws Exception {
    HgMaterial material1 = repo.createMaterial("dest1");
    MaterialRevision materialRevision = new MaterialRevision(material1, material1.latestModification(pipelineDir, new TestSubprocessExecutionContext()));
    materialRevision.updateTo(pipelineDir, ProcessOutputStreamConsumer.inMemoryConsumer(), new TestSubprocessExecutionContext(true));
    assertThat(new File(pipelineDir, "dest1").exists(), is(false));
    assertThat(new File(pipelineDir, ".hg").exists(), is(true));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) File(java.io.File) Test(org.junit.Test)

Example 17 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext 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 18 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class HgMaterialUpdaterTest method shouldPullNewChangesFromRemoteBeforeUpdating.

@Test
public void shouldPullNewChangesFromRemoteBeforeUpdating() throws Exception {
    File newWorkingFolder = temporaryFolder.newFolder("newWorkingFolder");
    updateTo(hgMaterial, new RevisionContext(REVISION_0), JobResult.Passed);
    String repositoryUrl = hgTestRepo.projectRepositoryUrl();
    HgMaterial material = MaterialsMother.hgMaterial(repositoryUrl);
    assertThat(material.getUrl(), is(hgMaterial.getUrl()));
    updateTo(material, new RevisionContext(REVISION_0), JobResult.Passed, newWorkingFolder);
    hgTestRepo.commitAndPushFile("SomeDocumentation.txt", "whatever");
    List<Modification> modification = hgMaterial.latestModification(workingFolder, new TestSubprocessExecutionContext());
    StringRevision revision = new StringRevision(modification.get(0).getRevision());
    updateTo(material, new RevisionContext(revision), JobResult.Passed, newWorkingFolder);
    assertThat(console.output(), containsString("Start updating files at revision " + revision.getRevision()));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) StringContains.containsString(org.hamcrest.core.StringContains.containsString) File(java.io.File) Test(org.junit.Test)

Example 19 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class P4MaterialTestBase method shouldReplacePasswordUsingStar.

@Test
public void shouldReplacePasswordUsingStar() throws Exception {
    P4Material p4Material = new P4Material("localhost:9876", "p4view");
    p4Material.setPassword("secret");
    p4Material.setUseTickets(true);
    try {
        p4Material.latestModification(clientFolder, new TestSubprocessExecutionContext());
        fail("should throw exception because p4 server not exists.");
    } catch (Exception e) {
        assertThat(e.getMessage(), not(containsString("secret")));
    }
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) Test(org.junit.Test)

Example 20 with TestSubprocessExecutionContext

use of com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext in project gocd by gocd.

the class P4MaterialTestBase method shouldValidateCorrectConnection.

@Test
public void shouldValidateCorrectConnection() throws Exception {
    P4Material p4Material = p4Fixture.material(VIEW);
    p4Material.setPassword("secret");
    p4Material.setUseTickets(false);
    ValidationBean validation = p4Material.checkConnection(new TestSubprocessExecutionContext());
    assertThat(validation.isValid(), is(true));
    assertThat(StringUtils.isBlank(validation.getError()), is(true));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) ValidationBean(com.thoughtworks.go.domain.materials.ValidationBean) Test(org.junit.Test)

Aggregations

TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)30 Test (org.junit.Test)24 File (java.io.File)15 Modification (com.thoughtworks.go.domain.materials.Modification)9 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)5 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)5 MaterialRevisionsMatchers.containsModifiedFile (com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile)4 Materials (com.thoughtworks.go.config.materials.Materials)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 TfsCommand (com.thoughtworks.go.domain.materials.tfs.TfsCommand)3 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)2 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)2 Material (com.thoughtworks.go.domain.materials.Material)2 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)2 ValidationBean (com.thoughtworks.go.domain.materials.ValidationBean)2 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)2 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2