mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-20 16:50:28 -05:00
Fixup the lint required for CI
Signed-off-by: Litchi Pi <litchi.pi@proton.me>
This commit is contained in:
parent
8ae2e4b2ef
commit
c993e4a157
2 changed files with 105 additions and 111 deletions
|
@ -41,7 +41,6 @@ func (agg *CommentAggregator) aggregateComment(c *Comment, index int) {
|
|||
} else {
|
||||
agg.addReviewRequest(req)
|
||||
}
|
||||
|
||||
} else if c.AssigneeTeamID > 0 {
|
||||
req := RequestReviewTarget{Team: c.AssigneeTeam}
|
||||
if c.RemovedAssignee {
|
||||
|
@ -54,10 +53,10 @@ func (agg *CommentAggregator) aggregateComment(c *Comment, index int) {
|
|||
for _, r := range c.RemovedRequestReview {
|
||||
agg.delReviewRequest(r)
|
||||
}
|
||||
|
||||
for _, r := range c.AddedRequestReview {
|
||||
agg.addReviewRequest(r)
|
||||
}
|
||||
|
||||
} else if c.Type == CommentTypeLabel {
|
||||
if c.Content == "1" {
|
||||
agg.addLabel(c.Label)
|
||||
|
@ -227,7 +226,7 @@ func (agg *CommentAggregator) createAggregatedComment(issue *Issue, final bool)
|
|||
return endind - startind
|
||||
}
|
||||
|
||||
new_agg := *agg // Trigger a memory allocation, get a COPY of the aggregator
|
||||
newAgg := *agg // Trigger a memory allocation, get a COPY of the aggregator
|
||||
|
||||
// Keep the same author, time, etc... But reset the parts we may want to use
|
||||
comment := issue.Comments[startind]
|
||||
|
@ -256,23 +255,23 @@ func (agg *CommentAggregator) createAggregatedComment(issue *Issue, final bool)
|
|||
comment.Type = CommentTypeReviewRequest
|
||||
} else {
|
||||
comment.Type = CommentTypeAggregator
|
||||
comment.Aggregator = &new_agg
|
||||
comment.Aggregator = &newAgg
|
||||
}
|
||||
|
||||
if len(new_agg.AddedLabels) > 0 {
|
||||
comment.AddedLabels = new_agg.AddedLabels
|
||||
if len(newAgg.AddedLabels) > 0 {
|
||||
comment.AddedLabels = newAgg.AddedLabels
|
||||
}
|
||||
|
||||
if len(new_agg.RemovedLabels) > 0 {
|
||||
comment.RemovedLabels = new_agg.RemovedLabels
|
||||
if len(newAgg.RemovedLabels) > 0 {
|
||||
comment.RemovedLabels = newAgg.RemovedLabels
|
||||
}
|
||||
|
||||
if len(new_agg.AddedRequestReview) > 0 {
|
||||
comment.AddedRequestReview = new_agg.AddedRequestReview
|
||||
if len(newAgg.AddedRequestReview) > 0 {
|
||||
comment.AddedRequestReview = newAgg.AddedRequestReview
|
||||
}
|
||||
|
||||
if len(new_agg.RemovedRequestReview) > 0 {
|
||||
comment.RemovedRequestReview = new_agg.RemovedRequestReview
|
||||
if len(newAgg.RemovedRequestReview) > 0 {
|
||||
comment.RemovedRequestReview = newAgg.RemovedRequestReview
|
||||
}
|
||||
|
||||
if final {
|
||||
|
@ -289,23 +288,21 @@ func CombineCommentsHistory(issue *Issue) {
|
|||
var agg CommentAggregator
|
||||
agg.StartUnix = 0
|
||||
agg.PosterID = -1
|
||||
req_reset := false
|
||||
reqReset := false
|
||||
|
||||
for i := 0; i < len(issue.Comments); i++ {
|
||||
cur := issue.Comments[i]
|
||||
if req_reset {
|
||||
if reqReset {
|
||||
agg.Reset(cur)
|
||||
req_reset = false
|
||||
reqReset = false
|
||||
}
|
||||
|
||||
// If the comment we encounter is not accepted inside an aggregator
|
||||
if !agg.IsAggregated(&cur.Type) {
|
||||
|
||||
// If we aggregated some data, create the resulting comment for it
|
||||
if len(agg.Indexes) > 0 {
|
||||
i -= agg.createAggregatedComment(issue, false)
|
||||
}
|
||||
req_reset = true
|
||||
reqReset = true
|
||||
|
||||
// Do not need to continue the aggregation loop, skip to next comment
|
||||
continue
|
||||
|
@ -325,7 +322,7 @@ func CombineCommentsHistory(issue *Issue) {
|
|||
}
|
||||
|
||||
// Create the aggregated comment if there's data in it
|
||||
if !req_reset && len(agg.Indexes) > 0 {
|
||||
if !reqReset && len(agg.Indexes) > 0 {
|
||||
agg.createAggregatedComment(issue, true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"testing"
|
||||
|
||||
issue_model "code.gitea.io/gitea/models/issues"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/organization"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
@ -18,8 +17,8 @@ import (
|
|||
|
||||
// *************** Helper functions for the tests ***************
|
||||
|
||||
func testComment(t int64) *issues_model.Comment {
|
||||
return &issues_model.Comment{PosterID: 1, CreatedUnix: timeutil.TimeStamp(t)}
|
||||
func testComment(t int64) *issue_model.Comment {
|
||||
return &issue_model.Comment{PosterID: 1, CreatedUnix: timeutil.TimeStamp(t)}
|
||||
}
|
||||
|
||||
func nameToID(name string) int64 {
|
||||
|
@ -30,15 +29,13 @@ func nameToID(name string) int64 {
|
|||
return id
|
||||
}
|
||||
|
||||
func createReqReviewTarget(name string) issues_model.RequestReviewTarget {
|
||||
func createReqReviewTarget(name string) issue_model.RequestReviewTarget {
|
||||
if bytes.HasSuffix([]byte(name), []byte("-team")) {
|
||||
team := createTeam(name)
|
||||
return issues_model.RequestReviewTarget{Team: &team}
|
||||
|
||||
} else {
|
||||
user := createUser(name)
|
||||
return issues_model.RequestReviewTarget{User: &user}
|
||||
return issue_model.RequestReviewTarget{Team: &team}
|
||||
}
|
||||
user := createUser(name)
|
||||
return issue_model.RequestReviewTarget{User: &user}
|
||||
}
|
||||
|
||||
func createUser(name string) user_model.User {
|
||||
|
@ -49,27 +46,27 @@ func createTeam(name string) organization.Team {
|
|||
return organization.Team{Name: name, ID: nameToID(name)}
|
||||
}
|
||||
|
||||
func createLabel(name string) issues_model.Label {
|
||||
return issues_model.Label{Name: name, ID: nameToID(name)}
|
||||
func createLabel(name string) issue_model.Label {
|
||||
return issue_model.Label{Name: name, ID: nameToID(name)}
|
||||
}
|
||||
|
||||
func addLabel(t int64, name string) *issues_model.Comment {
|
||||
func addLabel(t int64, name string) *issue_model.Comment {
|
||||
c := testComment(t)
|
||||
c.Type = issue_model.CommentTypeLabel
|
||||
c.Content = "1"
|
||||
lbl := createLabel(name)
|
||||
c.Label = &lbl
|
||||
c.AddedLabels = []*issues_model.Label{&lbl}
|
||||
c.AddedLabels = []*issue_model.Label{&lbl}
|
||||
return c
|
||||
}
|
||||
|
||||
func delLabel(t int64, name string) *issues_model.Comment {
|
||||
func delLabel(t int64, name string) *issue_model.Comment {
|
||||
c := addLabel(t, name)
|
||||
c.Content = ""
|
||||
return c
|
||||
}
|
||||
|
||||
func openOrClose(t int64, close bool) *issues_model.Comment {
|
||||
func openOrClose(t int64, close bool) *issue_model.Comment {
|
||||
c := testComment(t)
|
||||
if close {
|
||||
c.Type = issue_model.CommentTypeClose
|
||||
|
@ -79,7 +76,7 @@ func openOrClose(t int64, close bool) *issues_model.Comment {
|
|||
return c
|
||||
}
|
||||
|
||||
func reqReview(t int64, name string, delReq bool) *issues_model.Comment {
|
||||
func reqReview(t int64, name string, delReq bool) *issue_model.Comment {
|
||||
c := testComment(t)
|
||||
c.Type = issue_model.CommentTypeReviewRequest
|
||||
if bytes.HasSuffix([]byte(name), []byte("-team")) {
|
||||
|
@ -95,8 +92,8 @@ func reqReview(t int64, name string, delReq bool) *issues_model.Comment {
|
|||
return c
|
||||
}
|
||||
|
||||
func reqReviewList(t int64, del bool, names ...string) *issues_model.Comment {
|
||||
req := []issues_model.RequestReviewTarget{}
|
||||
func reqReviewList(t int64, del bool, names ...string) *issue_model.Comment {
|
||||
req := []issue_model.RequestReviewTarget{}
|
||||
for _, name := range names {
|
||||
req = append(req, createReqReviewTarget(name))
|
||||
}
|
||||
|
@ -112,14 +109,14 @@ func reqReviewList(t int64, del bool, names ...string) *issues_model.Comment {
|
|||
|
||||
func aggregatedComment(t int64,
|
||||
closed bool,
|
||||
addLabels []*issues_model.Label,
|
||||
delLabels []*issues_model.Label,
|
||||
addReqReview []issues_model.RequestReviewTarget,
|
||||
delReqReview []issues_model.RequestReviewTarget,
|
||||
) *issues_model.Comment {
|
||||
addLabels []*issue_model.Label,
|
||||
delLabels []*issue_model.Label,
|
||||
addReqReview []issue_model.RequestReviewTarget,
|
||||
delReqReview []issue_model.RequestReviewTarget,
|
||||
) *issue_model.Comment {
|
||||
cmnt := testComment(t)
|
||||
cmnt.Type = issues_model.CommentTypeAggregator
|
||||
cmnt.Aggregator = &issues_model.CommentAggregator{
|
||||
cmnt.Type = issue_model.CommentTypeAggregator
|
||||
cmnt.Aggregator = &issue_model.CommentAggregator{
|
||||
IsClosed: closed,
|
||||
AddedLabels: addLabels,
|
||||
RemovedLabels: delLabels,
|
||||
|
@ -141,7 +138,7 @@ func aggregatedComment(t int64,
|
|||
return cmnt
|
||||
}
|
||||
|
||||
func commentText(t int64, text string) *issues_model.Comment {
|
||||
func commentText(t int64, text string) *issue_model.Comment {
|
||||
c := testComment(t)
|
||||
c.Type = issue_model.CommentTypeComment
|
||||
c.Content = text
|
||||
|
@ -152,14 +149,14 @@ func commentText(t int64, text string) *issues_model.Comment {
|
|||
|
||||
type testCase struct {
|
||||
name string
|
||||
beforeCombined []*issues_model.Comment
|
||||
afterCombined []*issues_model.Comment
|
||||
beforeCombined []*issue_model.Comment
|
||||
afterCombined []*issue_model.Comment
|
||||
sameAfter bool
|
||||
}
|
||||
|
||||
func (kase *testCase) doTest(t *testing.T) {
|
||||
issue := issues_model.Issue{Comments: kase.beforeCombined}
|
||||
issues_model.CombineCommentsHistory(&issue)
|
||||
issue := issue_model.Issue{Comments: kase.beforeCombined}
|
||||
issue_model.CombineCommentsHistory(&issue)
|
||||
|
||||
after := &kase.afterCombined
|
||||
if kase.sameAfter {
|
||||
|
@ -214,7 +211,7 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
// ADD single = normal label comment
|
||||
{
|
||||
name: "add_single_label",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(0, "a"),
|
||||
commentText(10, "I'm a salmon"),
|
||||
},
|
||||
|
@ -224,12 +221,12 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
// ADD then REMOVE = Nothing
|
||||
{
|
||||
name: "add_label_then_remove",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(0, "a"),
|
||||
delLabel(1, "a"),
|
||||
commentText(65, "I'm a salmon"),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
commentText(65, "I'm a salmon"),
|
||||
},
|
||||
},
|
||||
|
@ -237,7 +234,7 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
// ADD 1 then comment then REMOVE = separate comments
|
||||
{
|
||||
name: "add_label_then_comment_then_remove",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(0, "a"),
|
||||
commentText(10, "I'm a salmon"),
|
||||
delLabel(20, "a"),
|
||||
|
@ -248,7 +245,7 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
// ADD 2 = Combined labels
|
||||
{
|
||||
name: "combine_labels",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(0, "a"),
|
||||
addLabel(10, "b"),
|
||||
commentText(20, "I'm a salmon"),
|
||||
|
@ -257,12 +254,12 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
addLabel(85, "e"),
|
||||
delLabel(90, "c"),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
{
|
||||
PosterID: 1,
|
||||
Type: issue_model.CommentTypeLabel,
|
||||
CreatedUnix: timeutil.TimeStamp(0),
|
||||
AddedLabels: []*issues_model.Label{
|
||||
AddedLabels: []*issue_model.Label{
|
||||
{Name: "a", ID: nameToID("a")},
|
||||
{Name: "b", ID: nameToID("b")},
|
||||
},
|
||||
|
@ -272,7 +269,7 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
PosterID: 1,
|
||||
Type: issue_model.CommentTypeLabel,
|
||||
CreatedUnix: timeutil.TimeStamp(30),
|
||||
AddedLabels: []*issues_model.Label{
|
||||
AddedLabels: []*issue_model.Label{
|
||||
{Name: "d", ID: nameToID("d")},
|
||||
{Name: "e", ID: nameToID("e")},
|
||||
},
|
||||
|
@ -283,17 +280,17 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
// ADD 1, then 1 later = 2 separate comments
|
||||
{
|
||||
name: "add_then_later_label",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(0, "a"),
|
||||
addLabel(60, "b"),
|
||||
addLabel(121, "c"),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
{
|
||||
PosterID: 1,
|
||||
Type: issue_model.CommentTypeLabel,
|
||||
CreatedUnix: timeutil.TimeStamp(0),
|
||||
AddedLabels: []*issues_model.Label{
|
||||
AddedLabels: []*issue_model.Label{
|
||||
{Name: "a", ID: nameToID("a")},
|
||||
{Name: "b", ID: nameToID("b")},
|
||||
},
|
||||
|
@ -305,12 +302,12 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
// ADD 2 then REMOVE 1 = label
|
||||
{
|
||||
name: "add_2_remove_1",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(0, "a"),
|
||||
addLabel(10, "b"),
|
||||
delLabel(20, "a"),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
// The timestamp will be the one of the first aggregated comment
|
||||
addLabel(0, "b"),
|
||||
},
|
||||
|
@ -319,7 +316,7 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
// ADD then REMOVE multiple = nothing
|
||||
{
|
||||
name: "add_multiple_remove_all",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(0, "a"),
|
||||
addLabel(1, "b"),
|
||||
addLabel(2, "c"),
|
||||
|
@ -337,18 +334,18 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
// ADD 2, wait, REMOVE 2 = +2 then -2 comments
|
||||
{
|
||||
name: "add2_wait_rm2_labels",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(0, "a"),
|
||||
addLabel(1, "b"),
|
||||
delLabel(120, "a"),
|
||||
delLabel(121, "b"),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
{
|
||||
PosterID: 1,
|
||||
Type: issue_model.CommentTypeLabel,
|
||||
CreatedUnix: timeutil.TimeStamp(0),
|
||||
AddedLabels: []*issues_model.Label{
|
||||
AddedLabels: []*issue_model.Label{
|
||||
{Name: "a", ID: nameToID("a")},
|
||||
{Name: "b", ID: nameToID("b")},
|
||||
},
|
||||
|
@ -357,7 +354,7 @@ func TestCombineLabelComments(t *testing.T) {
|
|||
PosterID: 1,
|
||||
Type: issue_model.CommentTypeLabel,
|
||||
CreatedUnix: timeutil.TimeStamp(120),
|
||||
RemovedLabels: []*issues_model.Label{
|
||||
RemovedLabels: []*issue_model.Label{
|
||||
{Name: "a", ID: nameToID("a")},
|
||||
{Name: "b", ID: nameToID("b")},
|
||||
},
|
||||
|
@ -376,7 +373,7 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
// ADD single = normal request review comment
|
||||
{
|
||||
name: "add_single_review",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(0, "toto", false),
|
||||
commentText(10, "I'm a salmon"),
|
||||
reqReview(0, "toto-team", false),
|
||||
|
@ -387,12 +384,12 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
// ADD then REMOVE = Nothing
|
||||
{
|
||||
name: "add_then_remove_review",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(0, "toto", false),
|
||||
reqReview(5, "toto", true),
|
||||
commentText(10, "I'm a salmon"),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
commentText(10, "I'm a salmon"),
|
||||
},
|
||||
},
|
||||
|
@ -400,7 +397,7 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
// ADD 1 then comment then REMOVE = separate comments
|
||||
{
|
||||
name: "add_comment_del_review",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(0, "toto", false),
|
||||
commentText(5, "I'm a salmon"),
|
||||
reqReview(10, "toto", true),
|
||||
|
@ -411,7 +408,7 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
// ADD 2 = Combined request reviews
|
||||
{
|
||||
name: "combine_reviews",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(0, "toto", false),
|
||||
reqReview(10, "tutu-team", false),
|
||||
commentText(20, "I'm a salmon"),
|
||||
|
@ -420,7 +417,7 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
reqReview(85, "tyty-team", false),
|
||||
reqReview(90, "titi", true),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
reqReviewList(0, false, "toto", "tutu-team"),
|
||||
commentText(20, "I'm a salmon"),
|
||||
reqReviewList(30, false, "tata", "tyty-team"),
|
||||
|
@ -430,12 +427,12 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
// ADD 1, then 1 later = 2 separate comments
|
||||
{
|
||||
name: "add_then_later_review",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(0, "titi", false),
|
||||
reqReview(60, "toto-team", false),
|
||||
reqReview(121, "tutu", false),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
reqReviewList(0, false, "titi", "toto-team"),
|
||||
reqReviewList(121, false, "tutu"),
|
||||
},
|
||||
|
@ -444,12 +441,12 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
// ADD 2 then REMOVE 1 = single request review
|
||||
{
|
||||
name: "add_2_then_remove_review",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(0, "titi-team", false),
|
||||
reqReview(59, "toto", false),
|
||||
reqReview(60, "titi-team", true),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
reqReviewList(0, false, "toto"),
|
||||
},
|
||||
},
|
||||
|
@ -457,7 +454,7 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
// ADD then REMOVE multiple = nothing
|
||||
{
|
||||
name: "add_multiple_then_remove_all_review",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(0, "titi0-team", false),
|
||||
reqReview(1, "toto1", false),
|
||||
reqReview(2, "titi2", false),
|
||||
|
@ -479,13 +476,13 @@ func TestCombineReviewRequests(t *testing.T) {
|
|||
// ADD 2, wait, REMOVE 2 = +2 then -2 comments
|
||||
{
|
||||
name: "add2_wait_rm2_requests",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(1, "titi", false),
|
||||
reqReview(2, "toto-team", false),
|
||||
reqReview(121, "titi", true),
|
||||
reqReview(122, "toto-team", true),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
reqReviewList(1, false, "titi", "toto-team"),
|
||||
reqReviewList(121, true, "titi", "toto-team"),
|
||||
},
|
||||
|
@ -502,7 +499,7 @@ func TestCombineOpenClose(t *testing.T) {
|
|||
// Close then open = nullified
|
||||
{
|
||||
name: "close_open_nullified",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
openOrClose(0, true),
|
||||
openOrClose(10, false),
|
||||
},
|
||||
|
@ -512,7 +509,7 @@ func TestCombineOpenClose(t *testing.T) {
|
|||
// Close then open later = separate comments
|
||||
{
|
||||
name: "close_open_later",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
openOrClose(0, true),
|
||||
openOrClose(61, false),
|
||||
},
|
||||
|
@ -522,7 +519,7 @@ func TestCombineOpenClose(t *testing.T) {
|
|||
// Close then comment then open = separate comments
|
||||
{
|
||||
name: "close_comment_open",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
openOrClose(0, true),
|
||||
commentText(1, "I'm a salmon"),
|
||||
openOrClose(2, false),
|
||||
|
@ -537,12 +534,12 @@ func TestCombineOpenClose(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCombineMultipleDifferentComments(t *testing.T) {
|
||||
lbl_a := createLabel("a")
|
||||
lblA := createLabel("a")
|
||||
kases := []testCase{
|
||||
// Add Label + Close + ReqReview = Combined
|
||||
{
|
||||
name: "label_close_reqreview_combined",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
reqReview(1, "toto", false),
|
||||
addLabel(2, "a"),
|
||||
openOrClose(3, true),
|
||||
|
@ -551,20 +548,20 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
|
|||
openOrClose(102, false),
|
||||
delLabel(103, "a"),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
aggregatedComment(1,
|
||||
true,
|
||||
[]*issues_model.Label{&lbl_a},
|
||||
[]*issues_model.Label{},
|
||||
[]issues_model.RequestReviewTarget{createReqReviewTarget("toto")},
|
||||
[]issues_model.RequestReviewTarget{},
|
||||
[]*issue_model.Label{&lblA},
|
||||
[]*issue_model.Label{},
|
||||
[]issue_model.RequestReviewTarget{createReqReviewTarget("toto")},
|
||||
[]issue_model.RequestReviewTarget{},
|
||||
),
|
||||
aggregatedComment(101,
|
||||
false,
|
||||
[]*issues_model.Label{},
|
||||
[]*issues_model.Label{&lbl_a},
|
||||
[]issues_model.RequestReviewTarget{},
|
||||
[]issues_model.RequestReviewTarget{createReqReviewTarget("toto")},
|
||||
[]*issue_model.Label{},
|
||||
[]*issue_model.Label{&lblA},
|
||||
[]issue_model.RequestReviewTarget{},
|
||||
[]issue_model.RequestReviewTarget{createReqReviewTarget("toto")},
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -572,14 +569,14 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
|
|||
// Add Req + Add Label + Close + Del Req + Del Label = Close only
|
||||
{
|
||||
name: "req_label_close_dellabel_delreq",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(2, "a"),
|
||||
reqReview(3, "titi", false),
|
||||
openOrClose(4, true),
|
||||
delLabel(5, "a"),
|
||||
reqReview(6, "titi", true),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
openOrClose(2, true),
|
||||
},
|
||||
},
|
||||
|
@ -587,14 +584,14 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
|
|||
// Close + Add Req + Add Label + Del Req + Open = Label only
|
||||
{
|
||||
name: "close_req_label_open_delreq",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
openOrClose(2, true),
|
||||
reqReview(4, "titi", false),
|
||||
addLabel(5, "a"),
|
||||
reqReview(6, "titi", true),
|
||||
openOrClose(8, false),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
addLabel(2, "a"),
|
||||
},
|
||||
},
|
||||
|
@ -602,14 +599,14 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
|
|||
// Add Label + Close + Add ReqReview + Del Label + Open = ReqReview only
|
||||
{
|
||||
name: "label_close_req_dellabel_open",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(1, "a"),
|
||||
openOrClose(2, true),
|
||||
reqReview(4, "titi", false),
|
||||
openOrClose(7, false),
|
||||
delLabel(8, "a"),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
reqReview(1, "titi", false),
|
||||
},
|
||||
},
|
||||
|
@ -617,7 +614,7 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
|
|||
// Add Label + Close + ReqReview, then delete everything = nothing
|
||||
{
|
||||
name: "add_multiple_delete_everything",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(1, "a"),
|
||||
openOrClose(2, true),
|
||||
reqReview(4, "titi", false),
|
||||
|
@ -631,7 +628,7 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
|
|||
// Add multiple, then comment, then delete everything = separate aggregation
|
||||
{
|
||||
name: "add_multiple_comment_delete_everything",
|
||||
beforeCombined: []*issues_model.Comment{
|
||||
beforeCombined: []*issue_model.Comment{
|
||||
addLabel(1, "a"),
|
||||
openOrClose(2, true),
|
||||
reqReview(4, "titi", false),
|
||||
|
@ -642,21 +639,21 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
|
|||
delLabel(8, "a"),
|
||||
reqReview(10, "titi", true),
|
||||
},
|
||||
afterCombined: []*issues_model.Comment{
|
||||
afterCombined: []*issue_model.Comment{
|
||||
aggregatedComment(1,
|
||||
true,
|
||||
[]*issues_model.Label{&lbl_a},
|
||||
[]*issues_model.Label{},
|
||||
[]issues_model.RequestReviewTarget{createReqReviewTarget("titi")},
|
||||
[]issues_model.RequestReviewTarget{},
|
||||
[]*issue_model.Label{&lblA},
|
||||
[]*issue_model.Label{},
|
||||
[]issue_model.RequestReviewTarget{createReqReviewTarget("titi")},
|
||||
[]issue_model.RequestReviewTarget{},
|
||||
),
|
||||
commentText(6, "I'm a salmon"),
|
||||
aggregatedComment(7,
|
||||
false,
|
||||
[]*issues_model.Label{},
|
||||
[]*issues_model.Label{&lbl_a},
|
||||
[]issues_model.RequestReviewTarget{},
|
||||
[]issues_model.RequestReviewTarget{createReqReviewTarget("titi")},
|
||||
[]*issue_model.Label{},
|
||||
[]*issue_model.Label{&lblA},
|
||||
[]issue_model.RequestReviewTarget{},
|
||||
[]issue_model.RequestReviewTarget{createReqReviewTarget("titi")},
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue