use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo.
@Test
public void shouldRemoveSubmoduleFolderFromWorkingDirWhenSubmoduleIsRemovedFromRepo() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
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()));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class GitMaterialUpdaterTest method shouldAllowSubmoduleUrlstoChange.
@Test
public void shouldAllowSubmoduleUrlstoChange() throws Exception {
GitSubmoduleRepos submoduleRepos = new GitSubmoduleRepos();
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'"));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class GitMaterialUpdaterTest method cloneWithDeepWorkingDir.
@Test
public void cloneWithDeepWorkingDir() throws Exception {
GitMaterial material = new GitMaterial(new GitTestRepo().projectRepositoryUrl(), "", "foo/bar/baz", true);
updateTo(material, new RevisionContext(REVISION_4), JobResult.Passed);
assertThat(new File(workingDir, "foo/bar/baz/build.xml").exists(), is(true));
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class SvnMaterialMockitoTest method shouldNotDeleteWorkingDirIfSvnRepositoryUsesFileProtocol.
@Test
public void shouldNotDeleteWorkingDirIfSvnRepositoryUsesFileProtocol() throws IOException {
Subversion subversion = mock(Subversion.class);
when(subversion.getUserName()).thenReturn("");
when(subversion.getPassword()).thenReturn("");
when(subversion.isCheckExternals()).thenReturn(false);
File workingCopy = createSvnWorkingCopy(true);
when(subversion.workingRepositoryUrl(workingCopy)).thenReturn(workingCopy.getPath());
String url = "file://" + workingCopy.getPath();
when(subversion.getUrl()).thenReturn(new UrlArgument(url));
SvnMaterial svnMaterial = SvnMaterial.createSvnMaterialWithMock(subversion);
svnMaterial.setUrl(url);
svnMaterial.updateTo(outputStreamConsumer, workingCopy, new RevisionContext(revision), new TestSubprocessExecutionContext());
assertThat(workingCopy.exists(), is(true));
verify(subversion).updateTo(outputStreamConsumer, workingCopy, revision);
}
use of com.thoughtworks.go.domain.materials.RevisionContext in project gocd by gocd.
the class BackupServiceIntegrationTest method shouldBackupConfigRepository.
@Test
public void shouldBackupConfigRepository() throws IOException {
configHelper.addPipeline("too-unique-to-be-present", "stage-name");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
backupService.startBackup(admin, result);
assertThat(result.isSuccessful(), is(true));
assertThat(result.message(localizer), is("Backup completed successfully."));
File repoZip = backedUpFile("config-repo.zip");
File repoDir = tempFiles.createUniqueFolder("expanded-config-repo-backup");
TestUtils.extractZipToDir(repoZip, repoDir);
File cloneDir = tempFiles.createUniqueFolder("cloned-config-repo-backup");
GitMaterial git = new GitMaterial(repoDir.getAbsolutePath());
List<Modification> modifications = git.latestModification(cloneDir, subprocessExecutionContext);
String latestChangeRev = modifications.get(0).getRevision();
git.checkout(cloneDir, new StringRevision(latestChangeRev), subprocessExecutionContext);
assertThat(FileUtil.readContentFromFile(new File(cloneDir, "cruise-config.xml")).indexOf("too-unique-to-be-present"), greaterThan(0));
StringRevision revision = new StringRevision(latestChangeRev + "~1");
git.updateTo(new InMemoryStreamConsumer(), cloneDir, new RevisionContext(revision), subprocessExecutionContext);
assertThat(FileUtil.readContentFromFile(new File(cloneDir, "cruise-config.xml")).indexOf("too-unique-to-be-present"), is(-1));
}
Aggregations