forked from forgejo/forgejo
Replace interface{}
with any
(#25686)
Result of running `perl -p -i -e 's#interface\{\}#any#g' **/*` and `make fmt`.
Basically the same [as golang did](2580d0e08d
).
This commit is contained in:
parent
00dbba7f42
commit
88f835192d
233 changed files with 727 additions and 727 deletions
|
@ -207,7 +207,7 @@ func TestAPIEditUser(t *testing.T) {
|
|||
})
|
||||
resp := MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
|
||||
errMap := make(map[string]interface{})
|
||||
errMap := make(map[string]any)
|
||||
json.Unmarshal(resp.Body.Bytes(), &errMap)
|
||||
assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string))
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ func uploadConanPackageV2(t *testing.T, baseURL, token, name, version, user, cha
|
|||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
var list *struct {
|
||||
Files map[string]interface{} `json:"files"`
|
||||
Files map[string]any `json:"files"`
|
||||
}
|
||||
DecodeJSON(t, resp, &list)
|
||||
assert.Len(t, list.Files, 1)
|
||||
|
|
|
@ -35,7 +35,7 @@ func addNuGetAPIKeyHeader(request *http.Request, token string) *http.Request {
|
|||
return request
|
||||
}
|
||||
|
||||
func decodeXML(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) {
|
||||
func decodeXML(t testing.TB, resp *httptest.ResponseRecorder, v any) {
|
||||
t.Helper()
|
||||
|
||||
assert.NoError(t, xml.NewDecoder(resp.Body).Decode(v))
|
||||
|
|
|
@ -131,10 +131,10 @@ description: ` + packageDescription
|
|||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
type VersionMetadata struct {
|
||||
Version string `json:"version"`
|
||||
ArchiveURL string `json:"archive_url"`
|
||||
Published time.Time `json:"published"`
|
||||
Pubspec interface{} `json:"pubspec,omitempty"`
|
||||
Version string `json:"version"`
|
||||
ArchiveURL string `json:"archive_url"`
|
||||
Published time.Time `json:"published"`
|
||||
Pubspec any `json:"pubspec,omitempty"`
|
||||
}
|
||||
|
||||
var result VersionMetadata
|
||||
|
@ -156,10 +156,10 @@ description: ` + packageDescription
|
|||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
type VersionMetadata struct {
|
||||
Version string `json:"version"`
|
||||
ArchiveURL string `json:"archive_url"`
|
||||
Published time.Time `json:"published"`
|
||||
Pubspec interface{} `json:"pubspec,omitempty"`
|
||||
Version string `json:"version"`
|
||||
ArchiveURL string `json:"archive_url"`
|
||||
Published time.Time `json:"published"`
|
||||
Pubspec any `json:"pubspec,omitempty"`
|
||||
}
|
||||
|
||||
type PackageVersions struct {
|
||||
|
|
|
@ -219,7 +219,7 @@ gpgkey=%sapi/packages/%s/rpm/repository.key`, user.Name, user.Name, setting.AppN
|
|||
assert.Contains(t, resp.Body.String(), "-----BEGIN PGP SIGNATURE-----")
|
||||
})
|
||||
|
||||
decodeGzipXML := func(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) {
|
||||
decodeGzipXML := func(t testing.TB, resp *httptest.ResponseRecorder, v any) {
|
||||
t.Helper()
|
||||
|
||||
zr, err := gzip.NewReader(resp.Body)
|
||||
|
|
|
@ -195,7 +195,7 @@ func TestAPIPullReview(t *testing.T) {
|
|||
Comments: []api.CreatePullReviewComment{},
|
||||
})
|
||||
resp = MakeRequest(t, req, http.StatusUnprocessableEntity)
|
||||
errMap := make(map[string]interface{})
|
||||
errMap := make(map[string]any)
|
||||
json.Unmarshal(resp.Body.Bytes(), &errMap)
|
||||
assert.EqualValues(t, "review event COMMENT requires a body or a comment", errMap["message"].(string))
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ func runTestCase(t *testing.T, testCase *requiredScopeTestCase, user *user_model
|
|||
// createAPIAccessTokenWithoutCleanUp Create an API access token and assert that
|
||||
// creation succeeded. The caller is responsible for deleting the token.
|
||||
func createAPIAccessTokenWithoutCleanUp(t *testing.T, tokenName string, user *user_model.User, scopes *[]auth_model.AccessTokenScope) api.AccessToken {
|
||||
payload := map[string]interface{}{
|
||||
payload := map[string]any{
|
||||
"name": tokenName,
|
||||
}
|
||||
if scopes != nil {
|
||||
|
|
|
@ -121,8 +121,8 @@ type compareDump struct {
|
|||
}
|
||||
|
||||
type compareField struct {
|
||||
before interface{}
|
||||
after interface{}
|
||||
before any
|
||||
after any
|
||||
ignore bool
|
||||
transform func(string) string
|
||||
nested *compareFields
|
||||
|
@ -215,7 +215,7 @@ func (c *compareDump) assertEquals(repoBefore, repoAfter *repo_model.Repository)
|
|||
}
|
||||
}
|
||||
|
||||
func (c *compareDump) assertLoadYAMLFiles(beforeFilename, afterFilename string, before, after interface{}) {
|
||||
func (c *compareDump) assertLoadYAMLFiles(beforeFilename, afterFilename string, before, after any) {
|
||||
_, beforeErr := os.Stat(beforeFilename)
|
||||
_, afterErr := os.Stat(afterFilename)
|
||||
assert.EqualValues(c.t, errors.Is(beforeErr, os.ErrNotExist), errors.Is(afterErr, os.ErrNotExist))
|
||||
|
@ -255,7 +255,7 @@ func (c *compareDump) assertLoadFiles(beforeFilename, afterFilename string, t re
|
|||
return beforePtr.Elem(), afterPtr.Elem()
|
||||
}
|
||||
|
||||
func (c *compareDump) assertEqual(filename string, kind interface{}, fields compareFields) (i interface{}) {
|
||||
func (c *compareDump) assertEqual(filename string, kind any, fields compareFields) (i any) {
|
||||
beforeFilename := filepath.Join(c.dirBefore, filename)
|
||||
afterFilename := filepath.Join(c.dirAfter, filename)
|
||||
|
||||
|
@ -269,7 +269,7 @@ func (c *compareDump) assertEqual(filename string, kind interface{}, fields comp
|
|||
return i
|
||||
}
|
||||
|
||||
func (c *compareDump) assertEqualSlices(before, after reflect.Value, fields compareFields) interface{} {
|
||||
func (c *compareDump) assertEqualSlices(before, after reflect.Value, fields compareFields) any {
|
||||
assert.EqualValues(c.t, before.Len(), after.Len())
|
||||
if before.Len() == after.Len() {
|
||||
for i := 0; i < before.Len(); i++ {
|
||||
|
@ -282,7 +282,7 @@ func (c *compareDump) assertEqualSlices(before, after reflect.Value, fields comp
|
|||
return after.Interface()
|
||||
}
|
||||
|
||||
func (c *compareDump) assertEqualValues(before, after reflect.Value, fields compareFields) interface{} {
|
||||
func (c *compareDump) assertEqualValues(before, after reflect.Value, fields compareFields) any {
|
||||
for _, field := range reflect.VisibleFields(before.Type()) {
|
||||
bf := before.FieldByName(field.Name)
|
||||
bi := bf.Interface()
|
||||
|
|
|
@ -319,7 +319,7 @@ func NewRequest(t testing.TB, method, urlStr string) *http.Request {
|
|||
return NewRequestWithBody(t, method, urlStr, nil)
|
||||
}
|
||||
|
||||
func NewRequestf(t testing.TB, method, urlFormat string, args ...interface{}) *http.Request {
|
||||
func NewRequestf(t testing.TB, method, urlFormat string, args ...any) *http.Request {
|
||||
t.Helper()
|
||||
return NewRequest(t, method, fmt.Sprintf(urlFormat, args...))
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ func NewRequestWithURLValues(t testing.TB, method, urlStr string, urlValues url.
|
|||
return req
|
||||
}
|
||||
|
||||
func NewRequestWithJSON(t testing.TB, method, urlStr string, v interface{}) *http.Request {
|
||||
func NewRequestWithJSON(t testing.TB, method, urlStr string, v any) *http.Request {
|
||||
t.Helper()
|
||||
|
||||
jsonBytes, err := json.Marshal(v)
|
||||
|
@ -435,7 +435,7 @@ func logUnexpectedResponse(t testing.TB, recorder *httptest.ResponseRecorder) {
|
|||
}
|
||||
}
|
||||
|
||||
func DecodeJSON(t testing.TB, resp *httptest.ResponseRecorder, v interface{}) {
|
||||
func DecodeJSON(t testing.TB, resp *httptest.ResponseRecorder, v any) {
|
||||
t.Helper()
|
||||
|
||||
decoder := json.NewDecoder(resp.Body)
|
||||
|
|
|
@ -30,18 +30,18 @@ func TestWebfinger(t *testing.T) {
|
|||
appURL, _ := url.Parse(setting.AppURL)
|
||||
|
||||
type webfingerLink struct {
|
||||
Rel string `json:"rel,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Titles map[string]string `json:"titles,omitempty"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
Rel string `json:"rel,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Href string `json:"href,omitempty"`
|
||||
Titles map[string]string `json:"titles,omitempty"`
|
||||
Properties map[string]any `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
type webfingerJRD struct {
|
||||
Subject string `json:"subject,omitempty"`
|
||||
Aliases []string `json:"aliases,omitempty"`
|
||||
Properties map[string]interface{} `json:"properties,omitempty"`
|
||||
Links []*webfingerLink `json:"links,omitempty"`
|
||||
Subject string `json:"subject,omitempty"`
|
||||
Aliases []string `json:"aliases,omitempty"`
|
||||
Properties map[string]any `json:"properties,omitempty"`
|
||||
Links []*webfingerLink `json:"links,omitempty"`
|
||||
}
|
||||
|
||||
session := loginUser(t, "user1")
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func exitf(format string, args ...interface{}) {
|
||||
func exitf(format string, args ...any) {
|
||||
fmt.Printf(format+"\n", args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -247,6 +247,6 @@ func PrintCurrentTest(t testing.TB, skip ...int) func() {
|
|||
}
|
||||
|
||||
// Printf takes a format and args and prints the string to os.Stdout
|
||||
func Printf(format string, args ...interface{}) {
|
||||
func Printf(format string, args ...any) {
|
||||
testlogger.Printf(format, args...)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue