Mercurial > hg > mercurial
view mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgVcsRootFactoryTest.java @ 717:c37903906fad
add new test
author | eugene.petrenko@jetbrains.com |
---|---|
date | Mon, 13 Jan 2014 19:20:39 +0100 |
parents | c32869bd757b |
children | 31a1aca3305c |
line wrap: on
line source
package jetbrains.buildServer.buildTriggers.vcs.mercurial; import jetbrains.buildServer.TempFiles; import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.HgVcsRoot; import jetbrains.buildServer.util.TestFor; import jetbrains.buildServer.vcs.VcsRoot; import org.testng.annotations.Test; import java.io.File; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.ServerPluginConfigBuilder.serverPluginConfig; import static jetbrains.buildServer.buildTriggers.vcs.mercurial.VcsRootBuilder.vcsRoot; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertTrue; @Test public class HgVcsRootFactoryTest extends BaseMercurialTestCase { @TestFor(issues = "TW-25057") public void vcs_root_custom_clone_dir_should_not_contain_password() throws Exception { TempFiles tmp = new TempFiles(); String urlWithoutPath = "http://only.host/"; String password = "pwd"; VcsRoot root = vcsRoot() .withUrl(urlWithoutPath) .withUserName("user") .withPassword(password) .withCloneRepositoryTo(tmp.createTempDir()) .build(); HgVcsRoot hgRoot = new HgVcsRootFactory(serverPluginConfig().cachesDir(tmp.createTempDir()).build()).createHgRoot(root); assertFalse("Custom clone dir contains password", hgRoot.getCustomWorkingDir().getName().contains(password)); } @TestFor(issues = "TW-32540") public void custom_clone_dir_should_contain_only_valid_characters() throws Exception { TempFiles tmp = new TempFiles(); String urlWithoutPath = "http://acme:8000/"; VcsRoot root = vcsRoot() .withUrl(urlWithoutPath) .withCloneRepositoryTo(tmp.createTempDir()) .build(); HgVcsRoot hgRoot = new HgVcsRootFactory(serverPluginConfig().cachesDir(tmp.createTempDir()).build()).createHgRoot(root); hgRoot.getCustomWorkingDir().mkdirs(); assertTrue(hgRoot.getCustomWorkingDir().exists()); } @TestFor(issues = "TW-28974") public void should_use_default_dirs() throws Exception { TempFiles tmp = new TempFiles(); File cachesDir = tmp.createTempDir(); File nonCanonicalCachesDir = new File(cachesDir.getCanonicalPath() + "/../" + cachesDir.getName()); ServerPluginConfig pluginConfig = serverPluginConfig().cachesDir(cachesDir).build(); VcsRoot root = vcsRoot() .withUrl("http://acme.com/repo") .withCloneRepositoryTo(nonCanonicalCachesDir) .build(); HgVcsRoot hgRoot = new HgVcsRootFactory(pluginConfig).createHgRoot(root); assertNull("Custom working dir is used instead of default one", hgRoot.getCustomWorkingDir()); } }