diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-08-27 08:39:31 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-09-09 06:07:22 +0300 |
commit | 9bc6df51b36a1e0f763b6ebc7974bb3d98aabf3a (patch) | |
tree | 28b88e9c3b6f2a16650164c15a28bfc62360763f | |
parent | 9dd40765e162aba80482abdf3ca8f788bec7a8db (diff) |
refactor: move away from ioutil (deprecated)
26 files changed, 65 insertions, 72 deletions
diff --git a/internal/auth/auth_test.go b/internal/auth/auth_test.go index b49e5423..77ea0b7a 100644 --- a/internal/auth/auth_test.go +++ b/internal/auth/auth_test.go @@ -3,7 +3,7 @@ package auth import ( "bytes" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" @@ -301,7 +301,7 @@ func TestCheckAuthenticationWhenNoAccess(t *testing.T) { require.Equal(t, http.StatusNotFound, res.StatusCode) - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) require.NoError(t, err) require.Equal(t, string(body), "Generic 404") } @@ -471,7 +471,7 @@ func TestCheckResponseForInvalidTokenWhenInvalidToken(t *testing.T) { require.NoError(t, err) r := &http.Request{URL: reqURL, Host: "pages.gitlab-example.com", RequestURI: "/test"} - resp := &http.Response{StatusCode: http.StatusUnauthorized, Body: ioutil.NopCloser(bytes.NewReader([]byte("{\"error\":\"invalid_token\"}")))} + resp := &http.Response{StatusCode: http.StatusUnauthorized, Body: io.NopCloser(bytes.NewReader([]byte("{\"error\":\"invalid_token\"}")))} defer resp.Body.Close() require.Equal(t, true, auth.CheckResponseForInvalidToken(result, r, resp)) @@ -489,7 +489,7 @@ func TestCheckResponseForInvalidTokenWhenNotInvalidToken(t *testing.T) { require.NoError(t, err) r := &http.Request{URL: reqURL} - resp := &http.Response{StatusCode: http.StatusOK, Body: ioutil.NopCloser(bytes.NewReader([]byte("ok")))} + resp := &http.Response{StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader([]byte("ok")))} require.Equal(t, false, auth.CheckResponseForInvalidToken(result, r, resp)) } diff --git a/internal/config/config.go b/internal/config/config.go index 71ff0eed..61767a57 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,7 +3,7 @@ package config import ( "encoding/base64" "fmt" - "io/ioutil" + "os" "strings" "time" @@ -157,7 +157,7 @@ func setGitLabAPISecretKey(secretFile string, config *Config) error { return nil } - encoded, err := ioutil.ReadFile(secretFile) + encoded, err := os.ReadFile(secretFile) if err != nil { return fmt.Errorf("reading secret file: %w", err) } @@ -259,7 +259,7 @@ func loadConfig() (*Config, error) { {&config.General.RootKey, *pagesRootKey}, } { if file.path != "" { - if *file.contents, err = ioutil.ReadFile(file.path); err != nil { + if *file.contents, err = os.ReadFile(file.path); err != nil { return nil, err } } diff --git a/internal/domain/domain_test.go b/internal/domain/domain_test.go index f053001a..5a95b4ec 100644 --- a/internal/domain/domain_test.go +++ b/internal/domain/domain_test.go @@ -2,7 +2,7 @@ package domain import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -210,7 +210,7 @@ func TestServeNamespaceNotFound(t *testing.T) { defer resp.Body.Close() require.Equal(t, http.StatusNotFound, resp.StatusCode) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedResponse) diff --git a/internal/httpfs/http_fs_test.go b/internal/httpfs/http_fs_test.go index f47e17ff..cbdbc0e1 100644 --- a/internal/httpfs/http_fs_test.go +++ b/internal/httpfs/http_fs_test.go @@ -1,7 +1,7 @@ package httpfs import ( - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -87,7 +87,7 @@ func TestFSOpen(t *testing.T) { require.NoError(t, err) - content, err := ioutil.ReadAll(got) + content, err := io.ReadAll(got) require.NoError(t, err) require.Equal(t, test.expectedContent, string(content)) @@ -192,7 +192,7 @@ func TestFileSystemPathCanServeHTTP(t *testing.T) { defer res.Body.Close() require.Equal(t, test.expectedStatusCode, res.StatusCode) - content, err := ioutil.ReadAll(res.Body) + content, err := io.ReadAll(res.Body) require.NoError(t, err) require.Equal(t, test.expectedContent, string(content)) diff --git a/internal/httprange/resource.go b/internal/httprange/resource.go index 5e61d3fb..1da1af95 100644 --- a/internal/httprange/resource.go +++ b/internal/httprange/resource.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "strconv" "strings" @@ -87,7 +86,7 @@ func NewResource(ctx context.Context, url string, httpClient *http.Client) (*Res } defer func() { - io.CopyN(ioutil.Discard, res.Body, 1) // since we want to read a single byte + io.CopyN(io.Discard, res.Body, 1) // since we want to read a single byte res.Body.Close() }() diff --git a/internal/httptransport/metered_round_tripper_test.go b/internal/httptransport/metered_round_tripper_test.go index 218ed4a7..147cfdba 100644 --- a/internal/httptransport/metered_round_tripper_test.go +++ b/internal/httptransport/metered_round_tripper_test.go @@ -1,7 +1,7 @@ package httptransport import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "strconv" @@ -27,7 +27,7 @@ func TestReconfigureMeteredRoundTripper(t *testing.T) { defer res.Body.Close() require.Equal(t, http.StatusOK, res.StatusCode) - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) require.NoError(t, err) require.Equal(t, "httptransport/testdata/file.html\n", string(body)) diff --git a/internal/serving/disk/local/serving_test.go b/internal/serving/disk/local/serving_test.go index 2602451f..8352bfc9 100644 --- a/internal/serving/disk/local/serving_test.go +++ b/internal/serving/disk/local/serving_test.go @@ -1,7 +1,7 @@ package local import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -82,7 +82,7 @@ func TestDisk_ServeFileHTTP(t *testing.T) { defer resp.Body.Close() require.Equal(t, test.expectedStatus, resp.StatusCode) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) require.NoError(t, err) require.Contains(t, string(body), test.expectedBody) diff --git a/internal/serving/disk/symlink/path_test.go b/internal/serving/disk/symlink/path_test.go index c9da51c3..400432c2 100644 --- a/internal/serving/disk/symlink/path_test.go +++ b/internal/serving/disk/symlink/path_test.go @@ -6,7 +6,6 @@ package symlink_test import ( "context" - "io/ioutil" "os" "path/filepath" "runtime" @@ -156,7 +155,7 @@ func TestIssue13582(t *testing.T) { t.Fatal(err) } file := filepath.Join(linkToDir, "file") - err = ioutil.WriteFile(file, nil, 0644) + err = os.WriteFile(file, nil, 0644) if err != nil { t.Fatal(err) } diff --git a/internal/serving/disk/zip/serving_test.go b/internal/serving/disk/zip/serving_test.go index 2cbee18d..167c47c3 100644 --- a/internal/serving/disk/zip/serving_test.go +++ b/internal/serving/disk/zip/serving_test.go @@ -1,7 +1,7 @@ package zip import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "os" @@ -127,7 +127,7 @@ func TestZip_ServeFileHTTP(t *testing.T) { defer resp.Body.Close() require.Equal(t, test.expectedStatus, resp.StatusCode) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) require.NoError(t, err) require.Contains(t, string(body), test.expectedBody) diff --git a/internal/source/gitlab/client/client.go b/internal/source/gitlab/client/client.go index 30185143..92ae0390 100644 --- a/internal/source/gitlab/client/client.go +++ b/internal/source/gitlab/client/client.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "path" @@ -118,7 +117,7 @@ func (gc *Client) GetLookup(ctx context.Context, host string) api.Lookup { // larger than 512 bytes, the response body will not be closed properly, thus // we need to close it manually in every case. defer func() { - io.Copy(ioutil.Discard, resp.Body) + io.Copy(io.Discard, resp.Body) resp.Body.Close() }() @@ -154,7 +153,7 @@ func (gc *Client) get(ctx context.Context, path string, params url.Values) (*htt // nolint: errcheck // best effort to discard and close the response body - io.Copy(ioutil.Discard, resp.Body) + io.Copy(io.Discard, resp.Body) resp.Body.Close() // StatusNoContent means that a domain does not exist, it is not an error diff --git a/internal/testhelpers/tmpdir.go b/internal/testhelpers/tmpdir.go index 5765d308..92987199 100644 --- a/internal/testhelpers/tmpdir.go +++ b/internal/testhelpers/tmpdir.go @@ -2,7 +2,6 @@ package testhelpers import ( "context" - "io/ioutil" "os" "path/filepath" "testing" @@ -18,7 +17,7 @@ var fs = vfs.Instrumented(&local.VFS{}) func TmpDir(tb testing.TB, pattern string) (vfs.Root, string) { tb.Helper() - tmpDir, err := ioutil.TempDir("", pattern) + tmpDir, err := os.MkdirTemp("", pattern) require.NoError(tb, err) // On some systems `/tmp` can be a symlink diff --git a/internal/vfs/local/root_test.go b/internal/vfs/local/root_test.go index f89e7736..1cf505bf 100644 --- a/internal/vfs/local/root_test.go +++ b/internal/vfs/local/root_test.go @@ -2,7 +2,7 @@ package local import ( "context" - "io/ioutil" + "io" "os" "path/filepath" "testing" @@ -288,7 +288,7 @@ func TestOpen(t *testing.T) { require.NoError(t, err, "Open") - data, err := ioutil.ReadAll(file) + data, err := io.ReadAll(file) require.NoError(t, err, "ReadAll") require.Equal(t, test.expectedContent, string(data), "ReadAll") }) diff --git a/internal/vfs/local/vfs_test.go b/internal/vfs/local/vfs_test.go index b678cfa7..2072d110 100644 --- a/internal/vfs/local/vfs_test.go +++ b/internal/vfs/local/vfs_test.go @@ -2,7 +2,6 @@ package local import ( "context" - "io/ioutil" "os" "path/filepath" "testing" @@ -16,7 +15,7 @@ import ( var localVFS = &VFS{} func tmpDir(t *testing.T) (string, func()) { - tmpDir, err := ioutil.TempDir("", "vfs") + tmpDir, err := os.MkdirTemp("", "vfs") require.NoError(t, err) // On some systems `/tmp` can be a symlink @@ -44,7 +43,7 @@ func TestVFSRoot(t *testing.T) { require.NoError(t, err) filePath := filepath.Join(tmpDir, "file") - err = ioutil.WriteFile(filePath, []byte{}, 0644) + err = os.WriteFile(filePath, []byte{}, 0644) require.NoError(t, err) symlinks := map[string]string{ diff --git a/internal/vfs/zip/archive_test.go b/internal/vfs/zip/archive_test.go index 23fe0583..acd89d49 100644 --- a/internal/vfs/zip/archive_test.go +++ b/internal/vfs/zip/archive_test.go @@ -6,7 +6,6 @@ import ( "context" "crypto/rand" "io" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -77,7 +76,7 @@ func testOpen(t *testing.T, zip *zipArchive) { } require.NoError(t, err) - data, err := ioutil.ReadAll(f) + data, err := io.ReadAll(f) require.NoError(t, err) require.Equal(t, tt.expectedContent, string(data)) @@ -173,7 +172,7 @@ func TestOpenCached(t *testing.T) { require.NoError(t, err) defer f.Close() - _, err = ioutil.ReadAll(f) + _, err = io.ReadAll(f) if test.expectedReadErr != nil { require.Equal(t, test.expectedReadErr, err) status, _ := zip.(*zipArchive).openStatus() @@ -354,7 +353,7 @@ func TestArchiveCanBeReadAfterOpenCtxCanceled(t *testing.T) { file, err := zip.Open(context.Background(), "index.html") require.NoError(t, err) - data, err := ioutil.ReadAll(file) + data, err := io.ReadAll(file) require.NoError(t, err) require.Equal(t, "zip.gitlab.io/project/index.html\n", string(data)) @@ -478,7 +477,7 @@ func benchmarkArchiveRead(b *testing.B, size int64) { f, err := z.Open(context.Background(), "file.txt") require.NoError(b, err) - _, err = io.Copy(ioutil.Discard, f) + _, err = io.Copy(io.Discard, f) require.NoError(b, err) require.NoError(b, f.Close()) diff --git a/internal/vfs/zip/vfs_test.go b/internal/vfs/zip/vfs_test.go index 22cc5c6b..fb368a69 100644 --- a/internal/vfs/zip/vfs_test.go +++ b/internal/vfs/zip/vfs_test.go @@ -2,7 +2,7 @@ package zip import ( "context" - "io/ioutil" + "io" "testing" "time" @@ -55,7 +55,7 @@ func TestVFSRoot(t *testing.T) { f, err := root.Open(context.Background(), "index.html") require.NoError(t, err) - content, err := ioutil.ReadAll(f) + content, err := io.ReadAll(f) require.NoError(t, err) require.Equal(t, "zip.gitlab.io/project/index.html\n", string(content)) diff --git a/test/acceptance/acme_test.go b/test/acceptance/acme_test.go index 1d6ea4ec..f0259e05 100644 --- a/test/acceptance/acme_test.go +++ b/test/acceptance/acme_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net/http" "net/url" "testing" @@ -44,7 +44,7 @@ func TestAcmeChallengesWhenItIsNotConfigured(t *testing.T) { defer rsp.Body.Close() require.NoError(t, err) require.Equal(t, test.expectedStatus, rsp.StatusCode) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Contains(t, string(body), test.expectedContent) @@ -85,7 +85,7 @@ func TestAcmeChallengesWhenItIsConfigured(t *testing.T) { defer rsp.Body.Close() require.NoError(t, err) require.Equal(t, test.expectedStatus, rsp.StatusCode) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Contains(t, string(body), test.expectedContent) diff --git a/test/acceptance/artifacts_test.go b/test/acceptance/artifacts_test.go index 01bb1f5c..dddfeb67 100644 --- a/test/acceptance/artifacts_test.go +++ b/test/acceptance/artifacts_test.go @@ -3,7 +3,7 @@ package acceptance_test import ( "crypto/tls" "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/url" @@ -142,7 +142,7 @@ func TestArtifactProxyRequest(t *testing.T) { require.Equal(t, tt.contentType, resp.Header.Get("Content-Type")) if tt.status == http.StatusOK { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) require.NoError(t, err) require.Equal(t, tt.content, string(body)) require.Equal(t, tt.length, resp.ContentLength) diff --git a/test/acceptance/auth_test.go b/test/acceptance/auth_test.go index 7ec55d95..3c616f7c 100644 --- a/test/acceptance/auth_test.go +++ b/test/acceptance/auth_test.go @@ -2,7 +2,7 @@ package acceptance_test import ( "fmt" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -278,7 +278,7 @@ func TestCustomErrorPageWithAuth(t *testing.T) { require.Equal(t, http.StatusNotFound, anotherResp.StatusCode) - page, err := ioutil.ReadAll(anotherResp.Body) + page, err := io.ReadAll(anotherResp.Body) require.NoError(t, err) require.Contains(t, string(page), tt.expectedErrorPage) }) diff --git a/test/acceptance/helpers_test.go b/test/acceptance/helpers_test.go index b8181dca..33a19127 100644 --- a/test/acceptance/helpers_test.go +++ b/test/acceptance/helpers_test.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net" "net/http" "net/http/httptest" @@ -261,7 +260,7 @@ func RunPagesProcessWithSSLCertFile(t *testing.T, listeners []ListenSpec, sslCer func RunPagesProcessWithSSLCertDir(t *testing.T, listeners []ListenSpec, sslCertFile string) { // Create temporary cert dir - sslCertDir, err := ioutil.TempDir("", "pages-test-SSL_CERT_DIR") + sslCertDir, err := os.MkdirTemp("", "pages-test-SSL_CERT_DIR") require.NoError(t, err) // Copy sslCertFile into temp cert dir @@ -621,7 +620,7 @@ func defaultUserHandler(t *testing.T, opts *stubOpts) http.HandlerFunc { func newConfigFile(t *testing.T, configs ...string) string { t.Helper() - f, err := ioutil.TempFile(os.TempDir(), "gitlab-pages-config") + f, err := os.CreateTemp(os.TempDir(), "gitlab-pages-config") require.NoError(t, err) defer f.Close() diff --git a/test/acceptance/metrics_test.go b/test/acceptance/metrics_test.go index 0e8237b7..cb4262fb 100644 --- a/test/acceptance/metrics_test.go +++ b/test/acceptance/metrics_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net/http" "testing" @@ -28,7 +28,7 @@ func TestPrometheusMetricsCanBeScraped(t *testing.T) { require.NoError(t, err) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) require.NoError(t, err) require.Contains(t, string(body), "gitlab_pages_http_in_flight_requests 0") diff --git a/test/acceptance/proxyv2_test.go b/test/acceptance/proxyv2_test.go index 8091e8c6..81a7ff94 100644 --- a/test/acceptance/proxyv2_test.go +++ b/test/acceptance/proxyv2_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net/http" "testing" "time" @@ -41,7 +41,7 @@ func TestProxyv2(t *testing.T) { require.Equal(t, tt.expectedStatusCode, response.StatusCode) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedContent, "content mismatch") diff --git a/test/acceptance/redirects_test.go b/test/acceptance/redirects_test.go index dd1b6891..1ce7a0be 100644 --- a/test/acceptance/redirects_test.go +++ b/test/acceptance/redirects_test.go @@ -2,7 +2,7 @@ package acceptance_test import ( "fmt" - "io/ioutil" + "io" "net/http" "testing" @@ -41,7 +41,7 @@ func TestRedirectStatusPage(t *testing.T) { rsp, err := GetPageFromListener(t, httpListener, "group.redirects.gitlab-example.com", "/project-redirects/_redirects") require.NoError(t, err) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) defer rsp.Body.Close() diff --git a/test/acceptance/rewrites_test.go b/test/acceptance/rewrites_test.go index a446a8cd..5ac16070 100644 --- a/test/acceptance/rewrites_test.go +++ b/test/acceptance/rewrites_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net/http" "testing" @@ -49,7 +49,7 @@ func TestRewrites(t *testing.T) { require.NoError(t, err) defer rsp.Body.Close() - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedBody) diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go index d401f417..c6a7d3ef 100644 --- a/test/acceptance/serving_test.go +++ b/test/acceptance/serving_test.go @@ -2,7 +2,7 @@ package acceptance_test import ( "fmt" - "io/ioutil" + "io" "net/http" "strings" "testing" @@ -40,7 +40,7 @@ func TestGroupDomainReturns200(t *testing.T) { defer rsp.Body.Close() require.Equal(t, http.StatusOK, rsp.StatusCode) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Equal(t, string(body), "OK\n") @@ -94,7 +94,7 @@ func TestKnownHostReturns200(t *testing.T) { require.NoError(t, err) require.Equal(t, http.StatusOK, rsp.StatusCode) - body, err := ioutil.ReadAll(rsp.Body) + body, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Equal(t, tt.content, string(body)) @@ -156,7 +156,7 @@ func TestCustom404(t *testing.T) { defer rsp.Body.Close() require.Equal(t, http.StatusNotFound, rsp.StatusCode) - page, err := ioutil.ReadAll(rsp.Body) + page, err := io.ReadAll(rsp.Body) require.NoError(t, err) require.Contains(t, string(page), test.content) } @@ -409,7 +409,7 @@ func TestDomainResolverError(t *testing.T) { require.Equal(t, http.StatusBadGateway, response.StatusCode) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) require.Contains(t, string(body), "Something went wrong (502)", "content mismatch") diff --git a/test/acceptance/stub_test.go b/test/acceptance/stub_test.go index 10bd3cf6..7fc733a1 100644 --- a/test/acceptance/stub_test.go +++ b/test/acceptance/stub_test.go @@ -2,9 +2,9 @@ package acceptance_test import ( "fmt" - "io/ioutil" "net/http" "net/http/httptest" + "os" "regexp" "testing" "time" @@ -110,18 +110,18 @@ func apiHandler(t *testing.T) http.HandlerFunc { func CreateHTTPSFixtureFiles(t *testing.T) (key string, cert string) { t.Helper() - keyfile, err := ioutil.TempFile("", "https-fixture") + keyfile, err := os.CreateTemp("", "https-fixture") require.NoError(t, err) key = keyfile.Name() keyfile.Close() - certfile, err := ioutil.TempFile("", "https-fixture") + certfile, err := os.CreateTemp("", "https-fixture") require.NoError(t, err) cert = certfile.Name() certfile.Close() - require.NoError(t, ioutil.WriteFile(key, []byte(fixture.Key), 0644)) - require.NoError(t, ioutil.WriteFile(cert, []byte(fixture.Certificate), 0644)) + require.NoError(t, os.WriteFile(key, []byte(fixture.Key), 0644)) + require.NoError(t, os.WriteFile(cert, []byte(fixture.Certificate), 0644)) return keyfile.Name(), certfile.Name() } @@ -129,11 +129,11 @@ func CreateHTTPSFixtureFiles(t *testing.T) (key string, cert string) { func CreateGitLabAPISecretKeyFixtureFile(t *testing.T) (filepath string) { t.Helper() - secretfile, err := ioutil.TempFile("", "gitlab-api-secret") + secretfile, err := os.CreateTemp("", "gitlab-api-secret") require.NoError(t, err) secretfile.Close() - require.NoError(t, ioutil.WriteFile(secretfile.Name(), []byte(fixture.GitLabAPISecretKey), 0644)) + require.NoError(t, os.WriteFile(secretfile.Name(), []byte(fixture.GitLabAPISecretKey), 0644)) return secretfile.Name() } diff --git a/test/acceptance/zip_test.go b/test/acceptance/zip_test.go index 3bdd1c49..97a35e2b 100644 --- a/test/acceptance/zip_test.go +++ b/test/acceptance/zip_test.go @@ -1,7 +1,7 @@ package acceptance_test import ( - "io/ioutil" + "io" "net" "net/http" "net/http/httptest" @@ -88,7 +88,7 @@ func TestZipServing(t *testing.T) { require.Equal(t, tt.expectedStatusCode, response.StatusCode) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedContent, "content mismatch") @@ -171,7 +171,7 @@ func TestZipServingFromDisk(t *testing.T) { require.Equal(t, tt.expectedStatusCode, response.StatusCode) - body, err := ioutil.ReadAll(response.Body) + body, err := io.ReadAll(response.Body) require.NoError(t, err) require.Contains(t, string(body), tt.expectedContent, "content mismatch") |