aboutsummaryrefslogtreecommitdiffstats
path: root/services/migrations/gitlab_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/migrations/gitlab_test.go')
-rw-r--r--services/migrations/gitlab_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/services/migrations/gitlab_test.go b/services/migrations/gitlab_test.go
index 1d8c5989bb..731486eff2 100644
--- a/services/migrations/gitlab_test.go
+++ b/services/migrations/gitlab_test.go
@@ -13,6 +13,7 @@ import (
"testing"
"time"
+ "code.gitea.io/gitea/modules/json"
base "code.gitea.io/gitea/modules/migration"
"github.com/stretchr/testify/assert"
@@ -469,3 +470,49 @@ func TestGitlabGetReviews(t *testing.T) {
assertReviewsEqual(t, []*base.Review{&review}, rvs)
}
}
+
+func TestAwardsToReactions(t *testing.T) {
+ downloader := &GitlabDownloader{}
+ // yes gitlab can have duplicated reactions (https://gitlab.com/jaywink/socialhome/-/issues/24)
+ testResponse := `
+[
+ {
+ "name": "thumbsup",
+ "user": {
+ "id": 1241334,
+ "username": "lafriks"
+ }
+ },
+ {
+ "name": "thumbsup",
+ "user": {
+ "id": 1241334,
+ "username": "lafriks"
+ }
+ },
+ {
+ "name": "thumbsup",
+ "user": {
+ "id": 4575606,
+ "username": "real6543"
+ }
+ }
+]
+`
+ var awards []*gitlab.AwardEmoji
+ assert.NoError(t, json.Unmarshal([]byte(testResponse), &awards))
+
+ reactions := downloader.awardsToReactions(awards)
+ assert.EqualValues(t, []*base.Reaction{
+ {
+ UserName: "lafriks",
+ UserID: 1241334,
+ Content: "thumbsup",
+ },
+ {
+ UserName: "real6543",
+ UserID: 4575606,
+ Content: "thumbsup",
+ },
+ }, reactions)
+}