aboutsummaryrefslogtreecommitdiffstats
path: root/modules/migration
diff options
context:
space:
mode:
authorsinguliere <35190819+singuliere@users.noreply.github.com>2022-02-01 19:20:28 +0100
committerGitHub <noreply@github.com>2022-02-01 13:20:28 -0500
commit367894adc820964135095e50c1ae6d6a0b2b0310 (patch)
tree6b773809f2c3c722251e902b244a074bdf8ec1a5 /modules/migration
parent6f6b8491da0d98121c8cab5c48f95425efa9606d (diff)
downloadgitea-367894adc820964135095e50c1ae6d6a0b2b0310.tar.gz
gitea-367894adc820964135095e50c1ae6d6a0b2b0310.zip
add test coverage for original author conversion during migrations (#18506)
* add test coverage for original author conversion during migrations And create a function to factorize a code snippet that is repeated five times and would otherwise be more difficult to test and maintain consistently. Signed-off-by: Loïc Dachary <loic@dachary.org> * fix variable scope and int64 formatting * add missing calls to remapExternalUser and fix misplaced %d Co-authored-by: Loïc Dachary <loic@dachary.org> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules/migration')
-rw-r--r--modules/migration/comment.go6
-rw-r--r--modules/migration/issue.go6
-rw-r--r--modules/migration/pullrequest.go6
-rw-r--r--modules/migration/reaction.go6
-rw-r--r--modules/migration/release.go6
-rw-r--r--modules/migration/review.go6
6 files changed, 36 insertions, 0 deletions
diff --git a/modules/migration/comment.go b/modules/migration/comment.go
index 234fea3e82..36277129d9 100644
--- a/modules/migration/comment.go
+++ b/modules/migration/comment.go
@@ -18,3 +18,9 @@ type Comment struct {
Content string
Reactions []*Reaction
}
+
+// GetExternalName ExternalUserMigrated interface
+func (c *Comment) GetExternalName() string { return c.PosterName }
+
+// ExternalID ExternalUserMigrated interface
+func (c *Comment) GetExternalID() int64 { return c.PosterID }
diff --git a/modules/migration/issue.go b/modules/migration/issue.go
index 19781ad984..984f07d8c9 100644
--- a/modules/migration/issue.go
+++ b/modules/migration/issue.go
@@ -46,3 +46,9 @@ type Issue struct {
Assignees []string `json:"assignees"`
Context IssueContext `yaml:"-"`
}
+
+// GetExternalName ExternalUserMigrated interface
+func (i *Issue) GetExternalName() string { return i.PosterName }
+
+// GetExternalID ExternalUserMigrated interface
+func (i *Issue) GetExternalID() int64 { return i.PosterID }
diff --git a/modules/migration/pullrequest.go b/modules/migration/pullrequest.go
index bbf1fe7653..7a681940a7 100644
--- a/modules/migration/pullrequest.go
+++ b/modules/migration/pullrequest.go
@@ -61,3 +61,9 @@ type PullRequestBranch struct {
func (p PullRequestBranch) RepoPath() string {
return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName)
}
+
+// GetExternalName ExternalUserMigrated interface
+func (p *PullRequest) GetExternalName() string { return p.PosterName }
+
+// ExternalID ExternalUserMigrated interface
+func (p *PullRequest) GetExternalID() int64 { return p.PosterID }
diff --git a/modules/migration/reaction.go b/modules/migration/reaction.go
index 2ba44a15a2..0946bdd40b 100644
--- a/modules/migration/reaction.go
+++ b/modules/migration/reaction.go
@@ -10,3 +10,9 @@ type Reaction struct {
UserName string `yaml:"user_name" json:"user_name"`
Content string `json:"content"`
}
+
+// GetExternalName ExternalUserMigrated interface
+func (r *Reaction) GetExternalName() string { return r.UserName }
+
+// GetExternalID ExternalUserMigrated interface
+func (r *Reaction) GetExternalID() int64 { return r.UserID }
diff --git a/modules/migration/release.go b/modules/migration/release.go
index a83f5502cb..cbdf01a3ed 100644
--- a/modules/migration/release.go
+++ b/modules/migration/release.go
@@ -38,3 +38,9 @@ type Release struct {
Created time.Time
Published time.Time
}
+
+// GetExternalName ExternalUserMigrated interface
+func (r *Release) GetExternalName() string { return r.PublisherName }
+
+// GetExternalID ExternalUserMigrated interface
+func (r *Release) GetExternalID() int64 { return r.PublisherID }
diff --git a/modules/migration/review.go b/modules/migration/review.go
index d6d15002af..85795385e9 100644
--- a/modules/migration/review.go
+++ b/modules/migration/review.go
@@ -28,6 +28,12 @@ type Review struct {
Comments []*ReviewComment
}
+// GetExternalName ExternalUserMigrated interface
+func (r *Review) GetExternalName() string { return r.ReviewerName }
+
+// ExternalID ExternalUserMigrated interface
+func (r *Review) GetExternalID() int64 { return r.ReviewerID }
+
// ReviewComment represents a review comment
type ReviewComment struct {
ID int64