1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-15 23:17:19 +00:00

[Refactor] Move APIFormat functions into convert package (#12856)

* USER APIFormat -> ToUser

* Migrate more and mark APIFormat deprecated

* models.Comment APIFormat() -> convert.ToComment

* models.Release APIFormat() -> convert.ToRelease

* models.Attachments APIFormat() -> convert.ToReleaseAttachments

* models.CommitStatus APIFormat() -> convert.ToCommitStatus

* finish migration to convert.ToUser

* Move Test

* Imprufe Test

* fix test

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
6543
2020-10-17 06:23:08 +02:00
committed by GitHub
parent 131278ff22
commit d453533beb
28 changed files with 234 additions and 208 deletions

View File

@@ -11,6 +11,7 @@ import (
"time"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/convert"
api "code.gitea.io/gitea/modules/structs"
"github.com/stretchr/testify/assert"
@@ -60,7 +61,7 @@ func TestAPIIssuesReactions(t *testing.T) {
DecodeJSON(t, resp, &apiReactions)
expectResponse := make(map[int]api.Reaction)
expectResponse[0] = api.Reaction{
User: user2.APIFormat(),
User: convert.ToUser(user2, true, true),
Reaction: "eyes",
Created: time.Unix(1573248003, 0),
}
@@ -120,12 +121,12 @@ func TestAPICommentReactions(t *testing.T) {
DecodeJSON(t, resp, &apiReactions)
expectResponse := make(map[int]api.Reaction)
expectResponse[0] = api.Reaction{
User: user2.APIFormat(),
User: convert.ToUser(user2, true, true),
Reaction: "laugh",
Created: time.Unix(1573248004, 0),
}
expectResponse[1] = api.Reaction{
User: user1.APIFormat(),
User: convert.ToUser(user1, true, true),
Reaction: "laugh",
Created: time.Unix(1573248005, 0),
}