16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package org.openjdk.skara.bots.bridgekeeper;
24
25 import org.openjdk.skara.test.*;
26
27 import org.junit.jupiter.api.*;
28
29 import java.io.IOException;
30 import java.time.Duration;
31
32 import static org.junit.jupiter.api.Assertions.assertEquals;
33
34 class PullRequestPrunerBotTests {
35 @Test
36 void close(TestInfo testInfo) throws IOException {
37 try (var credentials = new HostCredentials(testInfo);
38 var tempFolder = new TemporaryDirectory()) {
39 var author = credentials.getHostedRepository();
40 var bot = new PullRequestPrunerBot(author, Duration.ofMillis(1));
41
42 // Populate the projects repository
43 var localRepo = CheckableRepository.init(tempFolder.path(), author.repositoryType());
44 var masterHash = localRepo.resolve("master").orElseThrow();
45 localRepo.push(masterHash, author.url(), "master", true);
46
47 // Make a change with a corresponding PR
48 var editHash = CheckableRepository.appendAndCommit(localRepo);
49 localRepo.push(editHash, author.url(), "edit", true);
50 var pr = credentials.createPullRequest(author, "master", "edit", "This is a pull request");
51
52 // Let the bot see it
53 TestBotRunner.runPeriodicItems(bot);
54
55 // There should now be no open PRs
56 var prs = author.pullRequests();
57 assertEquals(0, prs.size());
58 }
59 }
60
61 @Test
62 void dontClose(TestInfo testInfo) throws IOException {
63 try (var credentials = new HostCredentials(testInfo);
64 var tempFolder = new TemporaryDirectory()) {
65 var author = credentials.getHostedRepository();
66 var bot = new PullRequestPrunerBot(author, Duration.ofDays(3));
67
68 // Populate the projects repository
69 var localRepo = CheckableRepository.init(tempFolder.path(), author.repositoryType());
70 var masterHash = localRepo.resolve("master").orElseThrow();
71 localRepo.push(masterHash, author.url(), "master", true);
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package org.openjdk.skara.bots.bridgekeeper;
24
25 import org.openjdk.skara.test.*;
26
27 import org.junit.jupiter.api.*;
28
29 import java.io.IOException;
30 import java.time.Duration;
31
32 import static org.junit.jupiter.api.Assertions.assertEquals;
33
34 class PullRequestPrunerBotTests {
35 @Test
36 void close(TestInfo testInfo) throws IOException, InterruptedException {
37 try (var credentials = new HostCredentials(testInfo);
38 var tempFolder = new TemporaryDirectory()) {
39 var author = credentials.getHostedRepository();
40 var bot = new PullRequestPrunerBot(author, Duration.ofMillis(1));
41
42 // Populate the projects repository
43 var localRepo = CheckableRepository.init(tempFolder.path(), author.repositoryType());
44 var masterHash = localRepo.resolve("master").orElseThrow();
45 localRepo.push(masterHash, author.url(), "master", true);
46
47 // Make a change with a corresponding PR
48 var editHash = CheckableRepository.appendAndCommit(localRepo);
49 localRepo.push(editHash, author.url(), "edit", true);
50 var pr = credentials.createPullRequest(author, "master", "edit", "This is a pull request");
51
52 // Make sure the timeout expires
53 Thread.sleep(100);
54
55 // Let the bot see it
56 TestBotRunner.runPeriodicItems(bot);
57
58 // There should now be no open PRs
59 var prs = author.pullRequests();
60 assertEquals(0, prs.size());
61 }
62 }
63
64 @Test
65 void dontClose(TestInfo testInfo) throws IOException {
66 try (var credentials = new HostCredentials(testInfo);
67 var tempFolder = new TemporaryDirectory()) {
68 var author = credentials.getHostedRepository();
69 var bot = new PullRequestPrunerBot(author, Duration.ofDays(3));
70
71 // Populate the projects repository
72 var localRepo = CheckableRepository.init(tempFolder.path(), author.repositoryType());
73 var masterHash = localRepo.resolve("master").orElseThrow();
74 localRepo.push(masterHash, author.url(), "master", true);
|