Search in sources :

Example 11 with StringRevision

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

the class GitMaterialUpdaterTest method shouldAllowSubmoduleUrlstoChange.

@Test
public void shouldAllowSubmoduleUrlstoChange() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
    String submoduleDirectoryName = "local-submodule";
    submoduleRepos.addSubmodule(SUBMODULE, submoduleDirectoryName);
    GitMaterial material = new GitMaterial(submoduleRepos.projectRepositoryUrl(), true);
    updateTo(material, new RevisionContext(new StringRevision("origin/HEAD")), JobResult.Passed);
    submoduleRepos.changeSubmoduleUrl(submoduleDirectoryName);
    updateTo(material, new RevisionContext(new StringRevision("origin/HEAD")), JobResult.Passed);
    assertThat(console.output(), containsString("Synchronizing submodule url for 'local-submodule'"));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 12 with StringRevision

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

the class GitMaterialUpdaterTest method shouldCleanUnversionedFilesInsideSubmodulesBeforeUpdating.

@Test
public void shouldCleanUnversionedFilesInsideSubmodulesBeforeUpdating() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
    String submoduleDirectoryName = "local-submodule";
    submoduleRepos.addSubmodule(SUBMODULE, submoduleDirectoryName);
    GitMaterial material = new GitMaterial(submoduleRepos.projectRepositoryUrl(), true);
    updateTo(material, new RevisionContext(new StringRevision("origin/HEAD")), JobResult.Passed);
    File unversionedFile = new File(new File(workingDir, submoduleDirectoryName), "unversioned_file.txt");
    FileUtils.writeStringToFile(unversionedFile, "this is an unversioned file. lets see you deleting me.. come on.. I dare you!!!!", UTF_8);
    updateTo(material, new RevisionContext(new StringRevision("origin/HEAD")), JobResult.Passed);
    assertThat(unversionedFile.exists(), Matchers.is(false));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 13 with StringRevision

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

the class GitMaterialUpdaterTest method shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo.

@Test
public void shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo() throws Exception {
    GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos(temporaryFolder);
    submoduleRepos.addSubmodule(SUBMODULE, "sub1");
    GitMaterial gitMaterial = new GitMaterial(submoduleRepos.mainRepo().getUrl(), true);
    StringRevision revision = new StringRevision("origin/master");
    updateTo(gitMaterial, new RevisionContext(revision), JobResult.Passed);
    assertThat(new File(workingDir, "sub1"), exists());
    submoduleRepos.removeSubmodule("sub1");
    updateTo(gitMaterial, new RevisionContext(revision), JobResult.Passed);
    assertThat(new File(workingDir, "sub1"), not(exists()));
}
Also used : GitSubmoduleRepos(com.thoughtworks.go.helper.GitSubmoduleRepos) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File) Test(org.junit.Test)

Example 14 with StringRevision

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

the class GitMaterialUpdaterTest method failureCommandShouldNotLeakPasswordOnUrl.

@Test
public void failureCommandShouldNotLeakPasswordOnUrl() throws Exception {
    GitMaterial material = new GitMaterial("https://foo:foopassword@this.is.absolute.not.exists", true);
    updateTo(material, new RevisionContext(new StringRevision("origin/master")), JobResult.Failed);
    assertThat(console.output(), containsString("https://foo:******@this.is.absolute.not.exists/"));
    assertThat(console.output(), not(containsString("foopassword")));
}
Also used : RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Test(org.junit.Test)

Example 15 with StringRevision

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

the class HgMaterialTest method shouldUpdateToDestinationFolder.

@Test
public void shouldUpdateToDestinationFolder() throws Exception {
    hgMaterial.setFolder("dest");
    updateMaterial(hgMaterial, new StringRevision("0"));
    File end2endFolder = new File(workingFolder, "dest/end2end");
    assertThat(end2endFolder.exists(), is(true));
}
Also used : StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File) Test(org.junit.Test)

Aggregations

StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)65 Test (org.junit.Test)35 File (java.io.File)31 Test (org.junit.jupiter.api.Test)23 Modification (com.thoughtworks.go.domain.materials.Modification)17 RevisionContext (com.thoughtworks.go.domain.materials.RevisionContext)17 GitSubmoduleRepos (com.thoughtworks.go.helper.GitSubmoduleRepos)11 GitTestRepo (com.thoughtworks.go.domain.materials.git.GitTestRepo)7 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)6 TestSubprocessExecutionContext (com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 StringContains.containsString (org.hamcrest.core.StringContains.containsString)5 RegexMatcher (com.thoughtworks.go.matchers.RegexMatcher)4 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)3 JsonValue (com.thoughtworks.go.util.JsonValue)3 Changeset (com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Changeset)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)2 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)2 SysOutStreamConsumer (com.thoughtworks.go.mail.SysOutStreamConsumer)2