@@ -4,7 +4,7 @@ import XCTest
44final class ChangelogProducerTests : XCTestCase {
55
66 /// It should extract pull request IDs from squash merges.
7- func testPullRequestIDsFromSquashCommits( ) throws {
7+ func testPullRequestIDsFromSquashCommits( ) {
88 let gitLogOutput = """
99 * Fix bucket deeplinking after adding content (#5130) via Antoine van der Lee
1010 * Fix CI for Coyote #trivial (#5114) via Antoine van der Lee
@@ -14,16 +14,49 @@ final class ChangelogProducerTests: XCTestCase {
1414 }
1515
1616 /// It should extract pull request from merge commits.
17- func testPullRequestIDsFromMergeCommits( ) throws {
18- let gitLogOutput = """
19- * Merge pull request #65 from BalestraPatrick/profiles-devices-endpoints via Antoine van der Lee
20- * Merge pull request #62 from hexagons/issue/42 via Antoine van der Lee
21- """
22- XCTAssertEqual ( gitLogOutput. pullRequestIDs ( ) , [ 62 , 65 ] )
17+ func testPullRequestIDsFromMergeCommits( ) {
18+ let gitLogOutput = """
19+ * Merge pull request #65 from BalestraPatrick/profiles-devices-endpoints via Antoine van der Lee
20+ * Merge pull request #62 from hexagons/issue/42 via Antoine van der Lee
21+ """
22+ XCTAssertEqual ( gitLogOutput. pullRequestIDs ( ) , [ 62 , 65 ] )
23+ }
24+
25+ /// It should extract the fixed issue from the Pull Request body.
26+ func testResolvingReferencedIssue( ) {
27+ // See this code as an example: https://github.com/fastlane/issue-bot/blob/457348717d99e5ffde34ca1619e7253ed51ec172/bot.rb#L456
28+
29+ let issueClosingKeywords = [
30+ " close " ,
31+ " Closes " ,
32+ " closed " ,
33+ " fix " ,
34+ " fixes " ,
35+ " Fixed " ,
36+ " resolve " ,
37+ " Resolves " ,
38+ " resolved "
39+ ]
40+
41+ issueClosingKeywords. forEach { ( closingKeyword) in
42+ let description = examplePullRequestDescriptionUsing ( closingKeyword: closingKeyword)
43+ XCTAssertEqual ( description. resolvingIssue ( ) , 4343 )
2344 }
45+ }
2446
2547 static var allTests = [
2648 ( " testPullRequestIDsFromSquashCommits " , testPullRequestIDsFromSquashCommits) ,
2749 ( " testPullRequestIDsFromMergeCommits " , testPullRequestIDsFromMergeCommits)
2850 ]
2951}
52+
53+ extension ChangelogProducerTests {
54+ func examplePullRequestDescriptionUsing( closingKeyword: String ) -> String {
55+ return """
56+ This PR does a lot of awesome stuff.
57+
58+ \( closingKeyword) #4343
59+ """
60+
61+ }
62+ }
0 commit comments