summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_admin_test.go3
-rw-r--r--integrations/api_helper_for_declarative_test.go4
-rw-r--r--integrations/create_no_session_test.go4
-rw-r--r--integrations/integration_test.go6
-rw-r--r--integrations/oauth_test.go10
-rw-r--r--integrations/repo_commits_test.go3
-rw-r--r--integrations/testlogger.go3
7 files changed, 26 insertions, 7 deletions
diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go
index fdcfc40789..b3a0de36d3 100644
--- a/integrations/api_admin_test.go
+++ b/integrations/api_admin_test.go
@@ -5,7 +5,6 @@
package integrations
import (
- "encoding/json"
"fmt"
"net/http"
"testing"
@@ -13,6 +12,7 @@ import (
"code.gitea.io/gitea/models"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
@@ -190,6 +190,7 @@ func TestAPIEditUser(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusUnprocessableEntity)
errMap := make(map[string]interface{})
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
json.Unmarshal(resp.Body.Bytes(), &errMap)
assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string))
diff --git a/integrations/api_helper_for_declarative_test.go b/integrations/api_helper_for_declarative_test.go
index 551a9bb751..f1d57e717c 100644
--- a/integrations/api_helper_for_declarative_test.go
+++ b/integrations/api_helper_for_declarative_test.go
@@ -6,7 +6,6 @@ package integrations
import (
"context"
- "encoding/json"
"fmt"
"io/ioutil"
"net/http"
@@ -18,6 +17,7 @@ import (
"code.gitea.io/gitea/modules/queue"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
@@ -212,6 +212,8 @@ func doAPICreatePullRequest(ctx APITestContext, owner, repo, baseBranch, headBra
expected = ctx.ExpectedCode
}
resp := ctx.Session.MakeRequest(t, req, expected)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
decoder := json.NewDecoder(resp.Body)
pr := api.PullRequest{}
err := decoder.Decode(&pr)
diff --git a/integrations/create_no_session_test.go b/integrations/create_no_session_test.go
index 89682e95cf..c864b9c7ae 100644
--- a/integrations/create_no_session_test.go
+++ b/integrations/create_no_session_test.go
@@ -5,7 +5,6 @@
package integrations
import (
- "encoding/json"
"io/ioutil"
"net/http"
"net/http/httptest"
@@ -18,6 +17,7 @@ import (
"code.gitea.io/gitea/routers/routes"
"gitea.com/go-chi/session"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
@@ -62,6 +62,8 @@ func TestSessionFileCreation(t *testing.T) {
}()
var config session.Options
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal([]byte(oldSessionConfig), &config)
assert.NoError(t, err)
diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index ee005c087d..10331a1560 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -8,7 +8,6 @@ import (
"bytes"
"context"
"database/sql"
- "encoding/json"
"fmt"
"io"
"net/http"
@@ -36,6 +35,7 @@ import (
"code.gitea.io/gitea/routers/routes"
"github.com/PuerkitoBio/goquery"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
@@ -376,6 +376,8 @@ func NewRequestWithValues(t testing.TB, method, urlStr string, values map[string
func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *http.Request {
t.Helper()
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
jsonBytes, err := json.Marshal(v)
assert.NoError(t, err)
req := NewRequestWithBody(t, method, urlStr, bytes.NewBuffer(jsonBytes))
@@ -453,6 +455,8 @@ func logUnexpectedResponse(t testing.TB, recorder *httptest.ResponseRecorder) {
func DecodeJSON(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) {
t.Helper()
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
decoder := json.NewDecoder(resp.Body)
assert.NoError(t, decoder.Decode(v))
}
diff --git a/integrations/oauth_test.go b/integrations/oauth_test.go
index e74ff28cad..2da182d0c8 100644
--- a/integrations/oauth_test.go
+++ b/integrations/oauth_test.go
@@ -6,12 +6,12 @@ package integrations
import (
"bytes"
- "encoding/json"
"io/ioutil"
"testing"
"code.gitea.io/gitea/modules/setting"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
@@ -70,6 +70,8 @@ func TestAccessTokenExchange(t *testing.T) {
RefreshToken string `json:"refresh_token"`
}
parsed := new(response)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
assert.True(t, len(parsed.AccessToken) > 10)
assert.True(t, len(parsed.RefreshToken) > 10)
@@ -93,6 +95,8 @@ func TestAccessTokenExchangeWithoutPKCE(t *testing.T) {
RefreshToken string `json:"refresh_token"`
}
parsed := new(response)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
assert.True(t, len(parsed.AccessToken) > 10)
assert.True(t, len(parsed.RefreshToken) > 10)
@@ -181,6 +185,8 @@ func TestAccessTokenExchangeWithBasicAuth(t *testing.T) {
RefreshToken string `json:"refresh_token"`
}
parsed := new(response)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
assert.True(t, len(parsed.AccessToken) > 10)
assert.True(t, len(parsed.RefreshToken) > 10)
@@ -223,6 +229,8 @@ func TestRefreshTokenInvalidation(t *testing.T) {
RefreshToken string `json:"refresh_token"`
}
parsed := new(response)
+
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
assert.NoError(t, json.Unmarshal(resp.Body.Bytes(), parsed))
// test without invalidation
diff --git a/integrations/repo_commits_test.go b/integrations/repo_commits_test.go
index f26960271a..042849db7c 100644
--- a/integrations/repo_commits_test.go
+++ b/integrations/repo_commits_test.go
@@ -5,7 +5,6 @@
package integrations
import (
- "encoding/json"
"net/http"
"net/http/httptest"
"path"
@@ -14,6 +13,7 @@ import (
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
+ jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
)
@@ -82,6 +82,7 @@ func doTestRepoCommitWithStatus(t *testing.T, state string, classes ...string) {
}
func testRepoCommitsWithStatus(t *testing.T, resp *httptest.ResponseRecorder, state string) {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
decoder := json.NewDecoder(resp.Body)
statuses := []*api.CommitStatus{}
assert.NoError(t, decoder.Decode(&statuses))
diff --git a/integrations/testlogger.go b/integrations/testlogger.go
index f84ed47e4f..9ea357ba27 100644
--- a/integrations/testlogger.go
+++ b/integrations/testlogger.go
@@ -6,7 +6,6 @@ package integrations
import (
"context"
- "encoding/json"
"fmt"
"os"
"runtime"
@@ -17,6 +16,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/queue"
+ jsoniter "github.com/json-iterator/go"
)
var (
@@ -158,6 +158,7 @@ func NewTestLogger() log.LoggerProvider {
// Init inits connection writer with json config.
// json config only need key "level".
func (log *TestLogger) Init(config string) error {
+ json := jsoniter.ConfigCompatibleWithStandardLibrary
err := json.Unmarshal([]byte(config), log)
if err != nil {
return err