diff options
author | 6543 <6543@obermui.de> | 2023-06-02 22:35:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 20:35:50 +0000 |
commit | af3deb0b30a5fe8c0c964015ef2681ab7ea9365a (patch) | |
tree | 35c9dc09c7d1986933c2bf8ef912a23601022a72 /services/migrations/gitlab_test.go | |
parent | b6d8d695dae2ae99368442be8d9b0ca2a6a281e1 (diff) | |
download | gitea-af3deb0b30a5fe8c0c964015ef2681ab7ea9365a.tar.gz gitea-af3deb0b30a5fe8c0c964015ef2681ab7ea9365a.zip |
GitLab migration: Sanitize response for reaction list (#25054)
Diffstat (limited to 'services/migrations/gitlab_test.go')
-rw-r--r-- | services/migrations/gitlab_test.go | 47 |
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) +} |