use of com.thoughtworks.go.config.materials.svn.SvnMaterial 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.config.materials.svn.SvnMaterial in project gocd by gocd.
the class MaterialDatabaseSvnWithExternalsUpdaterTest method shouldUpdateModificationsForExternals.
@Test
public void shouldUpdateModificationsForExternals() throws Exception {
updater.updateMaterial(material);
testRepoWithExternal.checkInExternalFile("foo_bar", "foo bar quux");
updater.updateMaterial(material);
MaterialRevisions materialRevisions = materialRepository.findLatestModification(material);
assertThat(materialRevisions.numberOfRevisions(), is(2));
SvnMaterial externalMaterial = testRepoWithExternal.externalMaterial();
MaterialRevision revisionForExternal = materialRevisions.findRevisionFor(externalMaterial);
assertThat(revisionForExternal.getModification(0).getComment(), is("foo bar quux"));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class MaterialDatabaseSvnWithExternalsUpdaterTest method shouldNotTryToSaveModificationForAnExternalThathasAlreadyBeenSaved.
@Test
public void shouldNotTryToSaveModificationForAnExternalThathasAlreadyBeenSaved() throws Exception {
updater.updateMaterial(material);
SvnTestRepoWithExternal otherRepo = new SvnTestRepoWithExternal(testRepoWithExternal.externalRepositoryUrl());
SvnMaterial otherMaterial = new SvnMaterial(otherRepo.projectRepositoryUrl(), null, null, true);
updater.updateMaterial(otherMaterial);
MaterialRevisions materialRevisions = materialRepository.findLatestModification(otherMaterial);
assertThat(materialRevisions.numberOfRevisions(), is(2));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class MaterialRevisionBuilder method svnInstance.
public Tuple svnInstance(String revision, Date modifiedTime) {
String key = key("svn", revision, modifiedTime);
insertIfNotPresent(new SvnMaterial("url", "username", "password", false), key, revision, modifiedTime);
return new Tuple(null, instanceToRevision.get(key));
}
use of com.thoughtworks.go.config.materials.svn.SvnMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method findModificationsSince_shouldCacheResults.
@Test
public void findModificationsSince_shouldCacheResults() {
SvnMaterial material = MaterialsMother.svnMaterial();
MaterialRevision zero = saveOneScmModification(material, "user1", "file1");
MaterialRevision first = saveOneScmModification(material, "user1", "file1");
MaterialRevision second = saveOneScmModification(material, "user2", "file2");
MaterialRevision third = saveOneScmModification(material, "user2", "file2");
repo.findModificationsSince(material, first);
HibernateTemplate mockTemplate = mock(HibernateTemplate.class);
repo.setHibernateTemplate(mockTemplate);
List<Modification> modifications = repo.findModificationsSince(material, first);
assertThat(modifications.size(), is(2));
assertEquals(third.getLatestModification(), modifications.get(0));
assertEquals(second.getLatestModification(), modifications.get(1));
verifyNoMoreInteractions(mockTemplate);
}
Aggregations