Commit c5643c3c authored by Brendan Burns's avatar Brendan Burns

Fix submit queue when there are multiple LGTMs

parent 714b39f0
......@@ -111,9 +111,11 @@ func validateLGTMAfterPush(client *github.Client, user, project string, pr *gith
for ix := range events {
event := &events[ix]
if *event.Event == "labeled" && *event.Label.Name == "lgtm" {
if lgtmTime == nil || event.CreatedAt.After(*lgtmTime) {
lgtmTime = event.CreatedAt
}
}
}
if lgtmTime == nil {
return false, fmt.Errorf("Couldn't find time for LGTM label, this shouldn't happen, skipping PR: %d", *pr.Number)
}
......
......@@ -424,6 +424,60 @@ func TestValidateLGTMAfterPush(t *testing.T) {
lastModified: time.Unix(11, 0),
shouldPass: false,
},
{
issueEvents: []github.IssueEvent{
{
Event: stringPtr("labeled"),
Label: &github.Label{
Name: stringPtr("lgtm"),
},
CreatedAt: timePtr(time.Unix(12, 0)),
},
{
Event: stringPtr("labeled"),
Label: &github.Label{
Name: stringPtr("lgtm"),
},
CreatedAt: timePtr(time.Unix(11, 0)),
},
{
Event: stringPtr("labeled"),
Label: &github.Label{
Name: stringPtr("lgtm"),
},
CreatedAt: timePtr(time.Unix(10, 0)),
},
},
lastModified: time.Unix(11, 0),
shouldPass: true,
},
{
issueEvents: []github.IssueEvent{
{
Event: stringPtr("labeled"),
Label: &github.Label{
Name: stringPtr("lgtm"),
},
CreatedAt: timePtr(time.Unix(10, 0)),
},
{
Event: stringPtr("labeled"),
Label: &github.Label{
Name: stringPtr("lgtm"),
},
CreatedAt: timePtr(time.Unix(11, 0)),
},
{
Event: stringPtr("labeled"),
Label: &github.Label{
Name: stringPtr("lgtm"),
},
CreatedAt: timePtr(time.Unix(12, 0)),
},
},
lastModified: time.Unix(11, 0),
shouldPass: true,
},
}
for _, test := range tests {
client, server, mux := initTest()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment