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>
This commit is contained in:
parent
6f6b8491da
commit
367894adc8
15 changed files with 222 additions and 173 deletions
|
@ -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 }
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue