changeset 207:3819be43aa8d

Test we clone to the destination dir * * * Fix test * * * Run clone command test
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Fri, 21 Jan 2011 09:56:06 +0300
parents b7d0ddf3df33
children 27c4ba8c1a6b
files mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CloneCommandTest.java mercurial-tests/src/testng.xml
diffstat 2 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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,59 @@
+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(root);
+    settings.setCustomWorkingDir(workingDir);
+
+    CloneCommand clone = new CloneCommand(settings, workingDir);
+    clone.execute();
+
+    String[] files = new String[] {".hg", "dir1", "dir with space", "file.txt"};
+    for (String f : files) {
+      assertTrue(new File(workingDir, f).exists());
+    }
+  }
+
+}
--- a/mercurial-tests/src/testng.xml	Thu Mar 24 16:49:32 2011 +0300
+++ b/mercurial-tests/src/testng.xml	Fri Jan 21 09:56:06 2011 +0300
@@ -2,6 +2,7 @@
 <suite name="Mercurial Suite">
   <test name="Mercurial Tests">
     <classes>
+      <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CloneCommandTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.LogCommandTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.StatusCommandTest"/>
       <class name="jetbrains.buildServer.buildTriggers.vcs.mercurial.command.PushCommandTest"/>