0
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-01-31 18:05:00 -05:00

Fixup the lint required for CI

Signed-off-by: Litchi Pi <litchi.pi@proton.me>
This commit is contained in:
Litchi Pi 2025-01-20 17:09:04 +01:00
parent 8ae2e4b2ef
commit c993e4a157
2 changed files with 105 additions and 111 deletions

View file

@ -41,7 +41,6 @@ func (agg *CommentAggregator) aggregateComment(c *Comment, index int) {
} else { } else {
agg.addReviewRequest(req) agg.addReviewRequest(req)
} }
} else if c.AssigneeTeamID > 0 { } else if c.AssigneeTeamID > 0 {
req := RequestReviewTarget{Team: c.AssigneeTeam} req := RequestReviewTarget{Team: c.AssigneeTeam}
if c.RemovedAssignee { if c.RemovedAssignee {
@ -54,10 +53,10 @@ func (agg *CommentAggregator) aggregateComment(c *Comment, index int) {
for _, r := range c.RemovedRequestReview { for _, r := range c.RemovedRequestReview {
agg.delReviewRequest(r) agg.delReviewRequest(r)
} }
for _, r := range c.AddedRequestReview { for _, r := range c.AddedRequestReview {
agg.addReviewRequest(r) agg.addReviewRequest(r)
} }
} else if c.Type == CommentTypeLabel { } else if c.Type == CommentTypeLabel {
if c.Content == "1" { if c.Content == "1" {
agg.addLabel(c.Label) agg.addLabel(c.Label)
@ -227,7 +226,7 @@ func (agg *CommentAggregator) createAggregatedComment(issue *Issue, final bool)
return endind - startind 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 // Keep the same author, time, etc... But reset the parts we may want to use
comment := issue.Comments[startind] comment := issue.Comments[startind]
@ -256,23 +255,23 @@ func (agg *CommentAggregator) createAggregatedComment(issue *Issue, final bool)
comment.Type = CommentTypeReviewRequest comment.Type = CommentTypeReviewRequest
} else { } else {
comment.Type = CommentTypeAggregator comment.Type = CommentTypeAggregator
comment.Aggregator = &new_agg comment.Aggregator = &newAgg
} }
if len(new_agg.AddedLabels) > 0 { if len(newAgg.AddedLabels) > 0 {
comment.AddedLabels = new_agg.AddedLabels comment.AddedLabels = newAgg.AddedLabels
} }
if len(new_agg.RemovedLabels) > 0 { if len(newAgg.RemovedLabels) > 0 {
comment.RemovedLabels = new_agg.RemovedLabels comment.RemovedLabels = newAgg.RemovedLabels
} }
if len(new_agg.AddedRequestReview) > 0 { if len(newAgg.AddedRequestReview) > 0 {
comment.AddedRequestReview = new_agg.AddedRequestReview comment.AddedRequestReview = newAgg.AddedRequestReview
} }
if len(new_agg.RemovedRequestReview) > 0 { if len(newAgg.RemovedRequestReview) > 0 {
comment.RemovedRequestReview = new_agg.RemovedRequestReview comment.RemovedRequestReview = newAgg.RemovedRequestReview
} }
if final { if final {
@ -289,23 +288,21 @@ func CombineCommentsHistory(issue *Issue) {
var agg CommentAggregator var agg CommentAggregator
agg.StartUnix = 0 agg.StartUnix = 0
agg.PosterID = -1 agg.PosterID = -1
req_reset := false reqReset := false
for i := 0; i < len(issue.Comments); i++ { for i := 0; i < len(issue.Comments); i++ {
cur := issue.Comments[i] cur := issue.Comments[i]
if req_reset { if reqReset {
agg.Reset(cur) agg.Reset(cur)
req_reset = false reqReset = false
} }
// If the comment we encounter is not accepted inside an aggregator // If the comment we encounter is not accepted inside an aggregator
if !agg.IsAggregated(&cur.Type) { if !agg.IsAggregated(&cur.Type) {
// If we aggregated some data, create the resulting comment for it // If we aggregated some data, create the resulting comment for it
if len(agg.Indexes) > 0 { if len(agg.Indexes) > 0 {
i -= agg.createAggregatedComment(issue, false) i -= agg.createAggregatedComment(issue, false)
} }
req_reset = true reqReset = true
// Do not need to continue the aggregation loop, skip to next comment // Do not need to continue the aggregation loop, skip to next comment
continue continue
@ -325,7 +322,7 @@ func CombineCommentsHistory(issue *Issue) {
} }
// Create the aggregated comment if there's data in it // 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) agg.createAggregatedComment(issue, true)
} }
} }

View file

@ -8,7 +8,6 @@ import (
"testing" "testing"
issue_model "code.gitea.io/gitea/models/issues" issue_model "code.gitea.io/gitea/models/issues"
issues_model "code.gitea.io/gitea/models/issues"
"code.gitea.io/gitea/models/organization" "code.gitea.io/gitea/models/organization"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/timeutil"
@ -18,8 +17,8 @@ import (
// *************** Helper functions for the tests *************** // *************** Helper functions for the tests ***************
func testComment(t int64) *issues_model.Comment { func testComment(t int64) *issue_model.Comment {
return &issues_model.Comment{PosterID: 1, CreatedUnix: timeutil.TimeStamp(t)} return &issue_model.Comment{PosterID: 1, CreatedUnix: timeutil.TimeStamp(t)}
} }
func nameToID(name string) int64 { func nameToID(name string) int64 {
@ -30,15 +29,13 @@ func nameToID(name string) int64 {
return id return id
} }
func createReqReviewTarget(name string) issues_model.RequestReviewTarget { func createReqReviewTarget(name string) issue_model.RequestReviewTarget {
if bytes.HasSuffix([]byte(name), []byte("-team")) { if bytes.HasSuffix([]byte(name), []byte("-team")) {
team := createTeam(name) team := createTeam(name)
return issues_model.RequestReviewTarget{Team: &team} return issue_model.RequestReviewTarget{Team: &team}
} else {
user := createUser(name)
return issues_model.RequestReviewTarget{User: &user}
} }
user := createUser(name)
return issue_model.RequestReviewTarget{User: &user}
} }
func createUser(name string) user_model.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)} return organization.Team{Name: name, ID: nameToID(name)}
} }
func createLabel(name string) issues_model.Label { func createLabel(name string) issue_model.Label {
return issues_model.Label{Name: name, ID: nameToID(name)} 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 := testComment(t)
c.Type = issue_model.CommentTypeLabel c.Type = issue_model.CommentTypeLabel
c.Content = "1" c.Content = "1"
lbl := createLabel(name) lbl := createLabel(name)
c.Label = &lbl c.Label = &lbl
c.AddedLabels = []*issues_model.Label{&lbl} c.AddedLabels = []*issue_model.Label{&lbl}
return c 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 := addLabel(t, name)
c.Content = "" c.Content = ""
return c return c
} }
func openOrClose(t int64, close bool) *issues_model.Comment { func openOrClose(t int64, close bool) *issue_model.Comment {
c := testComment(t) c := testComment(t)
if close { if close {
c.Type = issue_model.CommentTypeClose c.Type = issue_model.CommentTypeClose
@ -79,7 +76,7 @@ func openOrClose(t int64, close bool) *issues_model.Comment {
return c 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 := testComment(t)
c.Type = issue_model.CommentTypeReviewRequest c.Type = issue_model.CommentTypeReviewRequest
if bytes.HasSuffix([]byte(name), []byte("-team")) { if bytes.HasSuffix([]byte(name), []byte("-team")) {
@ -95,8 +92,8 @@ func reqReview(t int64, name string, delReq bool) *issues_model.Comment {
return c return c
} }
func reqReviewList(t int64, del bool, names ...string) *issues_model.Comment { func reqReviewList(t int64, del bool, names ...string) *issue_model.Comment {
req := []issues_model.RequestReviewTarget{} req := []issue_model.RequestReviewTarget{}
for _, name := range names { for _, name := range names {
req = append(req, createReqReviewTarget(name)) req = append(req, createReqReviewTarget(name))
} }
@ -112,14 +109,14 @@ func reqReviewList(t int64, del bool, names ...string) *issues_model.Comment {
func aggregatedComment(t int64, func aggregatedComment(t int64,
closed bool, closed bool,
addLabels []*issues_model.Label, addLabels []*issue_model.Label,
delLabels []*issues_model.Label, delLabels []*issue_model.Label,
addReqReview []issues_model.RequestReviewTarget, addReqReview []issue_model.RequestReviewTarget,
delReqReview []issues_model.RequestReviewTarget, delReqReview []issue_model.RequestReviewTarget,
) *issues_model.Comment { ) *issue_model.Comment {
cmnt := testComment(t) cmnt := testComment(t)
cmnt.Type = issues_model.CommentTypeAggregator cmnt.Type = issue_model.CommentTypeAggregator
cmnt.Aggregator = &issues_model.CommentAggregator{ cmnt.Aggregator = &issue_model.CommentAggregator{
IsClosed: closed, IsClosed: closed,
AddedLabels: addLabels, AddedLabels: addLabels,
RemovedLabels: delLabels, RemovedLabels: delLabels,
@ -141,7 +138,7 @@ func aggregatedComment(t int64,
return cmnt return cmnt
} }
func commentText(t int64, text string) *issues_model.Comment { func commentText(t int64, text string) *issue_model.Comment {
c := testComment(t) c := testComment(t)
c.Type = issue_model.CommentTypeComment c.Type = issue_model.CommentTypeComment
c.Content = text c.Content = text
@ -152,14 +149,14 @@ func commentText(t int64, text string) *issues_model.Comment {
type testCase struct { type testCase struct {
name string name string
beforeCombined []*issues_model.Comment beforeCombined []*issue_model.Comment
afterCombined []*issues_model.Comment afterCombined []*issue_model.Comment
sameAfter bool sameAfter bool
} }
func (kase *testCase) doTest(t *testing.T) { func (kase *testCase) doTest(t *testing.T) {
issue := issues_model.Issue{Comments: kase.beforeCombined} issue := issue_model.Issue{Comments: kase.beforeCombined}
issues_model.CombineCommentsHistory(&issue) issue_model.CombineCommentsHistory(&issue)
after := &kase.afterCombined after := &kase.afterCombined
if kase.sameAfter { if kase.sameAfter {
@ -214,7 +211,7 @@ func TestCombineLabelComments(t *testing.T) {
// ADD single = normal label comment // ADD single = normal label comment
{ {
name: "add_single_label", name: "add_single_label",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(0, "a"), addLabel(0, "a"),
commentText(10, "I'm a salmon"), commentText(10, "I'm a salmon"),
}, },
@ -224,12 +221,12 @@ func TestCombineLabelComments(t *testing.T) {
// ADD then REMOVE = Nothing // ADD then REMOVE = Nothing
{ {
name: "add_label_then_remove", name: "add_label_then_remove",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(0, "a"), addLabel(0, "a"),
delLabel(1, "a"), delLabel(1, "a"),
commentText(65, "I'm a salmon"), commentText(65, "I'm a salmon"),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
commentText(65, "I'm a salmon"), commentText(65, "I'm a salmon"),
}, },
}, },
@ -237,7 +234,7 @@ func TestCombineLabelComments(t *testing.T) {
// ADD 1 then comment then REMOVE = separate comments // ADD 1 then comment then REMOVE = separate comments
{ {
name: "add_label_then_comment_then_remove", name: "add_label_then_comment_then_remove",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(0, "a"), addLabel(0, "a"),
commentText(10, "I'm a salmon"), commentText(10, "I'm a salmon"),
delLabel(20, "a"), delLabel(20, "a"),
@ -248,7 +245,7 @@ func TestCombineLabelComments(t *testing.T) {
// ADD 2 = Combined labels // ADD 2 = Combined labels
{ {
name: "combine_labels", name: "combine_labels",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(0, "a"), addLabel(0, "a"),
addLabel(10, "b"), addLabel(10, "b"),
commentText(20, "I'm a salmon"), commentText(20, "I'm a salmon"),
@ -257,12 +254,12 @@ func TestCombineLabelComments(t *testing.T) {
addLabel(85, "e"), addLabel(85, "e"),
delLabel(90, "c"), delLabel(90, "c"),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
{ {
PosterID: 1, PosterID: 1,
Type: issue_model.CommentTypeLabel, Type: issue_model.CommentTypeLabel,
CreatedUnix: timeutil.TimeStamp(0), CreatedUnix: timeutil.TimeStamp(0),
AddedLabels: []*issues_model.Label{ AddedLabels: []*issue_model.Label{
{Name: "a", ID: nameToID("a")}, {Name: "a", ID: nameToID("a")},
{Name: "b", ID: nameToID("b")}, {Name: "b", ID: nameToID("b")},
}, },
@ -272,7 +269,7 @@ func TestCombineLabelComments(t *testing.T) {
PosterID: 1, PosterID: 1,
Type: issue_model.CommentTypeLabel, Type: issue_model.CommentTypeLabel,
CreatedUnix: timeutil.TimeStamp(30), CreatedUnix: timeutil.TimeStamp(30),
AddedLabels: []*issues_model.Label{ AddedLabels: []*issue_model.Label{
{Name: "d", ID: nameToID("d")}, {Name: "d", ID: nameToID("d")},
{Name: "e", ID: nameToID("e")}, {Name: "e", ID: nameToID("e")},
}, },
@ -283,17 +280,17 @@ func TestCombineLabelComments(t *testing.T) {
// ADD 1, then 1 later = 2 separate comments // ADD 1, then 1 later = 2 separate comments
{ {
name: "add_then_later_label", name: "add_then_later_label",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(0, "a"), addLabel(0, "a"),
addLabel(60, "b"), addLabel(60, "b"),
addLabel(121, "c"), addLabel(121, "c"),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
{ {
PosterID: 1, PosterID: 1,
Type: issue_model.CommentTypeLabel, Type: issue_model.CommentTypeLabel,
CreatedUnix: timeutil.TimeStamp(0), CreatedUnix: timeutil.TimeStamp(0),
AddedLabels: []*issues_model.Label{ AddedLabels: []*issue_model.Label{
{Name: "a", ID: nameToID("a")}, {Name: "a", ID: nameToID("a")},
{Name: "b", ID: nameToID("b")}, {Name: "b", ID: nameToID("b")},
}, },
@ -305,12 +302,12 @@ func TestCombineLabelComments(t *testing.T) {
// ADD 2 then REMOVE 1 = label // ADD 2 then REMOVE 1 = label
{ {
name: "add_2_remove_1", name: "add_2_remove_1",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(0, "a"), addLabel(0, "a"),
addLabel(10, "b"), addLabel(10, "b"),
delLabel(20, "a"), delLabel(20, "a"),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
// The timestamp will be the one of the first aggregated comment // The timestamp will be the one of the first aggregated comment
addLabel(0, "b"), addLabel(0, "b"),
}, },
@ -319,7 +316,7 @@ func TestCombineLabelComments(t *testing.T) {
// ADD then REMOVE multiple = nothing // ADD then REMOVE multiple = nothing
{ {
name: "add_multiple_remove_all", name: "add_multiple_remove_all",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(0, "a"), addLabel(0, "a"),
addLabel(1, "b"), addLabel(1, "b"),
addLabel(2, "c"), addLabel(2, "c"),
@ -337,18 +334,18 @@ func TestCombineLabelComments(t *testing.T) {
// ADD 2, wait, REMOVE 2 = +2 then -2 comments // ADD 2, wait, REMOVE 2 = +2 then -2 comments
{ {
name: "add2_wait_rm2_labels", name: "add2_wait_rm2_labels",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(0, "a"), addLabel(0, "a"),
addLabel(1, "b"), addLabel(1, "b"),
delLabel(120, "a"), delLabel(120, "a"),
delLabel(121, "b"), delLabel(121, "b"),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
{ {
PosterID: 1, PosterID: 1,
Type: issue_model.CommentTypeLabel, Type: issue_model.CommentTypeLabel,
CreatedUnix: timeutil.TimeStamp(0), CreatedUnix: timeutil.TimeStamp(0),
AddedLabels: []*issues_model.Label{ AddedLabels: []*issue_model.Label{
{Name: "a", ID: nameToID("a")}, {Name: "a", ID: nameToID("a")},
{Name: "b", ID: nameToID("b")}, {Name: "b", ID: nameToID("b")},
}, },
@ -357,7 +354,7 @@ func TestCombineLabelComments(t *testing.T) {
PosterID: 1, PosterID: 1,
Type: issue_model.CommentTypeLabel, Type: issue_model.CommentTypeLabel,
CreatedUnix: timeutil.TimeStamp(120), CreatedUnix: timeutil.TimeStamp(120),
RemovedLabels: []*issues_model.Label{ RemovedLabels: []*issue_model.Label{
{Name: "a", ID: nameToID("a")}, {Name: "a", ID: nameToID("a")},
{Name: "b", ID: nameToID("b")}, {Name: "b", ID: nameToID("b")},
}, },
@ -376,7 +373,7 @@ func TestCombineReviewRequests(t *testing.T) {
// ADD single = normal request review comment // ADD single = normal request review comment
{ {
name: "add_single_review", name: "add_single_review",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(0, "toto", false), reqReview(0, "toto", false),
commentText(10, "I'm a salmon"), commentText(10, "I'm a salmon"),
reqReview(0, "toto-team", false), reqReview(0, "toto-team", false),
@ -387,12 +384,12 @@ func TestCombineReviewRequests(t *testing.T) {
// ADD then REMOVE = Nothing // ADD then REMOVE = Nothing
{ {
name: "add_then_remove_review", name: "add_then_remove_review",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(0, "toto", false), reqReview(0, "toto", false),
reqReview(5, "toto", true), reqReview(5, "toto", true),
commentText(10, "I'm a salmon"), commentText(10, "I'm a salmon"),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
commentText(10, "I'm a salmon"), commentText(10, "I'm a salmon"),
}, },
}, },
@ -400,7 +397,7 @@ func TestCombineReviewRequests(t *testing.T) {
// ADD 1 then comment then REMOVE = separate comments // ADD 1 then comment then REMOVE = separate comments
{ {
name: "add_comment_del_review", name: "add_comment_del_review",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(0, "toto", false), reqReview(0, "toto", false),
commentText(5, "I'm a salmon"), commentText(5, "I'm a salmon"),
reqReview(10, "toto", true), reqReview(10, "toto", true),
@ -411,7 +408,7 @@ func TestCombineReviewRequests(t *testing.T) {
// ADD 2 = Combined request reviews // ADD 2 = Combined request reviews
{ {
name: "combine_reviews", name: "combine_reviews",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(0, "toto", false), reqReview(0, "toto", false),
reqReview(10, "tutu-team", false), reqReview(10, "tutu-team", false),
commentText(20, "I'm a salmon"), commentText(20, "I'm a salmon"),
@ -420,7 +417,7 @@ func TestCombineReviewRequests(t *testing.T) {
reqReview(85, "tyty-team", false), reqReview(85, "tyty-team", false),
reqReview(90, "titi", true), reqReview(90, "titi", true),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
reqReviewList(0, false, "toto", "tutu-team"), reqReviewList(0, false, "toto", "tutu-team"),
commentText(20, "I'm a salmon"), commentText(20, "I'm a salmon"),
reqReviewList(30, false, "tata", "tyty-team"), reqReviewList(30, false, "tata", "tyty-team"),
@ -430,12 +427,12 @@ func TestCombineReviewRequests(t *testing.T) {
// ADD 1, then 1 later = 2 separate comments // ADD 1, then 1 later = 2 separate comments
{ {
name: "add_then_later_review", name: "add_then_later_review",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(0, "titi", false), reqReview(0, "titi", false),
reqReview(60, "toto-team", false), reqReview(60, "toto-team", false),
reqReview(121, "tutu", false), reqReview(121, "tutu", false),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
reqReviewList(0, false, "titi", "toto-team"), reqReviewList(0, false, "titi", "toto-team"),
reqReviewList(121, false, "tutu"), reqReviewList(121, false, "tutu"),
}, },
@ -444,12 +441,12 @@ func TestCombineReviewRequests(t *testing.T) {
// ADD 2 then REMOVE 1 = single request review // ADD 2 then REMOVE 1 = single request review
{ {
name: "add_2_then_remove_review", name: "add_2_then_remove_review",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(0, "titi-team", false), reqReview(0, "titi-team", false),
reqReview(59, "toto", false), reqReview(59, "toto", false),
reqReview(60, "titi-team", true), reqReview(60, "titi-team", true),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
reqReviewList(0, false, "toto"), reqReviewList(0, false, "toto"),
}, },
}, },
@ -457,7 +454,7 @@ func TestCombineReviewRequests(t *testing.T) {
// ADD then REMOVE multiple = nothing // ADD then REMOVE multiple = nothing
{ {
name: "add_multiple_then_remove_all_review", name: "add_multiple_then_remove_all_review",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(0, "titi0-team", false), reqReview(0, "titi0-team", false),
reqReview(1, "toto1", false), reqReview(1, "toto1", false),
reqReview(2, "titi2", false), reqReview(2, "titi2", false),
@ -479,13 +476,13 @@ func TestCombineReviewRequests(t *testing.T) {
// ADD 2, wait, REMOVE 2 = +2 then -2 comments // ADD 2, wait, REMOVE 2 = +2 then -2 comments
{ {
name: "add2_wait_rm2_requests", name: "add2_wait_rm2_requests",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(1, "titi", false), reqReview(1, "titi", false),
reqReview(2, "toto-team", false), reqReview(2, "toto-team", false),
reqReview(121, "titi", true), reqReview(121, "titi", true),
reqReview(122, "toto-team", true), reqReview(122, "toto-team", true),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
reqReviewList(1, false, "titi", "toto-team"), reqReviewList(1, false, "titi", "toto-team"),
reqReviewList(121, true, "titi", "toto-team"), reqReviewList(121, true, "titi", "toto-team"),
}, },
@ -502,7 +499,7 @@ func TestCombineOpenClose(t *testing.T) {
// Close then open = nullified // Close then open = nullified
{ {
name: "close_open_nullified", name: "close_open_nullified",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
openOrClose(0, true), openOrClose(0, true),
openOrClose(10, false), openOrClose(10, false),
}, },
@ -512,7 +509,7 @@ func TestCombineOpenClose(t *testing.T) {
// Close then open later = separate comments // Close then open later = separate comments
{ {
name: "close_open_later", name: "close_open_later",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
openOrClose(0, true), openOrClose(0, true),
openOrClose(61, false), openOrClose(61, false),
}, },
@ -522,7 +519,7 @@ func TestCombineOpenClose(t *testing.T) {
// Close then comment then open = separate comments // Close then comment then open = separate comments
{ {
name: "close_comment_open", name: "close_comment_open",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
openOrClose(0, true), openOrClose(0, true),
commentText(1, "I'm a salmon"), commentText(1, "I'm a salmon"),
openOrClose(2, false), openOrClose(2, false),
@ -537,12 +534,12 @@ func TestCombineOpenClose(t *testing.T) {
} }
func TestCombineMultipleDifferentComments(t *testing.T) { func TestCombineMultipleDifferentComments(t *testing.T) {
lbl_a := createLabel("a") lblA := createLabel("a")
kases := []testCase{ kases := []testCase{
// Add Label + Close + ReqReview = Combined // Add Label + Close + ReqReview = Combined
{ {
name: "label_close_reqreview_combined", name: "label_close_reqreview_combined",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
reqReview(1, "toto", false), reqReview(1, "toto", false),
addLabel(2, "a"), addLabel(2, "a"),
openOrClose(3, true), openOrClose(3, true),
@ -551,20 +548,20 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
openOrClose(102, false), openOrClose(102, false),
delLabel(103, "a"), delLabel(103, "a"),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
aggregatedComment(1, aggregatedComment(1,
true, true,
[]*issues_model.Label{&lbl_a}, []*issue_model.Label{&lblA},
[]*issues_model.Label{}, []*issue_model.Label{},
[]issues_model.RequestReviewTarget{createReqReviewTarget("toto")}, []issue_model.RequestReviewTarget{createReqReviewTarget("toto")},
[]issues_model.RequestReviewTarget{}, []issue_model.RequestReviewTarget{},
), ),
aggregatedComment(101, aggregatedComment(101,
false, false,
[]*issues_model.Label{}, []*issue_model.Label{},
[]*issues_model.Label{&lbl_a}, []*issue_model.Label{&lblA},
[]issues_model.RequestReviewTarget{}, []issue_model.RequestReviewTarget{},
[]issues_model.RequestReviewTarget{createReqReviewTarget("toto")}, []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 // Add Req + Add Label + Close + Del Req + Del Label = Close only
{ {
name: "req_label_close_dellabel_delreq", name: "req_label_close_dellabel_delreq",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(2, "a"), addLabel(2, "a"),
reqReview(3, "titi", false), reqReview(3, "titi", false),
openOrClose(4, true), openOrClose(4, true),
delLabel(5, "a"), delLabel(5, "a"),
reqReview(6, "titi", true), reqReview(6, "titi", true),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
openOrClose(2, true), openOrClose(2, true),
}, },
}, },
@ -587,14 +584,14 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
// Close + Add Req + Add Label + Del Req + Open = Label only // Close + Add Req + Add Label + Del Req + Open = Label only
{ {
name: "close_req_label_open_delreq", name: "close_req_label_open_delreq",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
openOrClose(2, true), openOrClose(2, true),
reqReview(4, "titi", false), reqReview(4, "titi", false),
addLabel(5, "a"), addLabel(5, "a"),
reqReview(6, "titi", true), reqReview(6, "titi", true),
openOrClose(8, false), openOrClose(8, false),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
addLabel(2, "a"), addLabel(2, "a"),
}, },
}, },
@ -602,14 +599,14 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
// Add Label + Close + Add ReqReview + Del Label + Open = ReqReview only // Add Label + Close + Add ReqReview + Del Label + Open = ReqReview only
{ {
name: "label_close_req_dellabel_open", name: "label_close_req_dellabel_open",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(1, "a"), addLabel(1, "a"),
openOrClose(2, true), openOrClose(2, true),
reqReview(4, "titi", false), reqReview(4, "titi", false),
openOrClose(7, false), openOrClose(7, false),
delLabel(8, "a"), delLabel(8, "a"),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
reqReview(1, "titi", false), reqReview(1, "titi", false),
}, },
}, },
@ -617,7 +614,7 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
// Add Label + Close + ReqReview, then delete everything = nothing // Add Label + Close + ReqReview, then delete everything = nothing
{ {
name: "add_multiple_delete_everything", name: "add_multiple_delete_everything",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(1, "a"), addLabel(1, "a"),
openOrClose(2, true), openOrClose(2, true),
reqReview(4, "titi", false), reqReview(4, "titi", false),
@ -631,7 +628,7 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
// Add multiple, then comment, then delete everything = separate aggregation // Add multiple, then comment, then delete everything = separate aggregation
{ {
name: "add_multiple_comment_delete_everything", name: "add_multiple_comment_delete_everything",
beforeCombined: []*issues_model.Comment{ beforeCombined: []*issue_model.Comment{
addLabel(1, "a"), addLabel(1, "a"),
openOrClose(2, true), openOrClose(2, true),
reqReview(4, "titi", false), reqReview(4, "titi", false),
@ -642,21 +639,21 @@ func TestCombineMultipleDifferentComments(t *testing.T) {
delLabel(8, "a"), delLabel(8, "a"),
reqReview(10, "titi", true), reqReview(10, "titi", true),
}, },
afterCombined: []*issues_model.Comment{ afterCombined: []*issue_model.Comment{
aggregatedComment(1, aggregatedComment(1,
true, true,
[]*issues_model.Label{&lbl_a}, []*issue_model.Label{&lblA},
[]*issues_model.Label{}, []*issue_model.Label{},
[]issues_model.RequestReviewTarget{createReqReviewTarget("titi")}, []issue_model.RequestReviewTarget{createReqReviewTarget("titi")},
[]issues_model.RequestReviewTarget{}, []issue_model.RequestReviewTarget{},
), ),
commentText(6, "I'm a salmon"), commentText(6, "I'm a salmon"),
aggregatedComment(7, aggregatedComment(7,
false, false,
[]*issues_model.Label{}, []*issue_model.Label{},
[]*issues_model.Label{&lbl_a}, []*issue_model.Label{&lblA},
[]issues_model.RequestReviewTarget{}, []issue_model.RequestReviewTarget{},
[]issues_model.RequestReviewTarget{createReqReviewTarget("titi")}, []issue_model.RequestReviewTarget{createReqReviewTarget("titi")},
), ),
}, },
}, },