Search in sources :

Example 21 with TestSubprocessExecutionContext

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

the class P4MultipleMaterialsTest method shouldIgnoreDestinationFolderWhenUpdateToOnServerSide.

@Test
public void shouldIgnoreDestinationFolderWhenUpdateToOnServerSide() {
    P4Material p4Material = p4Fixture.material(VIEW_SRC, "dest1");
    MaterialRevision revision = new MaterialRevision(p4Material, p4Material.latestModification(clientFolder, new TestSubprocessExecutionContext()));
    revision.updateTo(clientFolder, inMemoryConsumer(), new TestSubprocessExecutionContext(true));
    assertThat(new File(clientFolder, "dest1/net").exists(), is(false));
    assertThat(new File(clientFolder, "net").exists(), is(true));
}
Also used : TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) MaterialRevisionsMatchers.containsModifiedFile(com.thoughtworks.go.config.MaterialRevisionsMatchers.containsModifiedFile) File(java.io.File) Test(org.junit.Test)

Example 22 with TestSubprocessExecutionContext

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

the class P4TestRepo method checkInOneFile.

private List<Modification> checkInOneFile(P4Material p4Material1, String fileName, String comment) throws Exception {
    File workingDir = temporaryFolder.newFolder();
    P4Client client = createClient();
    client.client(clientConfig(clientName, workingDir), inMemoryConsumer(), true);
    File dir = new File(workingDir, p4Material1.getFolder());
    dir.mkdirs();
    checkout(dir);
    File newFile = new File(new File(workingDir, p4Material1.getFolder()), fileName);
    newFile.createNewFile();
    add(workingDir, newFile.getAbsolutePath());
    commit(comment, workingDir);
    client.removeClient();
    List<Modification> modifications = p4Material1.latestModification(workingDir, new TestSubprocessExecutionContext());
    return modifications;
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) P4Client(com.thoughtworks.go.domain.materials.perforce.P4Client) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) File(java.io.File)

Example 23 with TestSubprocessExecutionContext

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

the class TfsMaterialTest method shouldShowLatestModification.

@Test
public void shouldShowLatestModification() throws IOException {
    File dir = temporaryFolder.newFolder("tfs-dir");
    TestSubprocessExecutionContext execCtx = new TestSubprocessExecutionContext();
    TfsMaterial spy = spy(tfsMaterialFirstCollectionSecondProject);
    TfsCommand tfsCommand = mock(TfsCommand.class);
    when(tfsCommand.latestModification(dir)).thenReturn(new ArrayList<>());
    doReturn(tfsCommand).when(spy).tfs(execCtx);
    List<Modification> actual = spy.latestModification(dir, execCtx);
    assertThat(actual, is(new ArrayList<Modification>()));
    verify(tfsCommand).latestModification(dir);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) TfsCommand(com.thoughtworks.go.domain.materials.tfs.TfsCommand) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 24 with TestSubprocessExecutionContext

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

the class TfsMaterialTest method shouldLoadAllModificationsSinceAGivenRevision.

@Test
public void shouldLoadAllModificationsSinceAGivenRevision() throws IOException {
    File dir = temporaryFolder.newFolder("tfs-dir");
    TestSubprocessExecutionContext execCtx = new TestSubprocessExecutionContext();
    TfsMaterial spy = spy(tfsMaterialFirstCollectionFirstProject);
    TfsCommand tfsCommand = mock(TfsCommand.class);
    when(tfsCommand.modificationsSince(dir, new StringRevision("5"))).thenReturn(new ArrayList<>());
    doReturn(tfsCommand).when(spy).tfs(execCtx);
    List<Modification> actual = spy.modificationsSince(dir, new StringRevision("5"), execCtx);
    assertThat(actual, is(new ArrayList<Modification>()));
    verify(tfsCommand).modificationsSince(dir, new StringRevision("5"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) TfsCommand(com.thoughtworks.go.domain.materials.tfs.TfsCommand) ArrayList(java.util.ArrayList) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File) Test(org.junit.Test)

Example 25 with TestSubprocessExecutionContext

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

the class HgMaterialDockerTest method shouldRefreshWorkingDirectoryIfUsernameInUrlChanges.

@Test
public void shouldRefreshWorkingDirectoryIfUsernameInUrlChanges() throws Exception {
    HgMaterial material = new HgMaterial("http://user1:password@localhost:9999", null);
    final List<Modification> modifications = material.latestModification(workingFolder, new TestSubprocessExecutionContext());
    final File unversionedFile = new File(workingFolder, "unversioned.txt");
    FileUtils.writeStringToFile(unversionedFile, "something", UTF_8);
    assertTrue(unversionedFile.exists());
    material = new HgMaterial("http://user2:password@localhost:9999", null);
    material.modificationsSince(workingFolder, new StringRevision(modifications.get(0).getRevision()), new TestSubprocessExecutionContext());
    assertFalse(unversionedFile.exists());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File) 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