/
AbstractGitTestCase.java
68 lines (53 loc) · 1.91 KB
/
AbstractGitTestCase.java
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
package hudson.plugins.git;
import hudson.FilePath;
import hudson.model.TaskListener;
import hudson.util.StreamTaskListener;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.eclipse.jgit.lib.PersonIdent;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.jvnet.hudson.test.HudsonTestCase;
/**
* Base class for single repository git plugin tests.
*
* @author Kohsuke Kawaguchi
* @author ishaaq
*/
public abstract class AbstractGitTestCase extends HudsonTestCase {
protected TaskListener listener;
protected TestGitRepo testRepo;
// aliases of testRepo properties
protected PersonIdent johnDoe;
protected PersonIdent janeDoe;
protected File workDir; // aliases "gitDir"
protected FilePath workspace; // aliases "gitDirPath"
protected GitClient git;
@Override
protected void setUp() throws Exception {
super.setUp();
listener = StreamTaskListener.fromStderr();
testRepo = new TestGitRepo("unnamed", this, listener);
johnDoe = testRepo.johnDoe;
janeDoe = testRepo.janeDoe;
workDir = testRepo.gitDir;
workspace = testRepo.gitDirPath;
git = testRepo.git;
}
protected void setAuthor(final PersonIdent author) {
testRepo.setAuthor(author);
}
protected void setCommitter(final PersonIdent committer) {
testRepo.setCommitter(committer);
}
protected void commit(final String fileName, final PersonIdent committer, final String message) throws GitException {
testRepo.commit(fileName, committer, message);
}
protected void commit(final String fileName, final PersonIdent author, final PersonIdent committer,
final String message) throws GitException {
testRepo.commit(fileName, author, committer, message);
}
protected List<UserRemoteConfig> createRemoteRepositories() throws IOException {
return testRepo.remoteConfigs();
}
}