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:
@@ -345,8 +345,7 @@ nwIDAQAB
|
||||
Dependencies map[string]string `json:"dependencies"`
|
||||
}
|
||||
|
||||
var result map[string]map[string]*VersionInfo
|
||||
DecodeJSON(t, resp, &result)
|
||||
result := DecodeJSON(t, resp, map[string]map[string]*VersionInfo{})
|
||||
|
||||
assert.Len(t, result, 1)
|
||||
assert.Contains(t, result, packageName)
|
||||
@@ -398,8 +397,7 @@ nwIDAQAB
|
||||
AddBasicAuth(user.Name)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var result Result
|
||||
DecodeJSON(t, resp, &result)
|
||||
result := DecodeJSON(t, resp, &Result{})
|
||||
|
||||
assert.Equal(t, c.ExpectedTotal, result.Total, "case %d: unexpected total hits", i)
|
||||
assert.Len(t, result.Items, c.ExpectedResults, "case %d: unexpected result count", i)
|
||||
@@ -449,8 +447,7 @@ nwIDAQAB
|
||||
AddBasicAuth(user.Name)
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var result Result
|
||||
DecodeJSON(t, resp, &result)
|
||||
result := DecodeJSON(t, resp, &Result{})
|
||||
|
||||
assert.Equal(t, c.ExpectedTotal, result.Total, "case %d: unexpected total hits", i)
|
||||
assert.Len(t, result.Items, c.ExpectedResults, "case %d: unexpected result count", i)
|
||||
@@ -484,8 +481,7 @@ nwIDAQAB
|
||||
Versions []string `json:"versions"`
|
||||
}
|
||||
|
||||
var result Result
|
||||
DecodeJSON(t, resp, &result)
|
||||
result := DecodeJSON(t, resp, &Result{})
|
||||
|
||||
versionURL := fmt.Sprintf("%s%s/cookbooks/%s/versions/%s", setting.AppURL, root[1:], packageName, packageVersion)
|
||||
|
||||
@@ -513,8 +509,7 @@ nwIDAQAB
|
||||
Dependencies map[string]string `json:"dependencies"`
|
||||
}
|
||||
|
||||
var result Result
|
||||
DecodeJSON(t, resp, &result)
|
||||
result := DecodeJSON(t, resp, &Result{})
|
||||
|
||||
packageURL := fmt.Sprintf("%s%s/cookbooks/%s", setting.AppURL, root[1:], packageName)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user