< prev index next >

bots/notify/src/test/java/org/openjdk/skara/bots/notify/UpdaterTests.java

Print this page
@@ -718,6 +718,44 @@
              assertEquals(email.recipients(), List.of(listAddress));
              assertEquals("git: test: created branch newbranch2 based on the branch newbranch1 containing 0 unique commits", email.subject());
              assertEquals("The new branch newbranch2 is currently identical to the newbranch1 branch.", email.body());
          }
      }
+ 
+     @Test
+     void testIssue(TestInfo testInfo) throws IOException {
+         try (var credentials = new HostCredentials(testInfo);
+              var tempFolder = new TemporaryDirectory()) {
+             var repo = credentials.getHostedRepository();
+             var repoFolder = tempFolder.path().resolve("repo");
+             var localRepo = CheckableRepository.init(repoFolder, repo.repositoryType());
+             credentials.commitLock(localRepo);
+             localRepo.pushAll(repo.url());
+ 
+             var tagStorage = createTagStorage(repo);
+             var branchStorage = createBranchStorage(repo);
+             var storageFolder = tempFolder.path().resolve("storage");
+ 
+             var issueProject = credentials.getIssueProject();
+             var updater = new IssueUpdater(issueProject);
+             var notifyBot = new JNotifyBot(repo, storageFolder, Pattern.compile("master"), tagStorage, branchStorage, List.of(updater));
+ 
+             // Initialize history
+             TestBotRunner.runPeriodicItems(notifyBot);
+ 
+             // Create an issue and commit a fix
+             var issue = issueProject.createIssue("This is an issue", List.of("Indeed"));
+             var editHash = CheckableRepository.appendAndCommit(localRepo, "Another line", issue.id() + ": Fix that issue");
+             localRepo.push(editHash, repo.url(), "master");
+             TestBotRunner.runPeriodicItems(notifyBot);
+ 
+             // The changeset should be reflected in a comment
+             var comments = issue.comments();
+             assertEquals(1, comments.size());
+             var comment = comments.get(0);
+             assertTrue(comment.body().contains(editHash.abbreviate()));
+ 
+             // There should be no open issues
+             assertEquals(0, issueProject.issues().size());
+         }
+     }
  }
< prev index next >