diff options
author | Chongyi Zheng <harryzheng25@gmail.com> | 2022-12-02 17:06:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 17:06:23 -0500 |
commit | 8698458f48eafeab21014db544aa7160368856e1 (patch) | |
tree | cc324e8f8856412ce7e715dacacb6301a2857004 | |
parent | 21bcb929260d1e41fd84c650aeea552f540d0981 (diff) | |
download | gitea-8698458f48eafeab21014db544aa7160368856e1.tar.gz gitea-8698458f48eafeab21014db544aa7160368856e1.zip |
Remove deprecated packages & staticcheck fixes (#22012)
`ioutil` is deprecated and should use `io` instead
-rw-r--r-- | modules/activitypub/client_test.go | 2 | ||||
-rw-r--r-- | tests/integration/api_packages_nuget_test.go | 3 | ||||
-rw-r--r-- | tests/integration/api_packages_vagrant_test.go | 2 | ||||
-rw-r--r-- | tests/integration/api_pull_test.go | 4 | ||||
-rw-r--r-- | tests/integration/download_test.go | 16 | ||||
-rw-r--r-- | tests/integration/nonascii_branches_test.go | 2 | ||||
-rw-r--r-- | tests/integration/rename_branch_test.go | 2 |
7 files changed, 15 insertions, 16 deletions
diff --git a/modules/activitypub/client_test.go b/modules/activitypub/client_test.go index b5f978c4dd..0ab512c5ba 100644 --- a/modules/activitypub/client_test.go +++ b/modules/activitypub/client_test.go @@ -35,7 +35,7 @@ func TestActivityPubSignedPost(t *testing.T) { body, err := io.ReadAll(r.Body) assert.NoError(t, err) assert.Equal(t, expected, string(body)) - fmt.Fprintf(w, expected) + fmt.Fprint(w, expected) })) defer srv.Close() diff --git a/tests/integration/api_packages_nuget_test.go b/tests/integration/api_packages_nuget_test.go index 72329b6691..cc4ff180d0 100644 --- a/tests/integration/api_packages_nuget_test.go +++ b/tests/integration/api_packages_nuget_test.go @@ -10,7 +10,6 @@ import ( "encoding/xml" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "testing" @@ -105,7 +104,7 @@ func TestPackageNuGet(t *testing.T) { return &buf } - content, _ := ioutil.ReadAll(createPackage(packageName, packageVersion)) + content, _ := io.ReadAll(createPackage(packageName, packageVersion)) url := fmt.Sprintf("/api/packages/%s/nuget", user.Name) diff --git a/tests/integration/api_packages_vagrant_test.go b/tests/integration/api_packages_vagrant_test.go index d3e4449f29..b4f04b0c89 100644 --- a/tests/integration/api_packages_vagrant_test.go +++ b/tests/integration/api_packages_vagrant_test.go @@ -87,7 +87,7 @@ func TestPackageVagrant(t *testing.T) { req = NewRequest(t, "HEAD", boxURL) resp := MakeRequest(t, req, http.StatusOK) - assert.True(t, strings.HasPrefix(resp.HeaderMap.Get("Content-Type"), "application/json")) + assert.True(t, strings.HasPrefix(resp.Header().Get("Content-Type"), "application/json")) pvs, err := packages.GetVersionsByPackageType(db.DefaultContext, user.ID, packages.TypeVagrant) assert.NoError(t, err) diff --git a/tests/integration/api_pull_test.go b/tests/integration/api_pull_test.go index 3d7256d30d..89d39179a6 100644 --- a/tests/integration/api_pull_test.go +++ b/tests/integration/api_pull_test.go @@ -5,7 +5,7 @@ package integration import ( "fmt" - "io/ioutil" + "io" "net/http" "testing" @@ -41,7 +41,7 @@ func TestAPIViewPulls(t *testing.T) { pull := pulls[0] if assert.EqualValues(t, 5, pull.ID) { resp = ctx.Session.MakeRequest(t, NewRequest(t, "GET", pull.DiffURL), http.StatusOK) - _, err := ioutil.ReadAll(resp.Body) + _, err := io.ReadAll(resp.Body) assert.NoError(t, err) // TODO: use diff to generate stats to test against diff --git a/tests/integration/download_test.go b/tests/integration/download_test.go index 9e03ec2882..efe5ac791c 100644 --- a/tests/integration/download_test.go +++ b/tests/integration/download_test.go @@ -34,9 +34,9 @@ func TestDownloadByIDForSVGUsesSecureHeaders(t *testing.T) { req := NewRequest(t, "GET", "/user2/repo2/raw/blob/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b") resp := session.MakeRequest(t, req, http.StatusOK) - assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.HeaderMap.Get("Content-Security-Policy")) - assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type")) - assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options")) + assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.Header().Get("Content-Security-Policy")) + assert.Equal(t, "image/svg+xml", resp.Header().Get("Content-Type")) + assert.Equal(t, "nosniff", resp.Header().Get("X-Content-Type-Options")) } func TestDownloadByIDMedia(t *testing.T) { @@ -60,9 +60,9 @@ func TestDownloadByIDMediaForSVGUsesSecureHeaders(t *testing.T) { req := NewRequest(t, "GET", "/user2/repo2/media/blob/6395b68e1feebb1e4c657b4f9f6ba2676a283c0b") resp := session.MakeRequest(t, req, http.StatusOK) - assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.HeaderMap.Get("Content-Security-Policy")) - assert.Equal(t, "image/svg+xml", resp.HeaderMap.Get("Content-Type")) - assert.Equal(t, "nosniff", resp.HeaderMap.Get("X-Content-Type-Options")) + assert.Equal(t, "default-src 'none'; style-src 'unsafe-inline'; sandbox", resp.Header().Get("Content-Security-Policy")) + assert.Equal(t, "image/svg+xml", resp.Header().Get("Content-Type")) + assert.Equal(t, "nosniff", resp.Header().Get("X-Content-Type-Options")) } func TestDownloadRawTextFileWithoutMimeTypeMapping(t *testing.T) { @@ -73,7 +73,7 @@ func TestDownloadRawTextFileWithoutMimeTypeMapping(t *testing.T) { req := NewRequest(t, "GET", "/user2/repo2/raw/branch/master/test.xml") resp := session.MakeRequest(t, req, http.StatusOK) - assert.Equal(t, "text/plain; charset=utf-8", resp.HeaderMap.Get("Content-Type")) + assert.Equal(t, "text/plain; charset=utf-8", resp.Header().Get("Content-Type")) } func TestDownloadRawTextFileWithMimeTypeMapping(t *testing.T) { @@ -86,7 +86,7 @@ func TestDownloadRawTextFileWithMimeTypeMapping(t *testing.T) { req := NewRequest(t, "GET", "/user2/repo2/raw/branch/master/test.xml") resp := session.MakeRequest(t, req, http.StatusOK) - assert.Equal(t, "text/xml; charset=utf-8", resp.HeaderMap.Get("Content-Type")) + assert.Equal(t, "text/xml; charset=utf-8", resp.Header().Get("Content-Type")) delete(setting.MimeTypeMap.Map, ".xml") setting.MimeTypeMap.Enabled = false diff --git a/tests/integration/nonascii_branches_test.go b/tests/integration/nonascii_branches_test.go index d9e5b0fce3..8917a9b574 100644 --- a/tests/integration/nonascii_branches_test.go +++ b/tests/integration/nonascii_branches_test.go @@ -22,7 +22,7 @@ func testSrcRouteRedirect(t *testing.T, session *TestSession, user, repo, route, resp := session.MakeRequest(t, req, http.StatusSeeOther) // Check Location header - location := resp.HeaderMap.Get("Location") + location := resp.Header().Get("Location") assert.Equal(t, path.Join(prefix, expectedLocation), location) // Perform redirect diff --git a/tests/integration/rename_branch_test.go b/tests/integration/rename_branch_test.go index d8434c28bb..9a55193ccf 100644 --- a/tests/integration/rename_branch_test.go +++ b/tests/integration/rename_branch_test.go @@ -35,7 +35,7 @@ func TestRenameBranch(t *testing.T) { // check old branch link req = NewRequestWithValues(t, "GET", "/user2/repo1/src/branch/master/README.md", postData) resp = session.MakeRequest(t, req, http.StatusSeeOther) - location := resp.HeaderMap.Get("Location") + location := resp.Header().Get("Location") assert.Equal(t, "/user2/repo1/src/branch/main/README.md", location) // check db |