Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | # |
| 3 | # Copyright (C) 2020 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | import unittest |
| 19 | import os |
| 20 | from GitClient import * |
Nick Anthony | 917014b | 2020-05-08 08:24:09 -0400 | [diff] [blame] | 21 | from AndroidXMarkdown import * |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 22 | |
| 23 | class GitClientTestImpl(GitClient): |
| 24 | def __init__(self, workingDir): |
| 25 | self.workingDir = workingDir |
| 26 | self.gitRoot = self.findGitDirInParentFilepath(workingDir) |
| 27 | if self.gitRoot == None: |
| 28 | self.gitRoot = workingDir |
| 29 | self.commandReplies = {} |
| 30 | |
| 31 | def executeCommand(self, command): |
| 32 | if command in self.commandReplies: |
| 33 | return self.commandReplies[command] |
| 34 | else: |
| 35 | print_e('FAILED: The following command was not given a reply for the mock GitClient: \n%s\n ' % command) |
| 36 | return None |
| 37 | |
| 38 | def addReply(self, command, reply): |
| 39 | self.commandReplies[command] = reply |
| 40 | |
| 41 | class TestGitClient(unittest.TestCase): |
| 42 | |
| 43 | def test_gitClientFindsGitDir(self): |
| 44 | gitClient = GitClientTestImpl(os.getcwd()) |
| 45 | self.assertTrue(os.path.exists(gitClient.gitRoot + "/.git")) |
| 46 | |
| 47 | def test_parseMalformattedReleaseNoteLine(self): |
| 48 | projectDir = "group/artifact" |
| 49 | commitWithABugFixString = """ |
| 50 | _CommitStart |
| 51 | Here is an explanation of my commit that changes a kotlin file |
| 52 | |
| 53 | Relnote: "Missing close quote in the release note block. |
| 54 | This is the second line of the release notes. It should not be included in the |
| 55 | release notes because this commit is missing the closing quote. |
| 56 | |
| 57 | Bug: 111111, 222222 |
| 58 | Test: ./gradlew buildOnServer |
| 59 | Change-Id: myChangeId |
| 60 | """ + \ |
| 61 | projectDir + "/a.java" |
| 62 | commitWithABugFix = Commit( |
| 63 | commitWithABugFixString, |
| 64 | projectDir |
| 65 | ) |
| 66 | self.assertEqual( |
| 67 | "Missing close quote in the release note block.", |
| 68 | commitWithABugFix.releaseNote |
| 69 | ) |
| 70 | |
| 71 | def test_parseAPICommitWithMultiLineReleaseNote(self): |
| 72 | commitWithApiChangeString = """ |
| 73 | _CommitStart |
| 74 | _CommitSHA:mySha |
| 75 | _Author:[email protected] |
| 76 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 77 | _Subject:Added a new API! |
| 78 | _Body:Also fixed some other bugs |
| 79 | |
| 80 | Here is an explanation of my commit |
| 81 | |
| 82 | "This is a quote about why it's great!" |
| 83 | |
| 84 | Relnote: "Added a new API that does something awesome and does a whole bunch |
| 85 | of other things that are also awesome and I just can't elaborate enough how |
| 86 | incredible this API is" |
| 87 | |
| 88 | "This is an extra set of quoted text" |
| 89 | |
| 90 | Bug: 123456 |
| 91 | Bug: b/1234567 |
| 92 | Fixes: 123123 |
| 93 | Test: ./gradlew buildOnServer |
| 94 | |
| 95 | Change-Id: myChangeId |
| 96 | |
| 97 | projectdir/a.java |
| 98 | projectdir/b.java |
| 99 | projectdir/androidTest/c.java |
| 100 | projectdir/api/some_api_file.txt |
| 101 | projectdir/api/current.txt |
| 102 | """ |
| 103 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 104 | self.assertEqual("mySha", commitWithApiChange.sha) |
| 105 | self.assertEqual("[email protected]", commitWithApiChange.authorEmail) |
| 106 | self.assertEqual("myChangeId", commitWithApiChange.changeId) |
| 107 | self.assertEqual("Added a new API!", commitWithApiChange.summary) |
| 108 | self.assertEqual(CommitType.API_CHANGE, commitWithApiChange.changeType) |
| 109 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 110 | self.assertEqual([ |
| 111 | "projectdir/a.java", |
| 112 | "projectdir/b.java", |
| 113 | "projectdir/androidTest/c.java", |
| 114 | "projectdir/api/some_api_file.txt", |
| 115 | "projectdir/api/current.txt" |
| 116 | ], |
| 117 | commitWithApiChange.files |
| 118 | ) |
| 119 | self.assertEqual( |
| 120 | "Added a new API that does something awesome and does a whole bunch\n" + |
| 121 | " of other things that are also awesome and I just can't elaborate " + |
| 122 | "enough how\n incredible this API is", |
| 123 | commitWithApiChange.releaseNote |
| 124 | ) |
| 125 | |
Nick Anthony | 333b2e6 | 2020-07-24 09:03:55 -0400 | [diff] [blame] | 126 | def test_parseCommitWithMultiLineTripleQuoteReleaseNote(self): |
| 127 | commitWithApiChangeString = ''' |
| 128 | _CommitStart |
| 129 | _CommitSHA:mySha |
| 130 | _Author:[email protected] |
| 131 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 132 | _Subject:Added a new API! |
| 133 | _Body:Also fixed some other bugs |
| 134 | |
| 135 | Here is an explanation of my commit |
| 136 | |
| 137 | "This is a quote about why it's great!" |
| 138 | |
| 139 | Relnote: """Added a new API that does something awesome and does a whole bunch |
| 140 | of other things that are also awesome and I just can't elaborate enough how |
| 141 | incredible this API is""" |
| 142 | |
| 143 | "This is an extra set of quoted text" |
| 144 | |
| 145 | Bug: 123456 |
| 146 | Test: ./gradlew buildOnServer |
| 147 | |
| 148 | Change-Id: myChangeId |
| 149 | |
| 150 | projectdir/a.java |
| 151 | ''' |
| 152 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 153 | self.assertEqual( |
| 154 | "Added a new API that does something awesome and does a whole bunch\n" + |
| 155 | " " + |
| 156 | "of other things that are also awesome and I just can't elaborate enough how\n" + |
| 157 | " " + |
| 158 | "incredible this API is", |
| 159 | commitWithApiChange.releaseNote |
| 160 | ) |
| 161 | |
| 162 | def test_parseCommitWithTripleQuoteReleaseNoteWithContainedQuotes(self): |
| 163 | commitWithApiChangeString = ''' |
| 164 | _CommitStart |
| 165 | _CommitSHA:mySha |
| 166 | _Author:[email protected] |
| 167 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 168 | _Subject:Added a new API! |
| 169 | _Body:Also fixed some other bugs |
| 170 | |
| 171 | Here is an explanation of my commit |
| 172 | |
| 173 | "This is a quote about why it's great!" |
| 174 | |
| 175 | Relnote: """ |
| 176 | Added a new API `myFoo`. This means you can now |
| 177 | call `myFoo("bar")` instead of `myFooBar("barbar").myBaz()`. |
| 178 | """ |
| 179 | |
| 180 | "This is an extra set of quoted text" |
| 181 | |
| 182 | Bug: 123456 |
| 183 | Test: ./gradlew buildOnServer |
| 184 | |
| 185 | Change-Id: myChangeId |
| 186 | |
| 187 | projectdir/a.java |
| 188 | ''' |
| 189 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 190 | self.assertEqual( |
| 191 | 'Added a new API `myFoo`. This means you can now\n' + |
| 192 | ' ' + |
| 193 | 'call `myFoo("bar")` instead of `myFooBar("barbar").myBaz()`.', |
| 194 | commitWithApiChange.releaseNote |
| 195 | ) |
| 196 | |
| 197 | def test_parseCommitWithOneLineTripleQuoteReleaseNote(self): |
| 198 | commitWithApiChangeString = ''' |
| 199 | _CommitStart |
| 200 | _CommitSHA:mySha |
| 201 | _Author:[email protected] |
| 202 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 203 | _Subject:Added a new API! |
| 204 | _Body:Also fixed some other bugs |
| 205 | |
| 206 | Here is an explanation of my commit |
| 207 | |
| 208 | "This is a quote about why it's great!" |
| 209 | |
| 210 | Relnote: """Added a new API!""" |
| 211 | |
| 212 | "This is an extra set of quoted text" |
| 213 | |
| 214 | Bug: 123456 |
| 215 | Test: ./gradlew buildOnServer |
| 216 | |
| 217 | Change-Id: myChangeId |
| 218 | |
| 219 | projectdir/a.java |
| 220 | ''' |
| 221 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 222 | self.assertEqual( |
| 223 | "Added a new API!", |
| 224 | commitWithApiChange.releaseNote |
| 225 | ) |
| 226 | |
| 227 | def test_parseCommitWithTripleQuoteAndBackslashQuoteReleaseNote(self): |
| 228 | commitWithApiChangeString = ''' |
| 229 | _CommitStart |
| 230 | _CommitSHA:mySha |
| 231 | _Author:[email protected] |
| 232 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 233 | _Subject:Added a new API! |
| 234 | _Body:Also fixed some other bugs |
| 235 | |
| 236 | Here is an explanation of my commit |
| 237 | |
| 238 | "This is a quote about why it's great!" |
| 239 | |
| 240 | Relnote: """ |
| 241 | Added a new API `myFoo`. This means you can now |
| 242 | call `myFoo("bar")` instead of `myFooBar("barbar").myBaz()`. |
| 243 | """ |
| 244 | |
| 245 | "This is an extra set of quoted text" |
| 246 | |
| 247 | Bug: 123456 |
| 248 | Test: ./gradlew buildOnServer |
| 249 | |
| 250 | Change-Id: myChangeId |
| 251 | |
| 252 | projectdir/a.java |
| 253 | ''' |
| 254 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 255 | self.assertEqual( |
| 256 | 'Added a new API `myFoo`. This means you can now\n' + |
| 257 | ' ' + |
| 258 | 'call `myFoo("bar")` instead of `myFooBar("barbar").myBaz()`.', |
| 259 | commitWithApiChange.releaseNote |
| 260 | ) |
| 261 | |
| 262 | commitWithEdgeCaseRelnoteChangeString = ''' |
| 263 | _CommitStart |
| 264 | _CommitSHA:mySha |
| 265 | _Author:[email protected] |
| 266 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 267 | _Subject:Added a new API! |
| 268 | _Body:Also fixed some other bugs |
| 269 | |
| 270 | Here is an explanation of my commit |
| 271 | |
| 272 | "This is a quote about why it's great!" |
| 273 | |
| 274 | Relnote: """Testing that \\"quotes\\" work when we put ten of them in the \\"message\\" """ |
| 275 | |
| 276 | "This is an extra set of quoted text" |
| 277 | |
| 278 | Bug: 123456 |
| 279 | Test: ./gradlew buildOnServer |
| 280 | |
| 281 | Change-Id: myChangeId |
| 282 | |
| 283 | projectdir/a.java |
| 284 | ''' |
| 285 | commitWithEdgeCaseRelnoteChange = Commit(commitWithEdgeCaseRelnoteChangeString, "/projectdir/") |
| 286 | self.assertEqual( |
| 287 | 'Testing that "quotes" work when we put ten of them in the "message"', |
| 288 | commitWithEdgeCaseRelnoteChange.releaseNote |
| 289 | ) |
| 290 | |
| 291 | def test_parseCommitWithOneLineAndBackslashQuoteReleaseNote(self): |
| 292 | commitWithIOneLineEdgeCaseRelnoteChangeString = ''' |
| 293 | _CommitStart |
| 294 | _CommitSHA:mySha |
| 295 | _Author:[email protected] |
| 296 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 297 | _Subject:Added a new API! |
| 298 | _Body:Also fixed some other bugs |
| 299 | |
| 300 | Here is an explanation of my commit |
| 301 | |
| 302 | "This is a quote about why it's great!" |
| 303 | |
| 304 | Relnote: Testing that escaped quoted work on one \\"line\\" |
| 305 | |
| 306 | "This is an extra set of quoted text" |
| 307 | |
| 308 | Bug: 123456 |
| 309 | Test: ./gradlew buildOnServer |
| 310 | |
| 311 | Change-Id: myChangeId |
| 312 | |
| 313 | projectdir/a.java |
| 314 | ''' |
| 315 | commitWithIOneLineEdgeCaseRelnoteChange = Commit(commitWithIOneLineEdgeCaseRelnoteChangeString, "/projectdir/") |
| 316 | self.assertEqual( |
| 317 | 'Testing that escaped quoted work on one "line"', |
| 318 | commitWithIOneLineEdgeCaseRelnoteChange.releaseNote |
| 319 | ) |
| 320 | |
| 321 | commitWithIOneLineTrailingBackslashRelnoteChangeString = ''' |
| 322 | _CommitStart |
| 323 | _CommitSHA:mySha |
| 324 | _Author:[email protected] |
| 325 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 326 | _Subject:Added a new API! |
| 327 | _Body:Also fixed some other bugs |
| 328 | |
| 329 | Here is an explanation of my commit |
| 330 | |
| 331 | "This is a quote about why it's great!" |
| 332 | |
| 333 | Relnote: Testing that we handle trailing back slashes properly \\ |
| 334 | |
| 335 | Bug: 123456 |
| 336 | Test: ./gradlew buildOnServer |
| 337 | |
| 338 | Change-Id: myChangeId |
| 339 | |
| 340 | projectdir/a.java |
| 341 | ''' |
| 342 | commitWithIOneLineTrailingBackslashRelnoteChange = Commit(commitWithIOneLineTrailingBackslashRelnoteChangeString, "/projectdir/") |
| 343 | self.assertEqual( |
| 344 | 'Testing that we handle trailing back slashes properly \\', |
| 345 | commitWithIOneLineTrailingBackslashRelnoteChange.releaseNote |
| 346 | ) |
| 347 | |
| 348 | commitWithIOneLineMalformattedRelnoteChangeString = ''' |
| 349 | _CommitStart |
| 350 | _CommitSHA:mySha |
| 351 | _Author:[email protected] |
| 352 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 353 | _Subject:Added a new API! |
| 354 | _Body:Also fixed some other bugs |
| 355 | |
| 356 | Here is an explanation of my commit |
| 357 | |
| 358 | "This is a quote about why it's great!" |
| 359 | |
| 360 | Relnote: "Testing that we handle trailing back slashes properly \\" |
| 361 | |
| 362 | Bug: 123456 |
| 363 | Test: ./gradlew buildOnServer |
| 364 | |
| 365 | Change-Id: myChangeId |
| 366 | |
| 367 | projectdir/a.java |
| 368 | ''' |
| 369 | commitWithIOneLineMalformattedRelnoteChange = Commit(commitWithIOneLineMalformattedRelnoteChangeString, "/projectdir/") |
| 370 | self.assertEqual( |
| 371 | 'Testing that we handle trailing back slashes properly \"', |
| 372 | commitWithIOneLineMalformattedRelnoteChange.releaseNote |
| 373 | ) |
| 374 | |
| 375 | def test_parseCommitWithSingleQuoteAndBackslashQuoteReleaseNote(self): |
| 376 | commitWithApiChangeString = ''' |
| 377 | _CommitStart |
| 378 | _CommitSHA:mySha |
| 379 | _Author:[email protected] |
| 380 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 381 | _Subject:Added a new API! |
| 382 | _Body:Also fixed some other bugs |
| 383 | |
| 384 | Here is an explanation of my commit |
| 385 | |
| 386 | "This is a quote about why it's great!" |
| 387 | |
| 388 | Relnote: " |
| 389 | Added a new API `myFoo`. This means you can now |
| 390 | call `myFoo(\\"bar\\")` instead of `myFooBar(\\"barbar\\").myBaz()`. |
| 391 | " |
| 392 | |
| 393 | "This is an extra set of quoted text" |
| 394 | |
| 395 | Bug: 123456 |
| 396 | Test: ./gradlew buildOnServer |
| 397 | |
| 398 | Change-Id: myChangeId |
| 399 | |
| 400 | projectdir/a.java |
| 401 | ''' |
| 402 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 403 | self.assertEqual( |
| 404 | 'Added a new API `myFoo`. This means you can now\n' + |
| 405 | ' ' + |
| 406 | 'call `myFoo("bar")` instead of `myFooBar("barbar").myBaz()`.', |
| 407 | commitWithApiChange.releaseNote |
| 408 | ) |
| 409 | |
| 410 | commitWithEdgeCaseRelnoteChangeString = ''' |
| 411 | _CommitStart |
| 412 | _CommitSHA:mySha |
| 413 | _Author:[email protected] |
| 414 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 415 | _Subject:Added a new API! |
| 416 | _Body:Also fixed some other bugs |
| 417 | |
| 418 | Here is an explanation of my commit |
| 419 | |
| 420 | "This is a quote about why it's great!" |
| 421 | |
| 422 | Relnote: "Testing that \\"quotes\\" work when we put six of them in the \\"message\\"" |
| 423 | |
| 424 | "This is an extra set of quoted text" |
| 425 | |
| 426 | Bug: 123456 |
| 427 | Test: ./gradlew buildOnServer |
| 428 | |
| 429 | Change-Id: myChangeId |
| 430 | |
| 431 | projectdir/a.java |
| 432 | ''' |
| 433 | commitWithEdgeCaseRelnoteChange = Commit(commitWithEdgeCaseRelnoteChangeString, "/projectdir/") |
| 434 | self.assertEqual( |
| 435 | 'Testing that "quotes" work when we put six of them in the "message"', |
| 436 | commitWithEdgeCaseRelnoteChange.releaseNote |
| 437 | ) |
| 438 | |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 439 | def test_parseAPICommitWithDefaultDelimiters(self): |
| 440 | commitWithApiChangeString = """ |
| 441 | _CommitStart |
| 442 | _CommitSHA:mySha |
| 443 | _Author:[email protected] |
| 444 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 445 | _Subject:Added a new API! |
| 446 | _Body:Also fixed some other bugs |
| 447 | |
| 448 | Here is an explanation of my commit |
| 449 | |
| 450 | "This is a quote about why it's great!" |
| 451 | |
| 452 | Bug: 123456 |
| 453 | Bug: b/1234567 |
| 454 | Fixes: 123123 |
| 455 | Test: ./gradlew buildOnServer |
| 456 | |
| 457 | Relnote: Added an awesome new API! |
| 458 | |
| 459 | Change-Id: myChangeId |
| 460 | |
| 461 | projectdir/a.java |
| 462 | projectdir/b.java |
| 463 | projectdir/androidTest/c.java |
| 464 | projectdir/api/some_api_file.txt |
| 465 | projectdir/api/current.txt |
| 466 | """ |
| 467 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 468 | self.assertEqual("mySha", commitWithApiChange.sha) |
| 469 | self.assertEqual("[email protected]", commitWithApiChange.authorEmail) |
| 470 | self.assertEqual("myChangeId", commitWithApiChange.changeId) |
| 471 | self.assertEqual("Added a new API!", commitWithApiChange.summary) |
| 472 | self.assertEqual(CommitType.API_CHANGE, commitWithApiChange.changeType) |
| 473 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 474 | self.assertEqual([ |
| 475 | "projectdir/a.java", |
| 476 | "projectdir/b.java", |
| 477 | "projectdir/androidTest/c.java", |
| 478 | "projectdir/api/some_api_file.txt", |
| 479 | "projectdir/api/current.txt" |
| 480 | ], |
| 481 | commitWithApiChange.files |
| 482 | ) |
| 483 | self.assertEqual("Added an awesome new API!", commitWithApiChange.releaseNote) |
Nick Anthony | 4c1cad7 | 2020-06-07 18:26:37 -0400 | [diff] [blame] | 484 | self.assertEqual( |
| 485 | "Added a new API! ([myChan]" + |
| 486 | "(https://android-review.googlesource.com/#/q/myChangeId), " + |
| 487 | "[b/123456](https://issuetracker.google.com/issues/123456), " + |
| 488 | "[b/1234567](https://issuetracker.google.com/issues/1234567), " + |
| 489 | "[b/123123](https://issuetracker.google.com/issues/123123))", |
| 490 | str(commitWithApiChange) |
| 491 | ) |
| 492 | |
| 493 | def test_parseAPICommitWithOneBug(self): |
| 494 | commitWithApiChangeString = """ |
| 495 | _CommitStart |
| 496 | _CommitSHA:mySha |
| 497 | _Author:[email protected] |
| 498 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 499 | _Subject:Added a new API! |
| 500 | _Body:Also fixed some other bugs |
| 501 | |
| 502 | Relnote: Added an awesome new API! |
| 503 | |
| 504 | Bug: 123456 |
| 505 | Test: ./gradlew buildOnServer |
| 506 | Change-Id: myChangeId |
| 507 | |
| 508 | projectdir/a.java |
| 509 | projectdir/api/current.txt |
| 510 | """ |
| 511 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 512 | self.assertEqual("Added an awesome new API!", commitWithApiChange.releaseNote) |
| 513 | self.assertEqual([123456], commitWithApiChange.bugs) |
| 514 | self.assertEqual( |
| 515 | "Added a new API! ([myChan]" + |
| 516 | "(https://android-review.googlesource.com/#/q/myChangeId), " + |
| 517 | "[b/123456](https://issuetracker.google.com/issues/123456))", |
| 518 | str(commitWithApiChange) |
| 519 | ) |
| 520 | |
| 521 | def test_parseAPICommitWithMultipleBugs(self): |
| 522 | commitWithApiChangeString = """ |
| 523 | _CommitStart |
| 524 | _CommitSHA:mySha |
| 525 | _Author:[email protected] |
| 526 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 527 | _Subject:Added a new API! |
| 528 | _Body:Also fixed some other bugs |
| 529 | |
| 530 | Relnote: Added an awesome new API! |
| 531 | |
| 532 | Bug: 123456, 1234567 |
| 533 | Fixes: 123123 |
| 534 | Test: ./gradlew buildOnServer |
| 535 | Change-Id: myChangeId |
| 536 | |
| 537 | projectdir/a.java |
| 538 | projectdir/api/current.txt |
| 539 | """ |
| 540 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 541 | self.assertEqual("Added an awesome new API!", commitWithApiChange.releaseNote) |
| 542 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 543 | self.assertEqual( |
| 544 | "Added a new API! ([myChan]" + |
| 545 | "(https://android-review.googlesource.com/#/q/myChangeId), " + |
| 546 | "[b/123456](https://issuetracker.google.com/issues/123456), " + |
| 547 | "[b/1234567](https://issuetracker.google.com/issues/1234567), " + |
| 548 | "[b/123123](https://issuetracker.google.com/issues/123123))", |
| 549 | str(commitWithApiChange) |
| 550 | ) |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 551 | |
Nick Anthony | a257b88 | 2020-03-16 09:19:34 -0400 | [diff] [blame] | 552 | def test_parseAPICommitWithDefaultDelimitersAndNonstandardQuoteCharacters(self): |
| 553 | commitWithApiChangeString = """ |
| 554 | _CommitStart |
| 555 | _CommitSHA:mySha |
| 556 | _Author:[email protected] |
| 557 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 558 | _Subject:Added a new API! |
| 559 | _Body:Also fixed some other bugs |
| 560 | |
| 561 | Here is an explanation of my commit |
| 562 | |
| 563 | "This is a quote about why it's great!" |
| 564 | |
| 565 | Bug: 123456 |
| 566 | Bug: b/1234567 |
| 567 | Fixes: 123123 |
| 568 | Test: ./gradlew buildOnServer |
| 569 | |
| 570 | Relnote: “Added an awesome new API! |
| 571 | It will make your life easier.” |
| 572 | |
| 573 | Change-Id: myChangeId |
| 574 | |
| 575 | projectdir/a.java |
| 576 | projectdir/b.java |
| 577 | projectdir/androidTest/c.java |
| 578 | projectdir/api/some_api_file.txt |
| 579 | projectdir/api/current.txt |
| 580 | """ |
| 581 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 582 | self.assertEqual("mySha", commitWithApiChange.sha) |
| 583 | self.assertEqual("[email protected]", commitWithApiChange.authorEmail) |
| 584 | self.assertEqual("myChangeId", commitWithApiChange.changeId) |
| 585 | self.assertEqual("Added a new API!", commitWithApiChange.summary) |
| 586 | self.assertEqual(CommitType.API_CHANGE, commitWithApiChange.changeType) |
| 587 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 588 | self.assertEqual([ |
| 589 | "projectdir/a.java", |
| 590 | "projectdir/b.java", |
| 591 | "projectdir/androidTest/c.java", |
| 592 | "projectdir/api/some_api_file.txt", |
| 593 | "projectdir/api/current.txt" |
| 594 | ], |
| 595 | commitWithApiChange.files |
| 596 | ) |
| 597 | self.assertEqual("Added an awesome new API!\n" + \ |
| 598 | " It will make your life easier." |
| 599 | , commitWithApiChange.releaseNote) |
| 600 | |
Nick Anthony | b0f5d6d | 2020-03-05 15:41:27 -0500 | [diff] [blame] | 601 | def test_parseAPICommitWithDefaultDelimitersAndUncapitalizedRelnoteTag(self): |
| 602 | commitWithApiChangeString = """ |
| 603 | _CommitStart |
| 604 | _CommitSHA:mySha |
| 605 | _Author:[email protected] |
| 606 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 607 | _Subject:Added a new API! |
| 608 | _Body:Also fixed some other bugs |
| 609 | |
| 610 | Here is an explanation of my commit |
| 611 | |
| 612 | "This is a quote about why it's great!" |
| 613 | |
| 614 | Bug: 123456 |
| 615 | Bug: b/1234567 |
| 616 | Fixes: 123123 |
| 617 | Test: ./gradlew buildOnServer |
| 618 | |
| 619 | relnote: Added an awesome new API! |
| 620 | |
| 621 | Change-Id: myChangeId |
| 622 | |
| 623 | projectdir/a.java |
| 624 | projectdir/b.java |
| 625 | projectdir/androidTest/c.java |
| 626 | projectdir/api/some_api_file.txt |
| 627 | projectdir/api/current.txt |
| 628 | """ |
| 629 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 630 | self.assertEqual("mySha", commitWithApiChange.sha) |
| 631 | self.assertEqual("[email protected]", commitWithApiChange.authorEmail) |
| 632 | self.assertEqual("myChangeId", commitWithApiChange.changeId) |
| 633 | self.assertEqual("Added a new API!", commitWithApiChange.summary) |
| 634 | self.assertEqual(CommitType.API_CHANGE, commitWithApiChange.changeType) |
| 635 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 636 | self.assertEqual([ |
| 637 | "projectdir/a.java", |
| 638 | "projectdir/b.java", |
| 639 | "projectdir/androidTest/c.java", |
| 640 | "projectdir/api/some_api_file.txt", |
| 641 | "projectdir/api/current.txt" |
| 642 | ], |
| 643 | commitWithApiChange.files |
| 644 | ) |
| 645 | self.assertEqual("Added an awesome new API!", commitWithApiChange.releaseNote) |
| 646 | |
| 647 | def test_parseAPICommitWithDefaultDelimitersAndCapitalizedRelnoteTag(self): |
| 648 | commitWithApiChangeString = """ |
| 649 | _CommitStart |
| 650 | _CommitSHA:mySha |
| 651 | _Author:[email protected] |
| 652 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 653 | _Subject:Added a new API! |
| 654 | _Body:Also fixed some other bugs |
| 655 | |
| 656 | Here is an explanation of my commit |
| 657 | |
| 658 | "This is a quote about why it's great!" |
| 659 | |
| 660 | Bug: 123456 |
| 661 | Bug: b/1234567 |
| 662 | Fixes: 123123 |
| 663 | Test: ./gradlew buildOnServer |
| 664 | |
| 665 | RelNotE: Added an awesome new API! |
| 666 | |
| 667 | Change-Id: myChangeId |
| 668 | |
| 669 | projectdir/a.java |
| 670 | projectdir/b.java |
| 671 | projectdir/androidTest/c.java |
| 672 | projectdir/api/some_api_file.txt |
| 673 | projectdir/api/current.txt |
| 674 | """ |
| 675 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 676 | self.assertEqual("mySha", commitWithApiChange.sha) |
| 677 | self.assertEqual("[email protected]", commitWithApiChange.authorEmail) |
| 678 | self.assertEqual("myChangeId", commitWithApiChange.changeId) |
| 679 | self.assertEqual("Added a new API!", commitWithApiChange.summary) |
| 680 | self.assertEqual(CommitType.API_CHANGE, commitWithApiChange.changeType) |
| 681 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 682 | self.assertEqual([ |
| 683 | "projectdir/a.java", |
| 684 | "projectdir/b.java", |
| 685 | "projectdir/androidTest/c.java", |
| 686 | "projectdir/api/some_api_file.txt", |
| 687 | "projectdir/api/current.txt" |
| 688 | ], |
| 689 | commitWithApiChange.files |
| 690 | ) |
| 691 | self.assertEqual("Added an awesome new API!", commitWithApiChange.releaseNote) |
| 692 | |
Nick Anthony | 505d103 | 2020-03-31 15:54:49 -0400 | [diff] [blame] | 693 | def test_parseAPICommitWithNotApplicableWithSlashRelnoteTag(self): |
| 694 | commitWithApiChangeString = """ |
| 695 | _CommitStart |
| 696 | _CommitSHA:mySha |
| 697 | _Author:[email protected] |
| 698 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 699 | _Subject:API Tracking Improvements |
| 700 | _Body:Also fixed some other bugs |
| 701 | |
| 702 | This CL fixes some infrastructure bugs |
| 703 | |
| 704 | "This is a quote" |
| 705 | |
| 706 | Bug: 123456 |
| 707 | Bug: b/1234567 |
| 708 | Fixes: 123123 |
| 709 | Test: ./gradlew buildOnServer |
| 710 | |
| 711 | Relnote: N/A |
| 712 | |
| 713 | Change-Id: myChangeId |
| 714 | |
| 715 | projectdir/a.java |
| 716 | projectdir/b.java |
| 717 | projectdir/androidTest/c.java |
| 718 | projectdir/api/some_api_file.txt |
| 719 | projectdir/api/current.txt |
| 720 | projectdir/api/restricted_current.txt |
| 721 | """ |
| 722 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 723 | self.assertEqual("mySha", commitWithApiChange.sha) |
| 724 | self.assertEqual("[email protected]", commitWithApiChange.authorEmail) |
| 725 | self.assertEqual("myChangeId", commitWithApiChange.changeId) |
| 726 | self.assertEqual("API Tracking Improvements", commitWithApiChange.summary) |
| 727 | self.assertEqual(CommitType.API_CHANGE, commitWithApiChange.changeType) |
| 728 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 729 | self.assertEqual([ |
| 730 | "projectdir/a.java", |
| 731 | "projectdir/b.java", |
| 732 | "projectdir/androidTest/c.java", |
| 733 | "projectdir/api/some_api_file.txt", |
| 734 | "projectdir/api/current.txt", |
| 735 | "projectdir/api/restricted_current.txt" |
| 736 | ], |
| 737 | commitWithApiChange.files |
| 738 | ) |
| 739 | self.assertEqual("", commitWithApiChange.releaseNote) |
| 740 | |
| 741 | def test_parseAPICommitWithMalformattedNotApplicableRelnoteTag(self): |
| 742 | commitWithApiChangeString = """ |
| 743 | _CommitStart |
| 744 | _CommitSHA:mySha |
| 745 | _Author:[email protected] |
| 746 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 747 | _Subject:API Tracking Improvements |
| 748 | _Body:Also fixed some other bugs |
| 749 | |
| 750 | This CL fixes some infrastructure bugs |
| 751 | |
| 752 | "This is a quote" |
| 753 | |
| 754 | Bug: 123456 |
| 755 | Bug: b/1234567 |
| 756 | Fixes: 123123 |
| 757 | Test: ./gradlew buildOnServer |
| 758 | |
| 759 | Relnote: "N/A |
| 760 | |
| 761 | Change-Id: myChangeId |
| 762 | |
| 763 | projectdir/a.java |
| 764 | projectdir/b.java |
| 765 | projectdir/androidTest/c.java |
| 766 | projectdir/api/some_api_file.txt |
| 767 | projectdir/api/current.txt |
| 768 | projectdir/api/restricted_current.txt |
| 769 | """ |
| 770 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 771 | self.assertEqual("mySha", commitWithApiChange.sha) |
| 772 | self.assertEqual("[email protected]", commitWithApiChange.authorEmail) |
| 773 | self.assertEqual("myChangeId", commitWithApiChange.changeId) |
| 774 | self.assertEqual("API Tracking Improvements", commitWithApiChange.summary) |
| 775 | self.assertEqual(CommitType.API_CHANGE, commitWithApiChange.changeType) |
| 776 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 777 | self.assertEqual([ |
| 778 | "projectdir/a.java", |
| 779 | "projectdir/b.java", |
| 780 | "projectdir/androidTest/c.java", |
| 781 | "projectdir/api/some_api_file.txt", |
| 782 | "projectdir/api/current.txt", |
| 783 | "projectdir/api/restricted_current.txt" |
| 784 | ], |
| 785 | commitWithApiChange.files |
| 786 | ) |
| 787 | self.assertEqual("", commitWithApiChange.releaseNote) |
| 788 | |
| 789 | def test_parseAPICommitWithNotApplicableWithoutSlashRelnoteTag(self): |
| 790 | commitWithApiChangeString = """ |
| 791 | _CommitStart |
| 792 | _CommitSHA:mySha |
| 793 | _Author:[email protected] |
| 794 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 795 | _Subject:API Tracking Improvements |
| 796 | _Body:Also fixed some other bugs |
| 797 | |
| 798 | This CL fixes some infrastructure bugs |
| 799 | |
| 800 | "This is a quote" |
| 801 | |
| 802 | Bug: 123456 |
| 803 | Bug: b/1234567 |
| 804 | Fixes: 123123 |
| 805 | Test: ./gradlew buildOnServer |
| 806 | |
| 807 | Relnote: na |
| 808 | |
| 809 | Change-Id: myChangeId |
| 810 | |
| 811 | projectdir/a.java |
| 812 | projectdir/b.java |
| 813 | projectdir/androidTest/c.java |
| 814 | projectdir/api/some_api_file.txt |
| 815 | projectdir/api/current.txt |
| 816 | projectdir/api/restricted_current.txt |
| 817 | """ |
| 818 | commitWithApiChange = Commit(commitWithApiChangeString, "/projectdir/") |
| 819 | self.assertEqual("mySha", commitWithApiChange.sha) |
| 820 | self.assertEqual("[email protected]", commitWithApiChange.authorEmail) |
| 821 | self.assertEqual("myChangeId", commitWithApiChange.changeId) |
| 822 | self.assertEqual("API Tracking Improvements", commitWithApiChange.summary) |
| 823 | self.assertEqual(CommitType.API_CHANGE, commitWithApiChange.changeType) |
| 824 | self.assertEqual([123456, 1234567, 123123], commitWithApiChange.bugs) |
| 825 | self.assertEqual([ |
| 826 | "projectdir/a.java", |
| 827 | "projectdir/b.java", |
| 828 | "projectdir/androidTest/c.java", |
| 829 | "projectdir/api/some_api_file.txt", |
| 830 | "projectdir/api/current.txt", |
| 831 | "projectdir/api/restricted_current.txt" |
| 832 | ], |
| 833 | commitWithApiChange.files |
| 834 | ) |
| 835 | self.assertEqual("", commitWithApiChange.releaseNote) |
| 836 | |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 837 | def test_parseBugFixCommitWithCustomDelimiters(self): |
| 838 | commitSHADelimiter = "_MyCommitSHA:" |
| 839 | authorEmailDelimiter = "_MyAuthor:" |
| 840 | subjectDelimiter = "_MySubject:" |
| 841 | projectDir = "group/artifact" |
| 842 | commitWithABugFixString = "_CommitStart\n" + \ |
| 843 | commitSHADelimiter + "mySha\n" + \ |
| 844 | authorEmailDelimiter + "[email protected]\n" + \ |
| 845 | "_Date:Tue Aug 6 15:05:55 2019 -0700\n" + \ |
| 846 | subjectDelimiter + "Fixed a bug!\n" + \ |
| 847 | """ |
| 848 | _Body:Also fixed some other bugs |
| 849 | |
| 850 | Here is an explanation of my commit that changes a kotlin file |
| 851 | |
| 852 | Relnote: "Fixed a critical bug" |
| 853 | |
| 854 | Bug: 111111, 222222 |
| 855 | Test: ./gradlew buildOnServer |
| 856 | |
| 857 | Change-Id: myChangeId |
| 858 | """ + \ |
| 859 | projectDir + "/a.java\n" + \ |
| 860 | projectDir + "/b.kt\n" + \ |
| 861 | projectDir + "/androidTest/c.java\n" |
| 862 | commitWithABugFix = Commit( |
| 863 | gitCommit = commitWithABugFixString, |
| 864 | projectDir = projectDir, |
| 865 | commitSHADelimiter = commitSHADelimiter, |
| 866 | subjectDelimiter = subjectDelimiter, |
| 867 | authorEmailDelimiter = authorEmailDelimiter |
| 868 | ) |
| 869 | self.assertEqual("mySha", commitWithABugFix.sha) |
| 870 | self.assertEqual("[email protected]", commitWithABugFix.authorEmail) |
| 871 | self.assertEqual("myChangeId", commitWithABugFix.changeId) |
| 872 | self.assertEqual("Fixed a bug!", commitWithABugFix.summary) |
| 873 | self.assertEqual(CommitType.BUG_FIX, commitWithABugFix.changeType) |
| 874 | self.assertEqual([111111, 222222], commitWithABugFix.bugs) |
| 875 | self.assertEqual([ |
| 876 | projectDir + "/a.java", |
| 877 | projectDir + "/b.kt", |
| 878 | projectDir + "/androidTest/c.java" |
| 879 | ], |
| 880 | commitWithABugFix.files |
| 881 | ) |
| 882 | self.assertEqual("Fixed a critical bug", commitWithABugFix.releaseNote) |
| 883 | |
| 884 | def test_parseExternalContributorCommitWithCustomDelimiters(self): |
| 885 | commitSHADelimiter = "_MyCommitSHA:" |
| 886 | subjectDelimiter = "_MySubject:" |
| 887 | authorEmailDelimiter = "_MyAuthor:" |
| 888 | projectDir = "group/artifact" |
| 889 | commitFromExternalContributorString = "_CommitStart\n" + \ |
| 890 | commitSHADelimiter + "mySha\n" + \ |
| 891 | authorEmailDelimiter + "[email protected]\n" + \ |
| 892 | "_Date:Thurs Aug 8 15:05:55 2019 -0700\n" + \ |
| 893 | subjectDelimiter + "New compat API!\n" + \ |
| 894 | """ |
| 895 | _Body:Also fixed some other bugs |
| 896 | |
| 897 | Here is an explanation of my commit that changes a java file |
| 898 | |
| 899 | Relnote: Added a new compat API! |
| 900 | |
| 901 | Bug: 111111, 222222 |
| 902 | Test: ./gradlew buildOnServer |
| 903 | |
| 904 | Change-Id: myChangeId |
| 905 | """ + \ |
| 906 | projectDir + "/a.java\n" + \ |
| 907 | projectDir + "/b.java\n" + \ |
| 908 | projectDir + "/androidTest/c.java\n" + \ |
| 909 | projectDir + "/api/current.txt\n" + \ |
| 910 | projectDir + "/api/1.2.0-alpha04.txt\n" |
| 911 | commitFromExternalContributor = Commit( |
| 912 | commitFromExternalContributorString, |
| 913 | projectDir, |
| 914 | commitSHADelimiter = commitSHADelimiter, |
| 915 | subjectDelimiter = subjectDelimiter, |
| 916 | authorEmailDelimiter = authorEmailDelimiter |
| 917 | ) |
| 918 | self.assertEqual("mySha", commitFromExternalContributor.sha) |
| 919 | self.assertEqual("[email protected]", commitFromExternalContributor.authorEmail) |
| 920 | self.assertEqual("myChangeId", commitFromExternalContributor.changeId) |
| 921 | self.assertEqual("New compat API!", commitFromExternalContributor.summary) |
| 922 | self.assertEqual(CommitType.EXTERNAL_CONTRIBUTION, commitFromExternalContributor.changeType) |
| 923 | self.assertEqual([111111, 222222], commitFromExternalContributor.bugs) |
| 924 | self.assertEqual([ |
| 925 | projectDir + "/a.java", |
| 926 | projectDir + "/b.java", |
| 927 | projectDir + "/androidTest/c.java", |
| 928 | projectDir + "/api/current.txt", |
| 929 | projectDir + "/api/1.2.0-alpha04.txt" |
| 930 | ], |
| 931 | commitFromExternalContributor.files |
| 932 | ) |
| 933 | self.assertEqual("Added a new compat API!", commitFromExternalContributor.releaseNote) |
| 934 | |
| 935 | def test_parseGitLog(self): |
| 936 | mockGitRootDir = "gitRoot" |
| 937 | gitClient = GitClientTestImpl(mockGitRootDir) |
| 938 | # This is the default set-up boilerplate from `GitClientImpl.getGitLog` to set up the |
| 939 | # default git log command (gitLogCmd) |
| 940 | commitStartDelimiter = "_CommitStart" |
| 941 | commitSHADelimiter = "_CommitSHA:" |
| 942 | subjectDelimiter = "_Subject:" |
| 943 | authorEmailDelimiter = "_Author:" |
| 944 | dateDelimiter = "_Date:" |
| 945 | bodyDelimiter = "_Body:" |
| 946 | projectDir = "group/artifact" |
| 947 | gitLogOptions = "--pretty=format:" + \ |
| 948 | commitStartDelimiter + "\%n" + \ |
| 949 | commitSHADelimiter + "\%H\%n" + \ |
| 950 | authorEmailDelimiter + "\%ae\%n" + \ |
| 951 | dateDelimiter + "\%ad\%n" + \ |
| 952 | subjectDelimiter + "\%s\%n" + \ |
| 953 | bodyDelimiter + "\%b" + \ |
Nick Anthony | 4183144 | 2020-04-15 18:12:35 -0400 | [diff] [blame] | 954 | " --no-merges" |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 955 | fullProjectDir = os.path.join(mockGitRootDir, projectDir) |
Nick Anthony | 4183144 | 2020-04-15 18:12:35 -0400 | [diff] [blame] | 956 | gitLogCmd = GIT_LOG_CMD_PREFIX + " " + gitLogOptions + " sha..topSha -- " + fullProjectDir |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 957 | # Check with default delimiters |
| 958 | gitLogString = """ |
| 959 | _CommitStart |
| 960 | _CommitSHA:topSha |
| 961 | _Author:[email protected] |
| 962 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 963 | _Subject:Added a new API! |
| 964 | _Body:Also fixed some other bugs |
| 965 | |
| 966 | Here is an explanation of my commit |
| 967 | |
| 968 | Bug: 123456 |
| 969 | Bug: b/1234567 |
| 970 | Fixes: 123123 |
| 971 | Test: ./gradlew buildOnServer |
| 972 | |
| 973 | Change-Id: myChangeId\n |
| 974 | """ + \ |
| 975 | projectDir + "/a.java\n" + \ |
| 976 | projectDir + "/b.java\n" + \ |
| 977 | projectDir + "/androidTest/c.java\n" + \ |
| 978 | projectDir + "/api/some_api_file.txt\n" + \ |
| 979 | projectDir + "/api/current.txt\n" + \ |
| 980 | """ |
| 981 | _CommitStart |
| 982 | _CommitSHA:midSha |
| 983 | _Author:[email protected] |
| 984 | _Date:Tue Aug 6 15:05:55 2019 -0700 |
| 985 | _Subject:Fixed a bug! |
| 986 | _Body:Also fixed some other bugs |
| 987 | |
| 988 | Here is an explanation of my commit |
| 989 | |
| 990 | Bug: 111111, 222222 |
| 991 | Test: ./gradlew buildOnServer |
| 992 | |
| 993 | Change-Id: myChangeId\n |
| 994 | """ + \ |
| 995 | projectDir + "/a.java\n" + \ |
| 996 | projectDir + "/b.java\n" + \ |
| 997 | projectDir + "/androidTest/c.java\n" + \ |
| 998 | """ |
| 999 | _CommitStart |
| 1000 | _CommitSHA:sha |
| 1001 | _Author:[email protected] |
| 1002 | _Date:Thurs Aug 8 15:05:55 2019 -0700 |
| 1003 | _Subject:New compat API! |
| 1004 | _Body:Also fixed some other bugs |
| 1005 | |
| 1006 | Here is an explanation of my commit |
| 1007 | |
| 1008 | Bug: 111111, 222222 |
| 1009 | Test: ./gradlew buildOnServer |
| 1010 | |
| 1011 | Change-Id: myChangeId\n |
| 1012 | """ + \ |
| 1013 | projectDir + "/a.java\n" + \ |
| 1014 | projectDir + "/b.java\n" + \ |
| 1015 | projectDir + "/androidTest/c.java\n" + \ |
| 1016 | projectDir + "/api/current.txt\n" + \ |
| 1017 | projectDir + "/api/1.2.0-alpha04.txt\n" |
| 1018 | |
| 1019 | gitClient.addReply( |
| 1020 | gitLogCmd, |
| 1021 | gitLogString |
| 1022 | ) |
| 1023 | |
| 1024 | commitWithAPIChange = Commit("", projectDir) |
| 1025 | commitWithAPIChange.sha = "topSha" |
| 1026 | commitWithAPIChange.authorEmail = "[email protected]" |
| 1027 | commitWithAPIChange.changeId = "myChangeId" |
| 1028 | commitWithAPIChange.summary = "Added a new API!" |
| 1029 | commitWithAPIChange.type = CommitType.API_CHANGE |
| 1030 | commitWithAPIChange.bugs = [123456, 1234567, 123123] |
| 1031 | commitWithAPIChange.files = [ |
| 1032 | projectDir + "/a.java", |
| 1033 | projectDir + "/b.java", |
| 1034 | projectDir + "/androidTest/c.java", |
| 1035 | projectDir + "/api/some_api_file.txt", |
| 1036 | projectDir + "/api/current.txt" |
| 1037 | ] |
| 1038 | |
| 1039 | commitWithBugFix = Commit("", projectDir) |
| 1040 | commitWithBugFix.sha = "midSha" |
| 1041 | commitWithBugFix.authorEmail = "[email protected]" |
| 1042 | commitWithBugFix.changeId = "myChangeId" |
| 1043 | commitWithBugFix.summary = "Fixed a bug!" |
| 1044 | commitWithBugFix.type = CommitType.BUG_FIX |
| 1045 | commitWithBugFix.bugs = [111111, 222222] |
| 1046 | commitWithBugFix.files = [ |
| 1047 | projectDir + "/a.java", |
| 1048 | projectDir + "/b.java", |
| 1049 | projectDir + "/androidTest/c.java" |
| 1050 | ] |
| 1051 | |
| 1052 | commitFromExternalContributor = Commit("", projectDir) |
| 1053 | commitFromExternalContributor.sha = "sha" |
| 1054 | commitFromExternalContributor.authorEmail = "[email protected]" |
| 1055 | commitFromExternalContributor.changeId = "myChangeId" |
| 1056 | commitFromExternalContributor.summary = "New compat API!" |
| 1057 | commitFromExternalContributor.type = CommitType.EXTERNAL_CONTRIBUTION |
| 1058 | commitFromExternalContributor.bugs = [111111, 222222] |
| 1059 | commitFromExternalContributor.files = [ |
| 1060 | projectDir + "/a.java", |
| 1061 | projectDir + "/b.java", |
| 1062 | projectDir + "/androidTest/c.java", |
| 1063 | projectDir + "/api/current.txt", |
| 1064 | projectDir + "/api/1.2.0-alpha04.txt" |
| 1065 | ] |
| 1066 | # In this test case, we pass an empty string as the subProjectDir because "group/artifact" |
| 1067 | # is the git root dir and the git client will prepend that to the subProjectDir. |
| 1068 | gitLogList = gitClient.getGitLog( |
| 1069 | fromExclusiveSha = "sha", |
| 1070 | untilInclusiveSha = "topSha", |
| 1071 | keepMerges = False, |
| 1072 | subProjectDir = projectDir |
| 1073 | ) |
| 1074 | self.assertEqual(3, len(gitLogList)) |
| 1075 | for commit in gitLogList: |
| 1076 | if commit.sha == "topSha": |
| 1077 | self.assertCommitsAreEqual(commitWithAPIChange, commit) |
| 1078 | elif commit.sha == "midSha": |
| 1079 | self.assertCommitsAreEqual(commitWithBugFix, commit) |
| 1080 | elif commit.sha == "sha": |
| 1081 | self.assertCommitsAreEqual(commitFromExternalContributor, commit) |
| 1082 | else: |
| 1083 | self.assertFalse("Unable to parse commit") |
| 1084 | |
| 1085 | def test_checkLatestCommitExists(self): |
| 1086 | # Do not use the MockCommandRunner because it's a better test to check the validity of |
| 1087 | # the git command against the actual git in the repo |
| 1088 | gitClient = GitClient(os.getcwd()) |
| 1089 | subProjectDir = os.getcwd().split("frameworks/support/")[1] |
| 1090 | commitList = gitClient.getGitLog( |
| 1091 | fromExclusiveSha = "", |
| 1092 | untilInclusiveSha = "HEAD", |
| 1093 | keepMerges = False, |
| 1094 | subProjectDir = subProjectDir, |
| 1095 | n = 1 |
| 1096 | ) |
| 1097 | self.assertEqual(1, len(commitList)) |
| 1098 | |
Nick Anthony | 4183144 | 2020-04-15 18:12:35 -0400 | [diff] [blame] | 1099 | def test_checkLatestNCommitExists(self): |
| 1100 | # Do not use the MockCommandRunner because it's a better test to check the validity of |
| 1101 | # the git command against the actual git in the repo |
| 1102 | gitClient = GitClient(os.getcwd()) |
| 1103 | subProjectDir = os.getcwd().split("frameworks/support/")[1] |
| 1104 | commitList = gitClient.getGitLog( |
| 1105 | fromExclusiveSha = "", |
| 1106 | untilInclusiveSha = "HEAD", |
| 1107 | keepMerges = False, |
| 1108 | subProjectDir = subProjectDir, |
| 1109 | n = 0 |
| 1110 | ) |
| 1111 | self.assertEqual(0, len(commitList)) |
| 1112 | commitList = gitClient.getGitLog( |
| 1113 | fromExclusiveSha = "", |
| 1114 | untilInclusiveSha = "HEAD", |
| 1115 | keepMerges = False, |
| 1116 | subProjectDir = subProjectDir, |
| 1117 | n = 1 |
| 1118 | ) |
| 1119 | self.assertEqual(1, len(commitList)) |
| 1120 | commitList = gitClient.getGitLog( |
| 1121 | fromExclusiveSha = "", |
| 1122 | untilInclusiveSha = "HEAD", |
| 1123 | keepMerges = False, |
| 1124 | subProjectDir = subProjectDir, |
| 1125 | n = 2 |
| 1126 | ) |
| 1127 | self.assertEqual(2, len(commitList)) |
| 1128 | commitList = gitClient.getGitLog( |
| 1129 | fromExclusiveSha = "HEAD~3", |
| 1130 | untilInclusiveSha = "HEAD", |
| 1131 | keepMerges = False, |
| 1132 | subProjectDir = subProjectDir, |
| 1133 | n = 1 |
| 1134 | ) |
| 1135 | self.assertEqual(1, len(commitList)) |
| 1136 | |
Nick Anthony | f721b598 | 2020-02-27 11:38:08 -0500 | [diff] [blame] | 1137 | def test_gitLogFailsWhenPassedAnAbsolutePath(self): |
| 1138 | # Tests that you cannot pass an absolute file path to git log |
| 1139 | gitClient = GitClient(os.getcwd()) |
| 1140 | subProjectDir = os.getcwd().split("frameworks/support/")[1] |
| 1141 | subProjectDir = '/' + subProjectDir |
| 1142 | self.assertRaises(RuntimeError, gitClient.getGitLog, |
| 1143 | fromExclusiveSha = "", |
| 1144 | untilInclusiveSha = "HEAD", |
| 1145 | keepMerges = False, |
| 1146 | subProjectDir = subProjectDir, |
| 1147 | n = 1 |
| 1148 | ) |
| 1149 | |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 1150 | def assertCommitsAreEqual(self, commitA, commitB): |
| 1151 | self.assertEqual(commitA.summary, commitB.summary) |
| 1152 | self.assertEqual(commitA.files, commitB.files) |
| 1153 | self.assertEqual(commitA.sha, commitB.sha) |
| 1154 | self.assertEqual(commitA.changeId, commitB.changeId) |
| 1155 | self.assertEqual(commitA.authorEmail, commitB.authorEmail) |
| 1156 | self.assertEqual(commitA.type, commitB.changeType) |
| 1157 | self.assertEqual(commitA.projectDir, commitB.projectDir) |
| 1158 | self.assertEqual(commitA.summary, commitB.summary) |
| 1159 | self.assertEqual(commitA.releaseNote, commitB.releaseNote) |
Nick Anthony | 917014b | 2020-05-08 08:24:09 -0400 | [diff] [blame] | 1160 | |
| 1161 | class TestMarkdown(unittest.TestCase): |
| 1162 | |
| 1163 | def test_markdownCorrectlyFormatsForOneArtifactWithNoCommit(self): |
| 1164 | releaseNotes = LibraryReleaseNotes( |
| 1165 | groupId = "groupId", |
| 1166 | artifactIds = ["artifactId"], |
| 1167 | version = "version", |
| 1168 | releaseDate = "01-01-1970", |
| 1169 | fromSHA = "fromSHA", |
| 1170 | untilSHA = "untilSHA", |
| 1171 | projectDir = "projectDir", |
| 1172 | requiresSameVersion = True, |
| 1173 | commitList = [], |
| 1174 | forceIncludeAllCommits = False |
| 1175 | ) |
| 1176 | self.assertEqual(releaseNotes.groupId, "groupId") |
| 1177 | self.assertEqual(releaseNotes.artifactIds, ["artifactId"]) |
| 1178 | self.assertEqual(releaseNotes.version, "version") |
| 1179 | self.assertEqual(str(releaseNotes.releaseDate), "January 1, 1970") |
| 1180 | self.assertEqual(releaseNotes.fromSHA, "fromSHA") |
| 1181 | self.assertEqual(releaseNotes.untilSHA, "untilSHA") |
| 1182 | self.assertEqual(releaseNotes.projectDir, "projectDir") |
| 1183 | self.assertEqual(releaseNotes.requiresSameVersion, True) |
| 1184 | self.assertEqual(releaseNotes.forceIncludeAllCommits, False) |
Nick Anthony | 8f18f3d | 2020-05-28 20:15:56 -0400 | [diff] [blame] | 1185 | self.assertEqual(str(releaseNotes.header), |
| 1186 | "### Groupid Version version {:#version}") |
Nick Anthony | 917014b | 2020-05-08 08:24:09 -0400 | [diff] [blame] | 1187 | self.assertEqual(str(releaseNotes.diffLogLink), |
| 1188 | "[Version version contains" + \ |
| 1189 | " these commits.](https://android.googlesource.com/" + \ |
| 1190 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)" |
| 1191 | ) |
| 1192 | self.assertEqual(releaseNotes.commits, []) |
| 1193 | self.assertEqual(str(releaseNotes.commitMarkdownList), |
Nick Anthony | 8f18f3d | 2020-05-28 20:15:56 -0400 | [diff] [blame] | 1194 | "\n**New Features**\n\n" + \ |
| 1195 | "\n**API Changes**\n\n" + \ |
| 1196 | "\n**Bug Fixes**\n\n" + \ |
| 1197 | "\n**External Contribution**\n\n" |
Nick Anthony | 917014b | 2020-05-08 08:24:09 -0400 | [diff] [blame] | 1198 | ) |
| 1199 | self.assertEqual(releaseNotes.getFormattedReleaseSummary(), |
| 1200 | "`groupId:artifactId:version` is released." + \ |
| 1201 | " [Version version contains these commits.](https://android.googlesource.com/" + \ |
| 1202 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n" |
| 1203 | ) |
| 1204 | self.assertEqual(releaseNotes.bugsFixed, []) |
| 1205 | |
Nick Anthony | 8f18f3d | 2020-05-28 20:15:56 -0400 | [diff] [blame] | 1206 | def test_markdownCorrectlyFormatsForTwoArtifactsWithFalseRequiresSameVersion(self): |
| 1207 | releaseNotes = LibraryReleaseNotes( |
| 1208 | groupId = "groupId", |
| 1209 | artifactIds = ["artifactId1", "artifactId2"], |
| 1210 | version = "version", |
| 1211 | releaseDate = "01-01-1970", |
| 1212 | fromSHA = "fromSHA", |
| 1213 | untilSHA = "untilSHA", |
| 1214 | projectDir = "projectDir", |
| 1215 | requiresSameVersion = False, |
| 1216 | commitList = [], |
| 1217 | forceIncludeAllCommits = False |
| 1218 | ) |
| 1219 | self.assertEqual(releaseNotes.groupId, "groupId") |
| 1220 | self.assertEqual(releaseNotes.artifactIds, ["artifactId1", "artifactId2"]) |
| 1221 | self.assertEqual(releaseNotes.version, "version") |
| 1222 | self.assertEqual(str(releaseNotes.releaseDate), "January 1, 1970") |
| 1223 | self.assertEqual(releaseNotes.fromSHA, "fromSHA") |
| 1224 | self.assertEqual(releaseNotes.untilSHA, "untilSHA") |
| 1225 | self.assertEqual(releaseNotes.projectDir, "projectDir") |
| 1226 | self.assertEqual(releaseNotes.requiresSameVersion, False) |
| 1227 | self.assertEqual(releaseNotes.forceIncludeAllCommits, False) |
| 1228 | self.assertEqual(str(releaseNotes.header), |
| 1229 | "### Artifactid1 Artifactid2 Version version {:#version}") |
| 1230 | self.assertEqual(str(releaseNotes.diffLogLink), |
| 1231 | "[Version version contains" + \ |
| 1232 | " these commits.](https://android.googlesource.com/" + \ |
| 1233 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)" |
| 1234 | ) |
| 1235 | self.assertEqual(releaseNotes.commits, []) |
| 1236 | self.assertEqual(str(releaseNotes.commitMarkdownList), |
| 1237 | "\n**New Features**\n\n" + \ |
| 1238 | "\n**API Changes**\n\n" + \ |
| 1239 | "\n**Bug Fixes**\n\n" + \ |
| 1240 | "\n**External Contribution**\n\n" |
| 1241 | ) |
| 1242 | self.assertEqual(releaseNotes.getFormattedReleaseSummary(), |
| 1243 | "`groupId:artifactId1:version` and `groupId:artifactId2:version` are released." + \ |
| 1244 | " [Version version contains these commits.](https://android.googlesource.com/" + \ |
| 1245 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n" |
| 1246 | ) |
| 1247 | self.assertEqual(releaseNotes.bugsFixed, []) |
| 1248 | |
| 1249 | def test_markdownCorrectlyFormatsForThreeArtifactsWithFalseRequiresSameVersion(self): |
| 1250 | releaseNotes = LibraryReleaseNotes( |
| 1251 | groupId = "groupId", |
| 1252 | artifactIds = ["artifactId1", "artifactId2", "artifactId3"], |
| 1253 | version = "version", |
| 1254 | releaseDate = "01-01-1970", |
| 1255 | fromSHA = "fromSHA", |
| 1256 | untilSHA = "untilSHA", |
| 1257 | projectDir = "projectDir", |
| 1258 | requiresSameVersion = False, |
| 1259 | commitList = [], |
| 1260 | forceIncludeAllCommits = False |
| 1261 | ) |
| 1262 | self.assertEqual(releaseNotes.groupId, "groupId") |
| 1263 | self.assertEqual(releaseNotes.artifactIds, |
| 1264 | ["artifactId1", "artifactId2", "artifactId3"]) |
| 1265 | self.assertEqual(releaseNotes.version, "version") |
| 1266 | self.assertEqual(str(releaseNotes.releaseDate), "January 1, 1970") |
| 1267 | self.assertEqual(releaseNotes.fromSHA, "fromSHA") |
| 1268 | self.assertEqual(releaseNotes.untilSHA, "untilSHA") |
| 1269 | self.assertEqual(releaseNotes.projectDir, "projectDir") |
| 1270 | self.assertEqual(releaseNotes.requiresSameVersion, False) |
| 1271 | self.assertEqual(releaseNotes.forceIncludeAllCommits, False) |
| 1272 | self.assertEqual(str(releaseNotes.header), |
| 1273 | "### Artifactid1 Artifactid2 Artifactid3 Version version {:#version}") |
| 1274 | self.assertEqual(str(releaseNotes.diffLogLink), |
| 1275 | "[Version version contains" + \ |
| 1276 | " these commits.](https://android.googlesource.com/" + \ |
| 1277 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)" |
| 1278 | ) |
| 1279 | self.assertEqual(releaseNotes.commits, []) |
| 1280 | self.assertEqual(str(releaseNotes.commitMarkdownList), |
| 1281 | "\n**New Features**\n\n" + \ |
| 1282 | "\n**API Changes**\n\n" + \ |
| 1283 | "\n**Bug Fixes**\n\n" + \ |
| 1284 | "\n**External Contribution**\n\n" |
| 1285 | ) |
| 1286 | self.assertEqual(releaseNotes.getFormattedReleaseSummary(), |
| 1287 | "`groupId:artifactId1:version`, `groupId:artifactId2:version`, and " + \ |
| 1288 | "`groupId:artifactId3:version` are released. " + \ |
| 1289 | "[Version version contains these commits.](https://android.googlesource.com/" + \ |
| 1290 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n" |
| 1291 | ) |
| 1292 | self.assertEqual(releaseNotes.bugsFixed, []) |
| 1293 | |
| 1294 | def test_markdownCorrectlyFormatsForFiveArtifactsWithFalseRequiresSameVersion(self): |
| 1295 | releaseNotes = LibraryReleaseNotes( |
| 1296 | groupId = "groupId", |
| 1297 | artifactIds = ["artifact-Id1", "artifact-Id2", "artifact-Id3", |
| 1298 | "artifact-Id4", "artifact-Id5"], |
| 1299 | version = "version", |
| 1300 | releaseDate = "01-01-1970", |
| 1301 | fromSHA = "fromSHA", |
| 1302 | untilSHA = "untilSHA", |
| 1303 | projectDir = "projectDir", |
| 1304 | requiresSameVersion = False, |
| 1305 | commitList = [], |
| 1306 | forceIncludeAllCommits = False |
| 1307 | ) |
| 1308 | self.assertEqual(releaseNotes.groupId, "groupId") |
| 1309 | self.assertEqual(releaseNotes.artifactIds, |
| 1310 | ["artifact-Id1", "artifact-Id2", "artifact-Id3", |
| 1311 | "artifact-Id4", "artifact-Id5"]) |
| 1312 | self.assertEqual(releaseNotes.version, "version") |
| 1313 | self.assertEqual(str(releaseNotes.releaseDate), "January 1, 1970") |
| 1314 | self.assertEqual(releaseNotes.fromSHA, "fromSHA") |
| 1315 | self.assertEqual(releaseNotes.untilSHA, "untilSHA") |
| 1316 | self.assertEqual(releaseNotes.projectDir, "projectDir") |
| 1317 | self.assertEqual(releaseNotes.requiresSameVersion, False) |
| 1318 | self.assertEqual(releaseNotes.forceIncludeAllCommits, False) |
| 1319 | self.assertEqual(str(releaseNotes.header), |
| 1320 | "### Groupid Version version {:#version}") |
| 1321 | self.assertEqual(str(releaseNotes.diffLogLink), |
| 1322 | "[Version version contains" + \ |
| 1323 | " these commits.](https://android.googlesource.com/" + \ |
| 1324 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)" |
| 1325 | ) |
| 1326 | self.assertEqual(releaseNotes.commits, []) |
| 1327 | self.assertEqual(str(releaseNotes.commitMarkdownList), |
| 1328 | "\n**New Features**\n\n" + \ |
| 1329 | "\n**API Changes**\n\n" + \ |
| 1330 | "\n**Bug Fixes**\n\n" + \ |
| 1331 | "\n**External Contribution**\n\n" |
| 1332 | ) |
| 1333 | self.assertEqual(releaseNotes.getFormattedReleaseSummary(), |
| 1334 | "`groupId:artifact-*:version` is released. " + \ |
| 1335 | "[Version version contains these commits.](https://android.googlesource.com/" + \ |
| 1336 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n" |
| 1337 | ) |
| 1338 | self.assertEqual(releaseNotes.bugsFixed, []) |
| 1339 | |
| 1340 | def test_markdownCorrectlyCapitalizesGroupIds(self): |
| 1341 | releaseNotes = LibraryReleaseNotes( |
| 1342 | groupId = "androidx.recyclerview", |
| 1343 | artifactIds = ["recyclerview"], |
| 1344 | version = "version", |
| 1345 | releaseDate = "01-01-1970", |
| 1346 | fromSHA = "fromSHA", |
| 1347 | untilSHA = "untilSHA", |
| 1348 | projectDir = "projectDir", |
| 1349 | requiresSameVersion = False, |
| 1350 | commitList = [], |
| 1351 | forceIncludeAllCommits = False |
| 1352 | ) |
| 1353 | self.assertEqual(releaseNotes.groupId, "androidx.recyclerview") |
| 1354 | self.assertEqual(str(releaseNotes.header), |
| 1355 | "### RecyclerView Version version {:#recyclerview-version}") |
| 1356 | self.assertEqual(releaseNotes.getFormattedReleaseSummary(), |
| 1357 | "`androidx.recyclerview:recyclerview:version` is released. " + \ |
| 1358 | "[Version version contains these commits.](https://android.googlesource.com/" + \ |
| 1359 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n" |
| 1360 | ) |
| 1361 | |
| 1362 | releaseNotes = LibraryReleaseNotes( |
| 1363 | groupId = "androidx.swiperefreshlayout", |
| 1364 | artifactIds = ["swiperefreshlayout"], |
| 1365 | version = "version", |
| 1366 | releaseDate = "01-01-1970", |
| 1367 | fromSHA = "fromSHA", |
| 1368 | untilSHA = "untilSHA", |
| 1369 | projectDir = "projectDir", |
| 1370 | requiresSameVersion = True, |
| 1371 | commitList = [], |
| 1372 | forceIncludeAllCommits = False |
| 1373 | ) |
| 1374 | self.assertEqual(releaseNotes.groupId, "androidx.swiperefreshlayout") |
| 1375 | self.assertEqual(str(releaseNotes.header), |
| 1376 | "### SwipeRefreshLayout Version version {:#version}") |
| 1377 | self.assertEqual(releaseNotes.getFormattedReleaseSummary(), |
| 1378 | "`androidx.swiperefreshlayout:swiperefreshlayout:version` is released. " + \ |
| 1379 | "[Version version contains these commits.](https://android.googlesource.com/" + \ |
| 1380 | "platform/frameworks/support/+log/fromSHA..untilSHA/projectDir)\n" |
| 1381 | ) |
| 1382 | |
Nick Anthony | 917014b | 2020-05-08 08:24:09 -0400 | [diff] [blame] | 1383 | def test_markdownCorrectlyFormatsGittilesLinkWithNoFromSHA(self): |
| 1384 | releaseNotes = LibraryReleaseNotes( |
| 1385 | groupId = "groupId", |
| 1386 | artifactIds = ["artifactId"], |
| 1387 | version = "version", |
| 1388 | releaseDate = "01-01-1970", |
| 1389 | fromSHA = "", |
| 1390 | untilSHA = "untilSHA", |
| 1391 | projectDir = "projectDir", |
| 1392 | requiresSameVersion = True, |
| 1393 | commitList = [], |
| 1394 | forceIncludeAllCommits = False |
| 1395 | ) |
| 1396 | self.assertEqual(releaseNotes.fromSHA, "") |
| 1397 | self.assertEqual(releaseNotes.untilSHA, "untilSHA") |
| 1398 | self.assertEqual(releaseNotes.projectDir, "projectDir") |
| 1399 | self.assertEqual(str(releaseNotes.diffLogLink), |
| 1400 | "[Version version contains" + \ |
| 1401 | " these commits.](https://android.googlesource.com/" + \ |
| 1402 | "platform/frameworks/support/+log/untilSHA/projectDir)" |
| 1403 | ) |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 1404 | |
Nick Anthony | 6526d3b | 2020-07-09 16:41:41 -0400 | [diff] [blame] | 1405 | def test_markdownCorrectlyGeneratesChannelSummary(self): |
| 1406 | releaseNotes = LibraryReleaseNotes( |
| 1407 | groupId = "androidx.recyclerview", |
| 1408 | artifactIds = ["recyclerview"], |
| 1409 | version = "1.2.0-alpha04", |
| 1410 | releaseDate = "01-01-1970", |
| 1411 | fromSHA = "fromSHA", |
| 1412 | untilSHA = "untilSHA", |
| 1413 | projectDir = "projectDir", |
| 1414 | requiresSameVersion = False, |
| 1415 | commitList = [], |
| 1416 | forceIncludeAllCommits = False |
| 1417 | ) |
| 1418 | self.assertEqual(str(releaseNotes.channelSummary), |
| 1419 | "* [RecyclerView Version 1.2.0-alpha04]" + \ |
| 1420 | "(/jetpack/androidx/releases/recyclerview#recyclerview-1.2.0-alpha04)\n") |
| 1421 | |
| 1422 | releaseNotes = LibraryReleaseNotes( |
| 1423 | groupId = "groupId", |
| 1424 | artifactIds = ["artifact-Id1", "artifact-Id2", "artifact-Id3", |
| 1425 | "artifact-Id4", "artifact-Id5"], |
| 1426 | version = "version", |
| 1427 | releaseDate = "01-01-1970", |
| 1428 | fromSHA = "fromSHA", |
| 1429 | untilSHA = "untilSHA", |
| 1430 | projectDir = "projectDir", |
| 1431 | requiresSameVersion = False, |
| 1432 | commitList = [], |
| 1433 | forceIncludeAllCommits = False |
| 1434 | ) |
| 1435 | self.assertEqual(str(releaseNotes.channelSummary), |
| 1436 | "* [Groupid Version version]" + \ |
| 1437 | "(/jetpack/androidx/releases/groupid#version)\n") |
| 1438 | |
| 1439 | releaseNotes = LibraryReleaseNotes( |
| 1440 | groupId = "groupId", |
| 1441 | artifactIds = ["artifactId1", "artifactId2", "artifactId3"], |
| 1442 | version = "version", |
| 1443 | releaseDate = "01-01-1970", |
| 1444 | fromSHA = "fromSHA", |
| 1445 | untilSHA = "untilSHA", |
| 1446 | projectDir = "projectDir", |
| 1447 | requiresSameVersion = False, |
| 1448 | commitList = [], |
| 1449 | forceIncludeAllCommits = False |
| 1450 | ) |
| 1451 | self.assertEqual(str(releaseNotes.channelSummary), |
| 1452 | "* [Artifactid1 Artifactid2 Artifactid3 Version version]" + \ |
| 1453 | "(/jetpack/androidx/releases/groupid#version)\n") |
| 1454 | |
Nick Anthony | 7ea8ca9 | 2020-02-11 11:11:37 -0500 | [diff] [blame] | 1455 | if __name__ == '__main__': |
| 1456 | unittest.main() |