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
|
// Copyright (C) 2018 The Qt Company
package com.googlesource.gerrit.plugins.qtcodereview;
import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.RestResponse;
import com.google.gerrit.acceptance.TestPlugin;
import com.google.gerrit.acceptance.UseSsh;
import com.google.gerrit.reviewdb.client.Change;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Test;
@TestPlugin(
name = "gerrit-plugin-qt-workflow",
sysModule = "com.googlesource.gerrit.plugins.qtcodereview.QtModule",
sshModule = "com.googlesource.gerrit.plugins.qtcodereview.QtSshModule"
)
@UseSsh
public class QtCodeReviewIT extends LightweightPluginDaemonTest {
protected static final String R_HEADS = "refs/heads/";
protected static final String R_STAGING = "refs/staging/";
protected static final String R_PUSH = "refs/for/";
@Test
public void pingSSHTest() throws Exception {
assertThat(adminSshSession.exec("gerrit-plugin-qt-workflow ping")).contains("Pong");
assertThat(adminSshSession.getError()).isNull();
}
// Helper functions
protected void QtDefer(PushOneCommit.Result c) throws Exception {
RestResponse response = call_REST_API_Defer(c.getChangeId());
response.assertOK();
}
protected RestResponse call_REST_API_Defer(String changeId) throws Exception {
String url = "/changes/"+changeId+"/gerrit-plugin-qt-workflow~defer";
RestResponse response = userRestSession.post(url);
return response;
}
protected PushOneCommit.Result pushCommit(String branch,
String message,
String file,
String content)
throws Exception {
String pushRef = R_PUSH + branch;
PushOneCommit.Result c = createUserChange(pushRef, message, file, content);
Change change = c.getChange().change();
assertThat(change.getStatus()).isEqualTo(Change.Status.NEW);
return c;
}
protected PushOneCommit.Result createUserChange(String ref, String message, String file, String content) throws Exception {
PushOneCommit push = pushFactory.create(db, user.getIdent(), testRepo, message, file, content);
PushOneCommit.Result result = push.to(ref);
result.assertOkStatus();
return result;
}
protected void assertRefUpdatedEvents(String refName, RevCommit ... expected) throws Exception {
eventRecorder.assertRefUpdatedEvents(project.get(), refName, expected);
}
}
|