diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-01-24 01:28:15 +0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2020-01-23 19:28:15 +0200 |
commit | f6067a8465e7762aea1561106cfee291409a0fd6 (patch) | |
tree | 35c97d4117acfe52dce32c9242e4c9a656c4bc6c /modules/migrations/github_test.go | |
parent | bfdfa9a8b32ae331f98137169693ba1d71c25b09 (diff) | |
download | gitea-f6067a8465e7762aea1561106cfee291409a0fd6.tar.gz gitea-f6067a8465e7762aea1561106cfee291409a0fd6.zip |
Migrate reviews when migrating repository from github (#9463)
* fix typo
* Migrate reviews when migrating repository from github
* fix lint
* Added test and migration when external user login
* fix test
* fix commented state
* Some improvements
* fix bug when get pull request and ref original author on code comments
* Fix migrated line; Added comment for review
* Don't load all pull requests attributes
* Fix typo
* wrong change copy head
* fix tests
* fix reactions
* Fix test
* fix fmt
* fix review comment reactions
Diffstat (limited to 'modules/migrations/github_test.go')
-rw-r--r-- | modules/migrations/github_test.go | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/modules/migrations/github_test.go b/modules/migrations/github_test.go index 9023e2ac4d..814c771e8c 100644 --- a/modules/migrations/github_test.go +++ b/modules/migrations/github_test.go @@ -361,4 +361,95 @@ func TestGitHubDownloadRepo(t *testing.T) { }, }, }, prs) + + reviews, err := downloader.GetReviews(3) + assert.NoError(t, err) + assert.EqualValues(t, []*base.Review{ + { + ID: 315859956, + IssueIndex: 3, + ReviewerID: 42128690, + ReviewerName: "jolheiser", + CommitID: "076160cf0b039f13e5eff19619932d181269414b", + CreatedAt: time.Date(2019, 11, 12, 21, 35, 24, 0, time.UTC), + State: base.ReviewStateApproved, + }, + { + ID: 315860062, + IssueIndex: 3, + ReviewerID: 1824502, + ReviewerName: "zeripath", + CommitID: "076160cf0b039f13e5eff19619932d181269414b", + CreatedAt: time.Date(2019, 11, 12, 21, 35, 36, 0, time.UTC), + State: base.ReviewStateApproved, + }, + { + ID: 315861440, + IssueIndex: 3, + ReviewerID: 165205, + ReviewerName: "lafriks", + CommitID: "076160cf0b039f13e5eff19619932d181269414b", + CreatedAt: time.Date(2019, 11, 12, 21, 38, 00, 0, time.UTC), + State: base.ReviewStateApproved, + }, + }, reviews) + + reviews, err = downloader.GetReviews(4) + assert.NoError(t, err) + assert.EqualValues(t, []*base.Review{ + { + ID: 338338740, + IssueIndex: 4, + ReviewerID: 81045, + ReviewerName: "lunny", + CommitID: "2be9101c543658591222acbee3eb799edfc3853d", + CreatedAt: time.Date(2020, 01, 04, 05, 33, 18, 0, time.UTC), + State: base.ReviewStateApproved, + Comments: []*base.ReviewComment{ + { + ID: 363017488, + Content: "This is a good pull request.", + TreePath: "README.md", + DiffHunk: "@@ -1,2 +1,4 @@\n # test_repo\n Test repository for testing migration from github to gitea\n+", + Position: 3, + CommitID: "2be9101c543658591222acbee3eb799edfc3853d", + PosterID: 81045, + CreatedAt: time.Date(2020, 01, 04, 05, 33, 06, 0, time.UTC), + UpdatedAt: time.Date(2020, 01, 04, 05, 33, 18, 0, time.UTC), + }, + }, + }, + { + ID: 338339651, + IssueIndex: 4, + ReviewerID: 81045, + ReviewerName: "lunny", + CommitID: "2be9101c543658591222acbee3eb799edfc3853d", + CreatedAt: time.Date(2020, 01, 04, 06, 07, 06, 0, time.UTC), + State: base.ReviewStateChangesRequested, + Content: "Don't add more reviews", + }, + { + ID: 338349019, + IssueIndex: 4, + ReviewerID: 81045, + ReviewerName: "lunny", + CommitID: "2be9101c543658591222acbee3eb799edfc3853d", + CreatedAt: time.Date(2020, 01, 04, 11, 21, 41, 0, time.UTC), + State: base.ReviewStateCommented, + Comments: []*base.ReviewComment{ + { + ID: 363029944, + Content: "test a single comment.", + TreePath: "LICENSE", + DiffHunk: "@@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n+", + Position: 4, + CommitID: "2be9101c543658591222acbee3eb799edfc3853d", + PosterID: 81045, + CreatedAt: time.Date(2020, 01, 04, 11, 21, 41, 0, time.UTC), + UpdatedAt: time.Date(2020, 01, 04, 11, 21, 41, 0, time.UTC), + }, + }, + }, + }, reviews) } |