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 -6
View File
@@ -34,8 +34,7 @@ func TestAPIUserInfo(t *testing.T) {
AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var u api.User
DecodeJSON(t, resp, &u)
u := DecodeJSON(t, resp, &api.User{})
assert.Equal(t, user2, u.UserName)
req = NewRequest(t, "GET", "/api/v1/users/"+user2)
@@ -44,14 +43,14 @@ func TestAPIUserInfo(t *testing.T) {
// test if the placaholder Mail is returned if a User is not logged in
req = NewRequest(t, "GET", "/api/v1/users/"+org3.Name)
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &u)
u = DecodeJSON(t, resp, &api.User{})
assert.Equal(t, org3.GetPlaceholderEmail(), u.Email)
// Test if the correct Mail is returned if a User is logged in
req = NewRequest(t, "GET", "/api/v1/users/"+org3.Name).
AddTokenAuth(token)
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &u)
u = DecodeJSON(t, resp, &api.User{})
assert.Equal(t, org3.GetEmail(), u.Email)
})
@@ -62,8 +61,7 @@ func TestAPIUserInfo(t *testing.T) {
AddTokenAuth(token)
resp := MakeRequest(t, req, http.StatusOK)
var u api.User
DecodeJSON(t, resp, &u)
u := DecodeJSON(t, resp, &api.User{})
assert.Equal(t, user, u.UserName)
})
}