Search in sources :

Example 26 with StringRevision

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

the class P4CommandTestBase method shouldReturnEmptyModificationListWhenP4OutputIsEmpty.

@Test
void shouldReturnEmptyModificationListWhenP4OutputIsEmpty() {
    P4Material anotherMaterial = p4Fixture.material(EMPTY_VIEW);
    List<Modification> materialRevisions = anotherMaterial.latestModification(clientFolder, new TestSubprocessExecutionContext());
    assertThat(materialRevisions.size()).isEqualTo(0);
    List<Modification> mods = anotherMaterial.modificationsSince(clientFolder, new StringRevision("1"), new TestSubprocessExecutionContext());
    assertThat(mods.size()).isEqualTo(0);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) TestSubprocessExecutionContext(com.thoughtworks.go.domain.materials.TestSubprocessExecutionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) Test(org.junit.jupiter.api.Test)

Example 27 with StringRevision

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

the class P4CommandTestBase method shouldGetChangesSinceARevision.

@Test
void shouldGetChangesSinceARevision() {
    List<Modification> output = p4.changesSince(new StringRevision("1"));
    assertThat(output.size()).isEqualTo(3);
    assertThat(output.get(0).getRevision()).isEqualTo("4");
    assertThat(output.get(1).getRevision()).isEqualTo("3");
    assertThat(output.get(2).getRevision()).isEqualTo("2");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) Test(org.junit.jupiter.api.Test)

Example 28 with StringRevision

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

the class MaterialRevisionTest method shouldDetectLatestRevision.

@Test
public void shouldDetectLatestRevision() throws Exception {
    MaterialRevision materialRevision = new MaterialRevision(hgMaterial, modification("3"), modification("2"), modification("1"));
    assertThat(materialRevision.getRevision(), is(new StringRevision("3")));
}
Also used : StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.jupiter.api.Test)

Example 29 with StringRevision

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

the class GitMaterialTest method shouldBeAbleToConvertToJson.

@Test
void shouldBeAbleToConvertToJson() {
    Map<String, Object> json = new LinkedHashMap<>();
    final GitMaterial git = new GitMaterial("http://0.0.0.0");
    git.toJson(json, new StringRevision("123"));
    JsonValue jsonValue = from(json);
    assertThat(jsonValue.getString("scmType")).isEqualTo("Git");
    assertThat(new File(jsonValue.getString("location"))).isEqualTo(new File(git.getUrl()));
    assertThat(jsonValue.getString("action")).isEqualTo("Modified");
}
Also used : JsonValue(com.thoughtworks.go.util.JsonValue) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 30 with StringRevision

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

the class GitMaterialShallowCloneTest method updateToANewRevisionShouldNotResultInUnshallowing.

@Test
void updateToANewRevisionShouldNotResultInUnshallowing() throws IOException {
    GitMaterial material = new GitMaterial(repo.projectRepositoryUrl(), true);
    material.updateTo(inMemoryConsumer(), workingDir, new RevisionContext(REVISION_4, REVISION_4, 1), context());
    assertThat(localRepoFor(material).isShallow()).isTrue();
    List<Modification> modifications = repo.addFileAndPush("newfile", "add new file");
    StringRevision newRevision = new StringRevision(modifications.get(0).getRevision());
    material.updateTo(inMemoryConsumer(), workingDir, new RevisionContext(newRevision, newRevision, 1), context());
    assertThat(new File(workingDir, "newfile").exists()).isTrue();
    assertThat(localRepoFor(material).isShallow()).isTrue();
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) RevisionContext(com.thoughtworks.go.domain.materials.RevisionContext) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) File(java.io.File) Test(org.junit.jupiter.api.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