Refactor integration test DecodeJSON calls to use generic return value (#37432)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Copilot
2026-04-26 14:57:07 +00:00
committed by GitHub
parent 99cd4f6b22
commit 2671b997f2
105 changed files with 569 additions and 930 deletions
+4 -8
View File
@@ -17,19 +17,17 @@ import (
func TestAPIExposedSettings(t *testing.T) {
defer tests.PrepareTestEnv(t)()
ui := new(api.GeneralUISettings)
req := NewRequest(t, "GET", "/api/v1/settings/ui")
resp := MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &ui)
ui := DecodeJSON(t, resp, &api.GeneralUISettings{})
assert.Len(t, ui.AllowedReactions, len(setting.UI.Reactions))
assert.ElementsMatch(t, setting.UI.Reactions, ui.AllowedReactions)
apiSettings := new(api.GeneralAPISettings)
req = NewRequest(t, "GET", "/api/v1/settings/api")
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiSettings)
apiSettings := DecodeJSON(t, resp, &api.GeneralAPISettings{})
assert.Equal(t, &api.GeneralAPISettings{
MaxResponseItems: setting.API.MaxResponseItems,
DefaultPagingNum: setting.API.DefaultPagingNum,
@@ -38,11 +36,10 @@ func TestAPIExposedSettings(t *testing.T) {
DefaultMaxResponseSize: setting.API.DefaultMaxResponseSize,
}, apiSettings)
repo := new(api.GeneralRepoSettings)
req = NewRequest(t, "GET", "/api/v1/settings/repository")
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &repo)
repo := DecodeJSON(t, resp, &api.GeneralRepoSettings{})
assert.Equal(t, &api.GeneralRepoSettings{
MirrorsDisabled: !setting.Mirror.Enabled,
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
@@ -51,11 +48,10 @@ func TestAPIExposedSettings(t *testing.T) {
LFSDisabled: !setting.LFS.StartServer,
}, repo)
attachment := new(api.GeneralAttachmentSettings)
req = NewRequest(t, "GET", "/api/v1/settings/attachment")
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &attachment)
attachment := DecodeJSON(t, resp, &api.GeneralAttachmentSettings{})
assert.Equal(t, &api.GeneralAttachmentSettings{
Enabled: setting.Attachment.Enabled,
AllowedTypes: setting.Attachment.AllowedTypes,