@@ -382,4 +382,71 @@ void issueInBody(TestInfo testInfo) throws IOException {
382
382
assertTrue (pr .body ().contains ("## Issues\n " ));
383
383
}
384
384
}
385
+
386
+ @ Test
387
+ void projectPrefix (TestInfo testInfo ) throws IOException {
388
+ try (var credentials = new HostCredentials (testInfo );
389
+ var tempFolder = new TemporaryDirectory ()) {
390
+ var author = credentials .getHostedRepository ();
391
+ var integrator = credentials .getHostedRepository ();
392
+
393
+ var issueProject = credentials .getIssueProject ();
394
+ var censusBuilder = credentials .getCensusBuilder ()
395
+ .addAuthor (author .forge ().currentUser ().id ());
396
+ var prBot = PullRequestBot .newBuilder ()
397
+ .repo (integrator )
398
+ .censusRepo (censusBuilder .build ())
399
+ .issueProject (issueProject )
400
+ .build ();
401
+
402
+ // Populate the projects repository
403
+ var localRepo = CheckableRepository .init (tempFolder .path (), author .repositoryType ());
404
+ var masterHash = localRepo .resolve ("master" ).orElseThrow ();
405
+ assertFalse (CheckableRepository .hasBeenEdited (localRepo ));
406
+ localRepo .push (masterHash , author .url (), "master" , true );
407
+
408
+ // Create issues
409
+ var issue1 = credentials .createIssue (issueProject , "Issue 1" );
410
+ var issue2 = credentials .createIssue (issueProject , "Issue 2" );
411
+
412
+ // Make a change with a corresponding PR
413
+ var editHash = CheckableRepository .appendAndCommit (localRepo );
414
+ localRepo .push (editHash , author .url (), "edit" , true );
415
+ var pr = credentials .createPullRequest (author , "master" , "edit" , issue1 .id () + ": This is a pull request" );
416
+ TestBotRunner .runPeriodicItems (prBot );
417
+
418
+ // Add variations of this issue
419
+ pr .addComment ("/issue add " + issue2 .id ().toLowerCase ());
420
+ TestBotRunner .runPeriodicItems (prBot );
421
+
422
+ // The bot should reply with a success message
423
+ assertLastCommentContains (pr ,"Adding additional issue to issue list" );
424
+
425
+ pr .addComment ("/issue remove " + issue2 .id ().toLowerCase ());
426
+ TestBotRunner .runPeriodicItems (prBot );
427
+
428
+ // The bot should reply with a success message
429
+ assertLastCommentContains (pr ,"Removing additional issue from issue list" );
430
+
431
+ // Add variations of this issue
432
+ pr .addComment ("/issue add " + issue2 .id ().toUpperCase ());
433
+ TestBotRunner .runPeriodicItems (prBot );
434
+
435
+ // The bot should reply with a success message
436
+ assertLastCommentContains (pr ,"Adding additional issue to issue list" );
437
+
438
+ pr .addComment ("/issue remove " + issue2 .id ().toUpperCase ());
439
+ TestBotRunner .runPeriodicItems (prBot );
440
+
441
+ // The bot should reply with a success message
442
+ assertLastCommentContains (pr ,"Removing additional issue from issue list" );
443
+
444
+ // Add variations of this issue
445
+ pr .addComment ("/issue add " + issue2 .id ().split ("-" )[1 ]);
446
+ TestBotRunner .runPeriodicItems (prBot );
447
+
448
+ // The bot should reply with a success message
449
+ assertLastCommentContains (pr ,"Adding additional issue to issue list" );
450
+ }
451
+ }
385
452
}
1 commit comments
bridgekeeper[bot] commentedon Jun 17, 2020
Review
Issues