use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldDeleteAndRecheckoutDirectoryWhenUrlChanges.
@Test
public void shouldDeleteAndRecheckoutDirectoryWhenUrlChanges() throws Exception {
updateTo(new GitMaterial(new GitTestRepo(temporaryFolder).projectRepositoryUrl(), true), new RevisionContext(new StringRevision("origin/master")), JobResult.Passed);
File shouldBeRemoved = new File(workingDir, "shouldBeRemoved");
shouldBeRemoved.createNewFile();
assertThat(shouldBeRemoved.exists(), is(true));
String repositoryUrl = new GitTestRepo(temporaryFolder).projectRepositoryUrl();
GitMaterial material = new GitMaterial(repositoryUrl, true);
updateTo(material, new RevisionContext(REVISION_4), JobResult.Passed);
assertThat(localRepoFor(material).workingRepositoryUrl().forCommandline(), is(repositoryUrl));
assertThat(shouldBeRemoved.exists(), is(false));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class HgMaterialTest method shouldNotAppendDestinationDirectoryWhileFetchingModifications.
@Test
public void shouldNotAppendDestinationDirectoryWhileFetchingModifications() throws Exception {
hgMaterial.setFolder("dest");
hgMaterial.modificationsSince(workingFolder, new StringRevision(REVISION_0), new TestSubprocessExecutionContext());
assertThat(new File(workingFolder, "dest").exists(), is(false));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class HgMaterialTest method shouldBeAbleToConvertToJson.
@Test
public void shouldBeAbleToConvertToJson() throws Exception {
Map<String, Object> json = new LinkedHashMap<>();
hgMaterial.toJson(json, new StringRevision("123"));
JsonValue jsonValue = from(json);
assertThat(jsonValue.getString("scmType"), is("Mercurial"));
assertThat(new File(jsonValue.getString("location")), is(new File(hgTestRepo.projectRepositoryUrl())));
assertThat(jsonValue.getString("action"), is("Modified"));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class HgMaterialTest method shouldReturnLatestRevisionIfNoModificationsDetected.
@Test
public void shouldReturnLatestRevisionIfNoModificationsDetected() throws Exception {
List<Modification> modification = hgMaterial.modificationsSince(workingFolder, new StringRevision(REVISION_2), new TestSubprocessExecutionContext());
assertThat(modification.isEmpty(), is(true));
}
use of com.thoughtworks.go.domain.materials.mercurial.StringRevision in project gocd by gocd.
the class HgMaterialTest method shouldNotRefreshWorkingFolderWhenFileProtocolIsUsed.
@Test
public void shouldNotRefreshWorkingFolderWhenFileProtocolIsUsed() throws Exception {
new HgCommand(null, workingFolder, "default", hgTestRepo.url().forCommandline(), null).clone(inMemoryConsumer(), hgTestRepo.url());
File testFile = createNewFileInWorkingFolder();
hgMaterial = MaterialsMother.hgMaterial("file://" + hgTestRepo.projectRepositoryUrl());
updateMaterial(hgMaterial, new StringRevision("0"));
String workingUrl = new HgCommand(null, workingFolder, "default", hgTestRepo.url().forCommandline(), null).workingRepositoryUrl().outputAsString();
assertThat(workingUrl, is(hgTestRepo.projectRepositoryUrl()));
assertThat(testFile.exists(), is(true));
}
Aggregations