# HG changeset patch # User Dmitry Neverov # Date 1295592966 -10800 # Node ID 42bbe553bd8baa0d7196c5b1038035f66420cde2 # Parent bcc04a74783d161158cf6e9f507d9336f8863dc3 Test we clone to the destination dir diff -r bcc04a74783d -r 42bbe553bd8b mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java Fri Jan 21 09:56:06 2011 +0300 @@ -0,0 +1,60 @@ +package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; + +import jetbrains.buildServer.BaseTestCase; +import jetbrains.buildServer.TempFiles; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.LocalRepositoryUtil; +import jetbrains.buildServer.buildTriggers.vcs.mercurial.Util; +import jetbrains.buildServer.vcs.VcsException; +import jetbrains.buildServer.vcs.impl.VcsRootImpl; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.IOException; + +/** + * @author dmitry.neverov + */ +@Test +public class CloneCommandTest extends BaseTestCase { + + protected TempFiles myTempFiles; + + + @Override + @BeforeMethod + public void setUp() throws Exception { + myTempFiles = new TempFiles(); + } + + + @AfterMethod + public void tearDown() throws Exception { + myTempFiles.cleanup(); + } + + + public void clone_should_be_made_to_its_destination_dir() throws IOException, VcsException { + File repository = LocalRepositoryUtil.prepareRepository(new File("mercurial-tests/testData/rep1").getAbsolutePath()); + + VcsRootImpl root = new VcsRootImpl(1, "rootForTest"); + root.addProperty(Constants.REPOSITORY_PROP, repository.getAbsolutePath()); + root.addProperty(Constants.HG_COMMAND_PATH_PROP, Util.getHgPath()); + + File workingDir = myTempFiles.createTempDir(); + Settings settings = new Settings(workingDir.getParentFile(), root); + settings.setWorkingDir(workingDir); + + CloneCommand clone = new CloneCommand(settings); + clone.setDestDir(workingDir.getAbsolutePath()); + clone.execute(); + + String[] files = new String[] {".hg", "dir1", "dir with space", "file.txt"}; + for (String f : files) { + assertTrue(new File(workingDir, f).exists()); + } + } + +}