Remove deprecated packages & staticcheck fixes (#22012)
`ioutil` is deprecated and should use `io` instead
This commit is contained in:
parent
21bcb92926
commit
8698458f48
7 changed files with 15 additions and 16 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue