1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
package org.jetbrains.plugins.github;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.components.ServiceManager;
import git4idea.commands.Git;
import org.jetbrains.plugins.github.api.GithubApiUtil;
import org.jetbrains.plugins.github.api.GithubRepoDetailed;
import org.jetbrains.plugins.github.util.GithubAuthData;
import java.io.IOException;
import static com.intellij.openapi.vcs.Executor.cd;
import static git4idea.test.GitExecutor.git;
/**
* @author Aleksey Pivovarov
*/
public class GithubShareProjectTest extends GithubShareProjectTestBase {
public void testSimple() throws Throwable {
registerDefaultShareDialogHandler();
registerDefaultUntrackedFilesDialogHandler();
createProjectFiles();
GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
checkNotification(NotificationType.INFORMATION, "Successfully shared project on GitHub", null);
initGitChecks();
checkGitExists();
checkGithubExists();
checkRemoteConfigured();
checkLastCommitPushed();
}
public void testGithubAlreadyExists() throws Throwable {
registerDefaultShareDialogHandler();
registerDefaultUntrackedFilesDialogHandler();
createProjectFiles();
GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
checkNotification(NotificationType.INFORMATION, "Project is already on GitHub", null);
}
public void testExistingGit() throws Throwable {
registerDefaultShareDialogHandler();
registerDefaultUntrackedFilesDialogHandler();
createProjectFiles();
cd(myProjectRoot.getPath());
git("init");
setGitIdentity(myProjectRoot);
git("add file.txt");
git("commit -m init");
GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
checkNotification(NotificationType.INFORMATION, "Successfully shared project on GitHub", null);
initGitChecks();
checkGitExists();
checkGithubExists();
checkRemoteConfigured();
checkLastCommitPushed();
}
public void testExistingFreshGit() throws Throwable {
registerDefaultShareDialogHandler();
registerDefaultUntrackedFilesDialogHandler();
createProjectFiles();
Git git = ServiceManager.getService(Git.class);
git.init(myProject, myProjectRoot);
GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
checkNotification(NotificationType.INFORMATION, "Successfully shared project on GitHub", null);
initGitChecks();
checkGitExists();
checkGithubExists();
checkRemoteConfigured();
checkLastCommitPushed();
}
public void testEmptyProject() throws Throwable {
registerDefaultUntrackedFilesDialogHandler();
registerDefaultShareDialogHandler();
GithubShareAction.shareProjectOnGithub(myProject, myProjectRoot);
checkNotification(NotificationType.INFORMATION, "Successfully created empty repository on GitHub", null);
initGitChecks();
checkGitExists();
checkGithubExists();
checkRemoteConfigured();
}
protected void checkGithubExists() throws IOException {
GithubAuthData auth = myGitHubSettings.getAuthData();
GithubRepoDetailed githubInfo = GithubApiUtil.getDetailedRepoInfo(auth, myLogin1, PROJECT_NAME);
assertNotNull("GitHub repository does not exist", githubInfo);
}
}
|