github: fix test
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Thu, 3 Sep 2015 11:54:45 +0000 (14:54 +0300)
committerAleksey Pivovarov <AMPivovarov@gmail.com>
Thu, 3 Sep 2015 13:20:18 +0000 (16:20 +0300)
plugins/github/test/org/jetbrains/plugins/github/GithubCreatePullRequestTestBase.java
plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTest.java
plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTestBase.java

index 1c0404be928018a414e2d71366b893df814eede5..b5fd5994a8b25a90ce242b76c4f79f809802347f 100644 (file)
@@ -85,7 +85,12 @@ public abstract class GithubCreatePullRequestTestBase extends GithubTest {
   }
 
   protected void cloneRepo() {
-    git("clone " + PROJECT_URL + " .");
+    // project dir can be not empty
+    git("init");
+    git("remote add origin " + PROJECT_URL);
+    git("fetch");
+    git("checkout -t origin/master");
+
     setGitIdentity(myProjectRoot);
     GitInit.refreshAndConfigureVcsMappings(myProject, myProjectRoot, myProjectRoot.getPath());
   }
index 51fb700e7d2988d6ed1dac2e1085795fdcc95cce..90c4d2d8fbdb75461d0fb327c37083043a5c37e9 100644 (file)
@@ -104,7 +104,7 @@ public class GithubShareProjectTest extends GithubShareProjectTestBase {
   }
 
   public void testEmptyProject() throws Throwable {
-    registerDefaultUntrackedFilesDialogHandler();
+    registerSelectNoneUntrackedFilesDialogHandler();
     registerDefaultShareDialogHandler();
 
     GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
index ea07ca1eaf1d686bb597da377d0fbeadcbbc81fe..7b76930cca4998223fe0133a67856b46774df1d5 100644 (file)
@@ -17,6 +17,7 @@ package org.jetbrains.plugins.github;
 
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.util.Clock;
+import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.text.DateFormatUtil;
 import git4idea.GitUtil;
 import git4idea.repo.GitRepository;
@@ -27,6 +28,7 @@ import org.jetbrains.plugins.github.test.GithubTest;
 import org.jetbrains.plugins.github.ui.GithubShareDialog;
 
 import java.io.IOException;
+import java.util.Collections;
 import java.util.Random;
 
 /**
@@ -75,4 +77,19 @@ public abstract class GithubShareProjectTestBase extends GithubTest {
                                             }
                                           });
   }
+
+  protected void registerSelectNoneUntrackedFilesDialogHandler() {
+    myDialogManager.registerDialogHandler(GithubShareAction.GithubUntrackedFilesDialog.class,
+                                          new TestDialogHandler<GithubShareAction.GithubUntrackedFilesDialog>() {
+                                            @Override
+                                            public int handleDialog(GithubShareAction.GithubUntrackedFilesDialog dialog) {
+                                              // actually we should ask user for name/email ourselves (like in CommitDialog)
+                                              for (GitRepository repository : GitUtil.getRepositoryManager(myProject).getRepositories()) {
+                                                setGitIdentity(repository.getRoot());
+                                              }
+                                              dialog.setSelectedFiles(Collections.<VirtualFile>emptyList());
+                                              return DialogWrapper.OK_EXIT_CODE;
+                                            }
+                                          });
+  }
 }