bridge/gitlab: fix integration tests

Amine created

Change summary

bridge/gitlab/import_test.go |  2 +-
bridge/gitlab/iterator.go    | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)

Detailed changes

bridge/gitlab/import_test.go 🔗

@@ -19,7 +19,7 @@ import (
 )
 
 func TestImport(t *testing.T) {
-	author := identity.NewIdentity("Amine hilaly", "hilalyamine@gmail.com")
+	author := identity.NewIdentity("Amine Hilaly", "hilalyamine@gmail.com")
 	tests := []struct {
 		name string
 		url  string

bridge/gitlab/iterator.go 🔗

@@ -2,6 +2,7 @@ package gitlab
 
 import (
 	"context"
+	"sort"
 	"time"
 
 	"github.com/xanzy/go-gitlab"
@@ -25,6 +26,20 @@ type labelEventIterator struct {
 	cache []*gitlab.LabelEvent
 }
 
+func (l *labelEventIterator) Len() int {
+	return len(l.cache)
+}
+
+func (l *labelEventIterator) Swap(i, j int) {
+	element := l.cache[i]
+	l.cache[i] = l.cache[j]
+	l.cache[j] = element
+}
+
+func (l *labelEventIterator) Less(i, j int) bool {
+	return l.cache[i].ID < l.cache[j].ID
+}
+
 type iterator struct {
 	// gitlab api v4 client
 	gc *gitlab.Client
@@ -240,6 +255,8 @@ func (i *iterator) getNextLabelEvents() bool {
 	i.labelEvent.cache = labelEvents
 	i.labelEvent.page++
 	i.labelEvent.index = 0
+
+	sort.Sort(i.labelEvent)
 	return true
 }