diff options
author | silverwind <me@silverwind.io> | 2023-07-04 20:36:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-04 18:36:08 +0000 |
commit | 88f835192d1a554d233b0ec4daa33276b7eb2910 (patch) | |
tree | 438140c295791e64a3b78dcfeae57701bcf296c3 /tests | |
parent | 00dbba7f4266032a2b91b760e7c611950ffad096 (diff) | |
download | gitea-88f835192d1a554d233b0ec4daa33276b7eb2910.tar.gz gitea-88f835192d1a554d233b0ec4daa33276b7eb2910.zip |
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](https://github.com/golang/go/commit/2580d0e08d5e9f979b943758d3c49877fb2324cb).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/api_admin_test.go | 2 | ||||
-rw-r--r-- | tests/integration/api_packages_conan_test.go | 2 | ||||
-rw-r--r-- | tests/integration/api_packages_nuget_test.go | 2 | ||||
-rw-r--r-- | tests/integration/api_packages_pub_test.go | 16 | ||||
-rw-r--r-- | tests/integration/api_packages_rpm_test.go | 2 | ||||
-rw-r--r-- | tests/integration/api_pull_review_test.go | 2 | ||||
-rw-r--r-- | tests/integration/api_token_test.go | 2 | ||||
-rw-r--r-- | tests/integration/dump_restore_test.go | 12 | ||||
-rw-r--r-- | tests/integration/integration_test.go | 6 | ||||
-rw-r--r-- | tests/integration/webfinger_test.go | 18 | ||||
-rw-r--r-- | tests/test_utils.go | 4 |
11 files changed, 34 insertions, 34 deletions
diff --git a/tests/integration/api_admin_test.go b/tests/integration/api_admin_test.go index 5900811922..6613d4b715 100644 --- a/tests/integration/api_admin_test.go +++ b/tests/integration/api_admin_test.go @@ -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)) diff --git a/tests/integration/api_packages_conan_test.go b/tests/integration/api_packages_conan_test.go index 209aeecd16..1f7890f3c0 100644 --- a/tests/integration/api_packages_conan_test.go +++ b/tests/integration/api_packages_conan_test.go @@ -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) diff --git a/tests/integration/api_packages_nuget_test.go b/tests/integration/api_packages_nuget_test.go index a6c4090f0e..3592d64db2 100644 --- a/tests/integration/api_packages_nuget_test.go +++ b/tests/integration/api_packages_nuget_test.go @@ -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)) diff --git a/tests/integration/api_packages_pub_test.go b/tests/integration/api_packages_pub_test.go index df0c7aa21b..cae280c0ec 100644 --- a/tests/integration/api_packages_pub_test.go +++ b/tests/integration/api_packages_pub_test.go @@ -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 { diff --git a/tests/integration/api_packages_rpm_test.go b/tests/integration/api_packages_rpm_test.go index 740bdf8262..e66460899f 100644 --- a/tests/integration/api_packages_rpm_test.go +++ b/tests/integration/api_packages_rpm_test.go @@ -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) diff --git a/tests/integration/api_pull_review_test.go b/tests/integration/api_pull_review_test.go index 4718f115cb..dd49cf6438 100644 --- a/tests/integration/api_pull_review_test.go +++ b/tests/integration/api_pull_review_test.go @@ -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)) diff --git a/tests/integration/api_token_test.go b/tests/integration/api_token_test.go index 0eecccb653..419884d45e 100644 --- a/tests/integration/api_token_test.go +++ b/tests/integration/api_token_test.go @@ -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 { diff --git a/tests/integration/dump_restore_test.go b/tests/integration/dump_restore_test.go index 0b6707845b..bed2453054 100644 --- a/tests/integration/dump_restore_test.go +++ b/tests/integration/dump_restore_test.go @@ -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() diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 2318ab9bb9..c904d32ffa 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -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) diff --git a/tests/integration/webfinger_test.go b/tests/integration/webfinger_test.go index f67abdbc2a..a1abc8d32b 100644 --- a/tests/integration/webfinger_test.go +++ b/tests/integration/webfinger_test.go @@ -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") diff --git a/tests/test_utils.go b/tests/test_utils.go index bf7d1b3fbe..fc4247eba8 100644 --- a/tests/test_utils.go +++ b/tests/test_utils.go @@ -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...) } |