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
@@ -67,8 +67,7 @@ func TestAPIDeleteFile(t *testing.T) {
req := NewRequestWithJSON(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath), &deleteFileOptions).
AddTokenAuth(token2)
resp := MakeRequest(t, req, http.StatusOK)
var fileResponse api.FileResponse
DecodeJSON(t, resp, &fileResponse)
fileResponse := DecodeJSON(t, resp, &api.FileResponse{})
assert.NotNil(t, fileResponse)
assert.Nil(t, fileResponse.Content)
}
@@ -83,8 +82,7 @@ func TestAPIDeleteFile(t *testing.T) {
req := NewRequestWithJSON(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath), &deleteFileOptions).
AddTokenAuth(token2)
resp := MakeRequest(t, req, http.StatusOK)
var fileResponse api.FileResponse
DecodeJSON(t, resp, &fileResponse)
fileResponse := DecodeJSON(t, resp, &api.FileResponse{})
assert.NotNil(t, fileResponse)
assert.Nil(t, fileResponse.Content)
assert.Equal(t, deleteFileOptions.Message+"\n", fileResponse.Commit.Message)
@@ -98,7 +96,7 @@ func TestAPIDeleteFile(t *testing.T) {
req = NewRequestWithJSON(t, "DELETE", fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s", user2.Name, repo1.Name, treePath), &deleteFileOptions).
AddTokenAuth(token2)
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &fileResponse)
fileResponse = DecodeJSON(t, resp, &api.FileResponse{})
expectedMessage := "Delete " + treePath + "\n"
assert.Equal(t, expectedMessage, fileResponse.Commit.Message)