< prev index next >

bots/bridgekeeper/src/test/java/org/openjdk/skara/bots/bridgekeeper/PullRequestPrunerBotTests.java

Print this page
@@ -27,11 +27,11 @@
  import org.junit.jupiter.api.*;
  
  import java.io.IOException;
  import java.time.Duration;
  
- import static org.junit.jupiter.api.Assertions.assertEquals;
+ import static org.junit.jupiter.api.Assertions.*;
  
  class PullRequestPrunerBotTests {
      @Test
      void close(TestInfo testInfo) throws IOException, InterruptedException {
          try (var credentials = new HostCredentials(testInfo);

@@ -50,11 +50,31 @@
              var pr = credentials.createPullRequest(author, "master", "edit", "This is a pull request");
  
              // Make sure the timeout expires
              Thread.sleep(100);
  
-             // Let the bot see it
+             // Let the bot see it - it should give a notice
+             TestBotRunner.runPeriodicItems(bot);
+ 
+             assertEquals(1, pr.comments().size());
+             assertTrue(pr.comments().get(0).body().contains("will be automatically closed if"));
+ 
+             pr.addComment("I'm still working on it!");
+ 
+             // Make sure the timeout expires again
+             Thread.sleep(100);
+ 
+             // Let the bot see it - it should post a second notice
+             TestBotRunner.runPeriodicItems(bot);
+ 
+             assertEquals(3, pr.comments().size());
+             assertTrue(pr.comments().get(2).body().contains("will be automatically closed if"));
+ 
+             // Make sure the timeout expires again
+             Thread.sleep(100);
+ 
+             // The bot should now close it
              TestBotRunner.runPeriodicItems(bot);
  
              // There should now be no open PRs
              var prs = author.pullRequests();
              assertEquals(0, prs.size());
< prev index next >