private void updateTo(SvnMaterial material, RevisionContext revisionContext, JobResult expectedResult) { BuildSession buildSession = newBuildSession(); JobResult result = buildSession.build(new SvnMaterialUpdater(material).updateTo(workingDir.toString(), revisionContext)); assertThat(buildInfo(), result, is(expectedResult)); } }
@Test public void shouldUpdateToDestinationFolder() throws Exception { svnMaterial.setFolder("dest"); updateTo(svnMaterial, new RevisionContext(revision), JobResult.Passed); assertThat(new File(workingDir, "dest").exists(), is(true)); assertThat(new File(workingDir, "dest/.svn").exists(), is(true)); }
@Test public void shouldDoAFreshCheckoutIfDestIsNotARepo() throws Exception { updateTo(svnMaterial, new RevisionContext(revision), JobResult.Passed); console.clear(); FileUtils.deleteQuietly(new File(workingDir, "svnDir/.svn")); updateTo(svnMaterial, new RevisionContext(revision), JobResult.Passed); assertThat(console.output(), containsString("Checked out revision")); assertThat(console.output(), not(containsString("Updating"))); }
@Test @RunIf(value = EnhancedOSChecker.class, arguments = {DO_NOT_RUN_ON, WINDOWS}) public void shouldUpdateIfNotCheckingOutFreshCopy() throws IOException { updateTo(svnMaterial, new RevisionContext(revision), JobResult.Passed); console.clear(); updateTo(svnMaterial, new RevisionContext(revision), JobResult.Passed); assertThat(console.output(), not(containsString("Checked out revision"))); assertThat(console.output(), containsString("Updating")); }
@Test public void shouldNotUpdateIfCheckingOutAFreshCopy() throws IOException { updateTo(svnMaterial, new RevisionContext(revision), JobResult.Passed); assertThat(console.output(), containsString("Checked out revision")); assertThat(console.output(), not(containsString("Updating"))); }
@Test public void shouldNotLeakPasswordInUrlIfCheckoutFails() throws Exception { SvnMaterial material = MaterialsMother.svnMaterial("https://foo:foopassword@thisdoesnotexist.io/repo"); updateTo(material, new RevisionContext(revision), JobResult.Failed); assertThat(console.output(), containsString("https://foo:******@thisdoesnotexist.io/repo")); assertThat(console.output(), not(containsString("foopassword"))); }
@Test public void shouldDoFreshCheckoutIfUrlChanges() throws Exception { updateTo(svnMaterial, new RevisionContext(revision), JobResult.Passed); console.clear(); File shouldBeRemoved = new File(workingDir, "svnDir/shouldBeRemoved"); shouldBeRemoved.createNewFile(); assertThat(shouldBeRemoved.exists(), is(true)); String repositoryUrl = new SvnTestRepo(temporaryFolder).projectRepositoryUrl(); assertNotEquals(svnTestRepo.projectRepositoryUrl(), repositoryUrl); SvnMaterial material = MaterialsMother.svnMaterial(repositoryUrl); updateTo(material, new RevisionContext(revision), JobResult.Passed); assertThat(material.getUrl(), is(repositoryUrl)); assertThat(console.output(), containsString("Checked out revision")); assertThat(console.output(), not(containsString("Updating"))); assertThat(shouldBeRemoved.exists(), is(false)); }