all: fix deprecated ioutil commands
Change-Id: I59db35116ec7215a1b8e2ae7dbd319fa099adfac
This commit is contained in:
parent
11d1e623b5
commit
ff22fc7ddd
@ -4,7 +4,7 @@
|
||||
package authorization
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"testing"
|
||||
@ -50,7 +50,7 @@ func TestEndpoint_Run_httpSuccess(t *testing.T) {
|
||||
|
||||
require.Equal(t, http.StatusCreated, res.StatusCode)
|
||||
|
||||
tokenBytes, err := ioutil.ReadAll(res.Body)
|
||||
tokenBytes, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, tokenBytes)
|
||||
require.NoError(t, res.Body.Close())
|
||||
|
@ -9,7 +9,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -102,7 +101,7 @@ func main() {
|
||||
}
|
||||
|
||||
func process(file string) {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
check(err)
|
||||
|
||||
source := string(data)
|
||||
@ -111,7 +110,7 @@ func process(file string) {
|
||||
// end up generating an `import _ "."`, the following replace removes it.
|
||||
source = strings.Replace(source, `_ "."`, "", -1)
|
||||
|
||||
err = ioutil.WriteFile(file, []byte(source), 0644)
|
||||
err = os.WriteFile(file, []byte(source), 0644)
|
||||
check(err)
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ package rpcerrs_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -91,7 +91,7 @@ func TestLoggingSanitizer_Error(t *testing.T) {
|
||||
}
|
||||
|
||||
if s.log != nil {
|
||||
logData, err := ioutil.ReadAll(logFile)
|
||||
logData, err := io.ReadAll(logFile)
|
||||
require.NoError(t, err)
|
||||
|
||||
logStr := string(logData)
|
||||
@ -116,7 +116,7 @@ func TestLoggingSanitizer_Error(t *testing.T) {
|
||||
}
|
||||
|
||||
if s.log != nil {
|
||||
logData, err := ioutil.ReadAll(logFile)
|
||||
logData, err := io.ReadAll(logFile)
|
||||
require.NoError(t, err)
|
||||
|
||||
logStr := string(logData)
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"crypto"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync/atomic"
|
||||
@ -157,7 +156,7 @@ func saveIdentityTar(path string, key crypto.PrivateKey, id storj.NodeID) error
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
if err = ioutil.WriteFile(path+".tar", tarData.Bytes(), 0600); err != nil {
|
||||
if err = os.WriteFile(path+".tar", tarData.Bytes(), 0600); err != nil {
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
return nil
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"compress/flate"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@ -100,7 +99,7 @@ func TestAutoUpdater(t *testing.T) {
|
||||
// NB: updater currently uses `log.SetOutput` so all output after that call
|
||||
// only goes to the log file.
|
||||
out, err := exec.Command(updaterPath, args...).CombinedOutput()
|
||||
logData, logErr := ioutil.ReadFile(logPath)
|
||||
logData, logErr := os.ReadFile(logPath)
|
||||
if assert.NoError(t, logErr) {
|
||||
logStr := string(logData)
|
||||
t.Log(logStr)
|
||||
@ -178,7 +177,7 @@ func testIdentityFiles(ctx *testcontext.Context, t *testing.T) identity.Config {
|
||||
identConfig.CertPath,
|
||||
identConfig.KeyPath,
|
||||
)
|
||||
err = ioutil.WriteFile(ctx.File("config.yaml"), []byte(configData), 0644)
|
||||
err = os.WriteFile(ctx.File("config.yaml"), []byte(configData), 0644)
|
||||
require.NoError(t, err)
|
||||
|
||||
return identConfig
|
||||
@ -191,7 +190,7 @@ func testVersionControlWithUpdates(ctx *testcontext.Context, t *testing.T, updat
|
||||
for name, src := range updateBins {
|
||||
dst := ctx.File("updates", name+".zip")
|
||||
zipBin(ctx, t, dst, src)
|
||||
zipData, err := ioutil.ReadFile(dst)
|
||||
zipData, err := os.ReadFile(dst)
|
||||
require.NoError(t, err)
|
||||
|
||||
mux.HandleFunc("/"+name, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -281,7 +280,7 @@ func zipBin(ctx *testcontext.Context, t *testing.T, dst, src string) {
|
||||
contents, err := writer.Create(base)
|
||||
require.NoError(t, err)
|
||||
|
||||
data, err := ioutil.ReadFile(src)
|
||||
data, err := os.ReadFile(src)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = contents.Write(data)
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"strings"
|
||||
@ -77,7 +76,7 @@ func (ce *consoleEndpoints) graphqlDo(request *http.Request, jsonResponse interf
|
||||
}
|
||||
defer func() { err = errs.Combine(err, resp.Body.Close()) }()
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -311,7 +310,7 @@ func newNetwork(flags *Flags) (*Processes, error) {
|
||||
"dir ./",
|
||||
}
|
||||
conf := strings.Join(arguments, "\n") + "\n"
|
||||
err := ioutil.WriteFile(confpath, []byte(conf), 0755)
|
||||
err := os.WriteFile(confpath, []byte(conf), 0755)
|
||||
return err
|
||||
}
|
||||
process.Arguments = Arguments{
|
||||
|
@ -5,7 +5,7 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPrefixWriter(t *testing.T) {
|
||||
root := NewPrefixWriter("", storjSimMaxLineLen, ioutil.Discard)
|
||||
root := NewPrefixWriter("", storjSimMaxLineLen, io.Discard)
|
||||
alpha := root.Prefixed("alpha")
|
||||
defer func() { _ = alpha.Flush() }()
|
||||
beta := root.Prefixed("beta")
|
||||
|
@ -4,7 +4,7 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
@ -65,11 +65,11 @@ func TestProcess(t *testing.T) {
|
||||
|
||||
require.NoError(t, service.Close())
|
||||
|
||||
retryCSV, err := ioutil.ReadFile(config.RetryPath)
|
||||
retryCSV, err := os.ReadFile(config.RetryPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "stream id,position,found,not found,retry\n", string(retryCSV))
|
||||
|
||||
notFoundCSV, err := ioutil.ReadFile(config.NotFoundPath)
|
||||
notFoundCSV, err := os.ReadFile(config.NotFoundPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "stream id,position,found,not found,retry\n", string(notFoundCSV))
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -180,7 +180,7 @@ func (service *Service) applyIgnoreNodes(ctx context.Context) (err error) {
|
||||
// parseNodeFile parses a file containing node ID-s.
|
||||
func (service *Service) parseNodeFile(path string) (NodeAliasSet, error) {
|
||||
set := NodeAliasSet{}
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return set, Error.New("unable to read nodes file: %w", err)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ package main_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
@ -64,7 +64,7 @@ func TestService_Success(t *testing.T) {
|
||||
}
|
||||
|
||||
// the node 1 is going to be priority
|
||||
err := ioutil.WriteFile(config.PriorityNodesPath, []byte((storj.NodeID{1}).String()+"\n"), 0755)
|
||||
err := os.WriteFile(config.PriorityNodesPath, []byte((storj.NodeID{1}).String()+"\n"), 0755)
|
||||
require.NoError(t, err)
|
||||
|
||||
func() {
|
||||
@ -116,11 +116,11 @@ func TestService_Success(t *testing.T) {
|
||||
assert.Len(t, verifier.processed[nodes[4]], 1)
|
||||
}()
|
||||
|
||||
retryCSV, err := ioutil.ReadFile(config.RetryPath)
|
||||
retryCSV, err := os.ReadFile(config.RetryPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "stream id,position,found,not found,retry\n", string(retryCSV))
|
||||
|
||||
notFoundCSV, err := ioutil.ReadFile(config.NotFoundPath)
|
||||
notFoundCSV, err := os.ReadFile(config.NotFoundPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "stream id,position,found,not found,retry\n", string(notFoundCSV))
|
||||
}
|
||||
@ -140,7 +140,7 @@ func TestService_Failures(t *testing.T) {
|
||||
}
|
||||
|
||||
// the node 1 is going to be priority
|
||||
err := ioutil.WriteFile(config.PriorityNodesPath, []byte((storj.NodeID{1}).String()+"\n"), 0755)
|
||||
err := os.WriteFile(config.PriorityNodesPath, []byte((storj.NodeID{1}).String()+"\n"), 0755)
|
||||
require.NoError(t, err)
|
||||
|
||||
func() {
|
||||
@ -185,14 +185,14 @@ func TestService_Failures(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
retryCSV, err := ioutil.ReadFile(config.RetryPath)
|
||||
retryCSV, err := os.ReadFile(config.RetryPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, ""+
|
||||
"stream id,position,found,not found,retry\n"+
|
||||
"10100000-0000-0000-0000-000000000000,0,1,0,1\n",
|
||||
string(retryCSV))
|
||||
|
||||
notFoundCSV, err := ioutil.ReadFile(config.NotFoundPath)
|
||||
notFoundCSV, err := os.ReadFile(config.NotFoundPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, ""+
|
||||
"stream id,position,found,not found,retry\n"+
|
||||
|
@ -175,7 +175,7 @@ func (ex *external) ExportAccess(ctx context.Context, access *uplink.Access, fil
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
// note: we don't use ioutil.WriteFile because we want to pass
|
||||
// note: we don't use os.WriteFile because we want to pass
|
||||
// the O_EXCL flag to ensure we don't overwrite existing files.
|
||||
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
|
||||
if err != nil {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@ -102,7 +102,7 @@ func RegisterAccess(ctx context.Context, access *uplink.Access, authService stri
|
||||
}
|
||||
defer func() { err = errs.Combine(err, resp.Body.Close()) }()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ package ultest
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
@ -143,7 +143,7 @@ func collectIterator(ctx context.Context, t *testing.T, fs ulfs.FilesystemLocal,
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = rh.Close() }()
|
||||
|
||||
data, err := ioutil.ReadAll(rh)
|
||||
data, err := io.ReadAll(rh)
|
||||
require.NoError(t, err)
|
||||
files = append(files, File{
|
||||
Loc: loc,
|
||||
|
@ -6,7 +6,7 @@ package multinodedb_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -50,7 +50,7 @@ func TestMigrateSQLite3(t *testing.T) {
|
||||
version := parseTestdataVersion(match, "sqlite3")
|
||||
require.True(t, version >= 0, "invalid testdata file %q: %v", match, err)
|
||||
|
||||
scriptData, err := ioutil.ReadFile(match)
|
||||
scriptData, err := os.ReadFile(match)
|
||||
require.NoError(t, err, "could not read testdata file for version %d: %v", version, err)
|
||||
|
||||
// exec per snapshot??
|
||||
@ -131,7 +131,7 @@ func TestMigratePostgres(t *testing.T) {
|
||||
version := parseTestdataVersion(match, "postgres")
|
||||
require.True(t, version >= 0, "invalid testdata file %q: %v", match, err)
|
||||
|
||||
scriptData, err := ioutil.ReadFile(match)
|
||||
scriptData, err := os.ReadFile(match)
|
||||
require.NoError(t, err, "could not read testdata file for version %d: %v", version, err)
|
||||
|
||||
snapshot, err := loadSnapshotFromSQLPostgres(ctx, connStr, string(scriptData))
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
@ -74,7 +73,7 @@ func send(ctx context.Context, method string, url string, body interface{}) ([]b
|
||||
return nil, err
|
||||
}
|
||||
|
||||
respBody, err := ioutil.ReadAll(resp.Body)
|
||||
respBody, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -102,7 +101,7 @@ func main() {
|
||||
}
|
||||
|
||||
func process(file string) {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
check(err)
|
||||
|
||||
source := string(data)
|
||||
@ -111,7 +110,7 @@ func process(file string) {
|
||||
// end up generating an `import _ "."`, the following replace removes it.
|
||||
source = strings.Replace(source, `_ "."`, "", -1)
|
||||
|
||||
err = ioutil.WriteFile(file, []byte(source), 0644)
|
||||
err = os.WriteFile(file, []byte(source), 0644)
|
||||
check(err)
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -63,7 +62,7 @@ func basicMigration(ctx *testcontext.Context, t *testing.T, db tagsql.DB, testDB
|
||||
defer func() { assert.NoError(t, dropTables(ctx, db, dbName, "users")) }()
|
||||
|
||||
/* #nosec G306 */ // This is a test besides the file contains just test data.
|
||||
err := ioutil.WriteFile(ctx.File("alpha.txt"), []byte("test"), 0644)
|
||||
err := os.WriteFile(ctx.File("alpha.txt"), []byte("test"), 0644)
|
||||
require.NoError(t, err)
|
||||
m := migrate.Migration{
|
||||
Table: dbName,
|
||||
@ -131,7 +130,7 @@ func basicMigration(ctx *testcontext.Context, t *testing.T, db tagsql.DB, testDB
|
||||
// file exists
|
||||
_, err = os.Stat(ctx.File("beta.txt"))
|
||||
assert.NoError(t, err)
|
||||
data, err := ioutil.ReadFile(ctx.File("beta.txt"))
|
||||
data, err := os.ReadFile(ctx.File("beta.txt"))
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, []byte("test"), data)
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -102,7 +101,7 @@ func main() {
|
||||
}
|
||||
|
||||
func process(file string) {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
check(err)
|
||||
|
||||
source := string(data)
|
||||
@ -111,7 +110,7 @@ func process(file string) {
|
||||
// end up generating an `import _ "."`, the following replace removes it.
|
||||
source = strings.Replace(source, `_ "."`, "", -1)
|
||||
|
||||
err = ioutil.WriteFile(file, []byte(source), 0644)
|
||||
err = os.WriteFile(file, []byte(source), 0644)
|
||||
check(err)
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ package revocation_test
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
@ -39,7 +39,7 @@ func TestNewOptions(t *testing.T) {
|
||||
chainData, err := peertls.ChainBytes(fi.CA)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = ioutil.WriteFile(whitelistPath, chainData, 0644)
|
||||
err = os.WriteFile(whitelistPath, chainData, 0644)
|
||||
assert.NoError(t, err)
|
||||
|
||||
cases := []struct {
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"runtime/pprof"
|
||||
"strconv"
|
||||
"time"
|
||||
@ -269,7 +268,7 @@ func (client *Uplink) Download(ctx context.Context, satellite *Satellite, bucket
|
||||
}
|
||||
defer func() { err = errs.Combine(err, download.Close()) }()
|
||||
|
||||
data, err := ioutil.ReadAll(download)
|
||||
data, err := io.ReadAll(download)
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ func Process(ctx context.Context) (Server, error) {
|
||||
}
|
||||
|
||||
conf := strings.Join(arguments, "\n") + "\n"
|
||||
err = ioutil.WriteFile(confpath, []byte(conf), 0755)
|
||||
err = os.WriteFile(confpath, []byte(conf), 0755)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -130,7 +130,7 @@ func Process(ctx context.Context) (Server, error) {
|
||||
}
|
||||
}
|
||||
waitForReady <- scanner.Err()
|
||||
_, _ = io.Copy(ioutil.Discard, read)
|
||||
_, _ = io.Copy(io.Discard, read)
|
||||
}()
|
||||
|
||||
select {
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -49,7 +48,7 @@ func TestECClient(t *testing.T) {
|
||||
rs, err := eestream.NewRedundancyStrategy(es, 0, 0)
|
||||
require.NoError(t, err)
|
||||
|
||||
data, err := ioutil.ReadAll(io.LimitReader(testrand.Reader(), dataSize.Int64()))
|
||||
data, err := io.ReadAll(io.LimitReader(testrand.Reader(), dataSize.Int64()))
|
||||
require.NoError(t, err)
|
||||
|
||||
// Erasure encode some random data and upload the pieces
|
||||
@ -116,7 +115,7 @@ func testGet(ctx context.Context, t *testing.T, planet *testplanet.Planet, ec ec
|
||||
|
||||
r, err := rr.Range(ctx, 0, rr.Size())
|
||||
require.NoError(t, err)
|
||||
readData, err := ioutil.ReadAll(r)
|
||||
readData, err := io.ReadAll(r)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, data, readData)
|
||||
assert.NoError(t, r.Close())
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
@ -68,7 +68,7 @@ func (client *Client) All(ctx context.Context) (ver version.AllowedVersions, err
|
||||
return version.AllowedVersions{}, Error.Wrap(err)
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return version.AllowedVersions{}, Error.Wrap(err)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
@ -35,7 +35,7 @@ func (server *Server) addAPIKey(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
sendJSONError(w, "failed to read body",
|
||||
err.Error(), http.StatusInternalServerError)
|
||||
|
@ -6,7 +6,7 @@ package admin_test
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -50,7 +50,7 @@ func TestApiKeyAdd(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, response.Body.Close())
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@ -309,7 +309,7 @@ func (server *Server) putProjectLimit(w http.ResponseWriter, r *http.Request) {
|
||||
func (server *Server) addProject(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
sendJSONError(w, "failed to read body",
|
||||
err.Error(), http.StatusInternalServerError)
|
||||
@ -402,7 +402,7 @@ func (server *Server) renameProject(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
sendJSONError(w, "ailed to read body",
|
||||
err.Error(), http.StatusInternalServerError)
|
||||
|
@ -6,7 +6,7 @@ package admin_test
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@ -228,7 +228,7 @@ func TestProjectAdd(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, response.Body.Close())
|
||||
|
||||
@ -383,7 +383,7 @@ func TestProjectCheckUsage_withoutUsage(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"result\":\"no project usage exist\"}", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -454,7 +454,7 @@ func TestProjectCheckUsage_withUsage(t *testing.T) {
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"result\":\"no project usage exist\"}", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -477,7 +477,7 @@ func TestProjectCheckUsage_withUsage(t *testing.T) {
|
||||
require.Equal(t, http.StatusConflict, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
responseBody, err = ioutil.ReadAll(response.Body)
|
||||
responseBody, err = io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"error\":\"usage for current month exists\",\"detail\":\"\"}", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -555,7 +555,7 @@ func TestProjectCheckUsage_lastMonthUnappliedInvoice(t *testing.T) {
|
||||
require.Equal(t, http.StatusConflict, response.StatusCode)
|
||||
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"error\":\"unapplied project invoice record exist\",\"detail\":\"\"}", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -632,7 +632,7 @@ func TestProjectDelete_withUsageCurrentMonth(t *testing.T) {
|
||||
require.Equal(t, http.StatusConflict, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"error\":\"usage for current month exists\",\"detail\":\"\"}", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -654,7 +654,7 @@ func TestProjectDelete_withUsageCurrentMonth(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
|
||||
responseBody, err = ioutil.ReadAll(response.Body)
|
||||
responseBody, err = io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -731,7 +731,7 @@ func TestProjectDelete_withUsagePreviousMonthUncharged(t *testing.T) {
|
||||
|
||||
response, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"error\":\"usage for last month exist, but is not billed yet\",\"detail\":\"\"}", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -755,7 +755,7 @@ func TestProjectDelete_withUsagePreviousMonthUncharged(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
|
||||
responseBody, err = ioutil.ReadAll(response.Body)
|
||||
responseBody, err = io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -832,7 +832,7 @@ func TestProjectDelete_withUsagePreviousMonthCharged(t *testing.T) {
|
||||
|
||||
response, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"error\":\"usage for last month exist, but is not billed yet\",\"detail\":\"\"}", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -855,7 +855,7 @@ func TestProjectDelete_withUsagePreviousMonthCharged(t *testing.T) {
|
||||
// Project should fail to delete since the project record has not been used/billed yet.
|
||||
response, err = http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
responseBody, err = ioutil.ReadAll(response.Body)
|
||||
responseBody, err = io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "{\"error\":\"unapplied project invoice record exist\",\"detail\":\"\"}", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
@ -877,7 +877,7 @@ func TestProjectDelete_withUsagePreviousMonthCharged(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
|
||||
responseBody, err = ioutil.ReadAll(response.Body)
|
||||
responseBody, err = io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "", string(responseBody))
|
||||
require.NoError(t, response.Body.Close())
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@ -38,7 +38,7 @@ func (server *Server) addRESTKey(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
sendJSONError(w, "failed to read body",
|
||||
err.Error(), http.StatusInternalServerError)
|
||||
|
@ -6,7 +6,7 @@ package admin_test
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -54,7 +54,7 @@ func TestRESTKeys(t *testing.T) {
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, response.Body.Close())
|
||||
|
||||
@ -93,7 +93,7 @@ func TestRESTKeys(t *testing.T) {
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, response.Body.Close())
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
package admin_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@ -41,7 +41,7 @@ func TestBasic(t *testing.T) {
|
||||
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
|
||||
content, err := ioutil.ReadAll(response.Body)
|
||||
content, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, response.Body.Close())
|
||||
require.Empty(t, content)
|
||||
require.NoError(t, err)
|
||||
@ -57,7 +57,7 @@ func TestBasic(t *testing.T) {
|
||||
require.Equal(t, http.StatusForbidden, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
body, err := ioutil.ReadAll(response.Body)
|
||||
body, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, response.Body.Close())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, `{"error":"Forbidden","detail":""}`, string(body))
|
||||
@ -74,7 +74,7 @@ func TestBasic(t *testing.T) {
|
||||
require.Equal(t, http.StatusForbidden, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
body, err := ioutil.ReadAll(response.Body)
|
||||
body, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, response.Body.Close())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, `{"error":"Forbidden","detail":""}`, string(body))
|
||||
@ -92,7 +92,7 @@ func TestBasic(t *testing.T) {
|
||||
require.Equal(t, http.StatusNotFound, response.StatusCode)
|
||||
require.Equal(t, "text/plain; charset=utf-8", response.Header.Get("Content-Type"))
|
||||
|
||||
body, err := ioutil.ReadAll(response.Body)
|
||||
body, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, response.Body.Close())
|
||||
require.NoError(t, err)
|
||||
require.Contains(t, string(body), "not found")
|
||||
|
@ -5,7 +5,7 @@ package admin_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -26,7 +26,7 @@ func assertGet(ctx context.Context, t *testing.T, link string, expected string,
|
||||
response, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
|
||||
data, err := ioutil.ReadAll(response.Body)
|
||||
data, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, response.Body.Close())
|
||||
|
||||
@ -61,7 +61,7 @@ func assertReq(
|
||||
|
||||
require.Equal(t, expectedStatus, res.StatusCode, "response status code")
|
||||
|
||||
resBody, err := ioutil.ReadAll(res.Body)
|
||||
resBody, err := io.ReadAll(res.Body)
|
||||
if expectedBody != "" {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expectedBody, string(resBody), "response body")
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
func (server *Server) addUser(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
sendJSONError(w, "failed to read body",
|
||||
err.Error(), http.StatusInternalServerError)
|
||||
@ -220,7 +220,7 @@ func (server *Server) updateUser(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
sendJSONError(w, "failed to read body",
|
||||
err.Error(), http.StatusInternalServerError)
|
||||
|
@ -6,7 +6,7 @@ package admin_test
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -75,7 +75,7 @@ func TestUserAdd(t *testing.T) {
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, response.Body.Close())
|
||||
|
||||
@ -114,7 +114,7 @@ func TestUserAdd_sameEmail(t *testing.T) {
|
||||
require.Equal(t, http.StatusOK, response.StatusCode)
|
||||
require.Equal(t, "application/json", response.Header.Get("Content-Type"))
|
||||
|
||||
responseBody, err := ioutil.ReadAll(response.Body)
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, response.Body.Close())
|
||||
|
||||
|
@ -6,7 +6,6 @@ package satellite_test
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -44,9 +43,9 @@ func TestConfigLock(t *testing.T) {
|
||||
lockPath := filepath.Join("..", "scripts", "testdata", "satellite-config.yaml.lock")
|
||||
if *createLock { // update satellite-config.yaml.lock
|
||||
// copy using ReadFile/WriteFile, since os.Rename() won't work across drives
|
||||
input, err := ioutil.ReadFile(cleanedupConfig)
|
||||
input, err := os.ReadFile(cleanedupConfig)
|
||||
assert.NoErrorf(t, err, "Error reading file for move")
|
||||
err = ioutil.WriteFile(lockPath, input, 0644)
|
||||
err = os.WriteFile(lockPath, input, 0644)
|
||||
assert.NoErrorf(t, err, "Error writing file for move")
|
||||
} else { // compare to satellite-config.yaml.lock
|
||||
configs1 := readLines(t, lockPath)
|
||||
@ -62,7 +61,7 @@ func TestConfigLock(t *testing.T) {
|
||||
|
||||
// readLines takes a file path and returns the contents split by lines.
|
||||
func readLines(t *testing.T, filePath string) []string {
|
||||
file, err := ioutil.ReadFile(filePath)
|
||||
file, err := os.ReadFile(filePath)
|
||||
assert.NoErrorf(t, err, "Error opening %s", filePath)
|
||||
return strings.Split(strings.ReplaceAll(string(file), "\r\n", "\n"), "\n")
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@ -162,7 +162,7 @@ func TestForgotPasswordRecaptcha(t *testing.T) {
|
||||
result, err := http.DefaultClient.Do(req)
|
||||
require.NoError(t, err)
|
||||
|
||||
bodyBytes, err := ioutil.ReadAll(result.Body)
|
||||
bodyBytes, err := io.ReadAll(result.Body)
|
||||
require.NoError(t, err)
|
||||
fmt.Println(string(bodyBytes))
|
||||
|
||||
|
@ -6,7 +6,7 @@ package consoleauth
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
@ -41,12 +41,12 @@ func FromBase64URLString(token string) (Token, error) {
|
||||
payloadDecoder := base64.NewDecoder(base64.URLEncoding, bytes.NewReader([]byte(payload)))
|
||||
signatureDecoder := base64.NewDecoder(base64.URLEncoding, bytes.NewReader([]byte(signature)))
|
||||
|
||||
payloadBytes, err := ioutil.ReadAll(payloadDecoder)
|
||||
payloadBytes, err := io.ReadAll(payloadDecoder)
|
||||
if err != nil {
|
||||
return Token{}, errs.New("decoding token's signature failed: %s", err)
|
||||
}
|
||||
|
||||
signatureBytes, err := ioutil.ReadAll(signatureDecoder)
|
||||
signatureBytes, err := io.ReadAll(signatureDecoder)
|
||||
if err != nil {
|
||||
return Token{}, errs.New("decoding token's body failed: %s", err)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ package consoleapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
@ -49,7 +49,7 @@ func (a *Analytics) EventTriggered(w http.ResponseWriter, r *http.Request) {
|
||||
var err error
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
a.serveJSONError(w, http.StatusInternalServerError, err)
|
||||
}
|
||||
@ -78,7 +78,7 @@ func (a *Analytics) PageEventTriggered(w http.ResponseWriter, r *http.Request) {
|
||||
var err error
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
a.serveJSONError(w, http.StatusInternalServerError, err)
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@ -304,7 +303,7 @@ func TestDeleteAccount(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
body, err := ioutil.ReadAll(result.Body)
|
||||
body, err := io.ReadAll(result.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
return result.StatusCode, body
|
||||
|
@ -5,7 +5,7 @@ package consoleapi_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
@ -86,7 +86,7 @@ func Test_AllBucketNames(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, result.StatusCode)
|
||||
|
||||
body, err := ioutil.ReadAll(result.Body)
|
||||
body, err := io.ReadAll(result.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
var output []string
|
||||
|
@ -6,7 +6,6 @@ package consoleapi
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
@ -133,7 +132,7 @@ func (p *Payments) AddCreditCard(w http.ResponseWriter, r *http.Request) {
|
||||
var err error
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
bodyBytes, err := ioutil.ReadAll(r.Body)
|
||||
bodyBytes, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
p.serveJSONError(w, http.StatusBadRequest, err)
|
||||
return
|
||||
@ -189,7 +188,7 @@ func (p *Payments) MakeCreditCardDefault(w http.ResponseWriter, r *http.Request)
|
||||
var err error
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
cardID, err := ioutil.ReadAll(r.Body)
|
||||
cardID, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
p.serveJSONError(w, http.StatusBadRequest, err)
|
||||
return
|
||||
@ -332,7 +331,7 @@ func (p *Payments) ApplyCouponCode(w http.ResponseWriter, r *http.Request) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
// limit the size of the body to prevent excessive memory usage
|
||||
bodyBytes, err := ioutil.ReadAll(io.LimitReader(r.Body, 1*1024*1024))
|
||||
bodyBytes, err := io.ReadAll(io.LimitReader(r.Body, 1*1024*1024))
|
||||
if err != nil {
|
||||
p.serveJSONError(w, http.StatusInternalServerError, err)
|
||||
return
|
||||
|
@ -6,7 +6,7 @@ package consoleapi_test
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"testing"
|
||||
@ -99,7 +99,7 @@ func Test_TotalUsageLimits(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, result.StatusCode)
|
||||
|
||||
body, err := ioutil.ReadAll(result.Body)
|
||||
body, err := io.ReadAll(result.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
var output console.ProjectUsageLimits
|
||||
@ -213,7 +213,7 @@ func Test_DailyUsage(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, result.StatusCode)
|
||||
|
||||
body, err := ioutil.ReadAll(result.Body)
|
||||
body, err := io.ReadAll(result.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
var output accounting.ProjectDailyUsage
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
@ -851,7 +850,7 @@ func (test *test) do(req *http.Request) (_ Response, body string) {
|
||||
resp, err := test.client.Do(req)
|
||||
require.NoError(test.t, err)
|
||||
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
require.NoError(test.t, err)
|
||||
require.NoError(test.t, resp.Body.Close())
|
||||
|
||||
|
@ -6,7 +6,7 @@ package consoleweb
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"mime"
|
||||
"net/http"
|
||||
"regexp"
|
||||
@ -58,7 +58,7 @@ func queryPOST(w http.ResponseWriter, req *http.Request) (query graphqlJSON, err
|
||||
limitedReader := http.MaxBytesReader(w, req.Body, ContentLengthLimit.Int64())
|
||||
switch typ := req.Header.Get(contentType); typ {
|
||||
case applicationGraphql:
|
||||
body, err := ioutil.ReadAll(limitedReader)
|
||||
body, err := io.ReadAll(limitedReader)
|
||||
query.Query = string(body)
|
||||
return query, errs.Combine(err, limitedReader.Close())
|
||||
case applicationJSON:
|
||||
|
@ -6,7 +6,7 @@ package bloomfilter_test
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"sort"
|
||||
"strconv"
|
||||
"testing"
|
||||
@ -91,7 +91,7 @@ func TestGarbageCollectionBloomFilters(t *testing.T) {
|
||||
bfReader, err := file.Open()
|
||||
require.NoError(t, err)
|
||||
|
||||
bloomfilter, err := ioutil.ReadAll(bfReader)
|
||||
bloomfilter, err := io.ReadAll(bfReader)
|
||||
require.NoError(t, err)
|
||||
|
||||
var pbRetainInfo internalpb.RetainInfo
|
||||
|
@ -9,7 +9,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -104,7 +103,7 @@ func main() {
|
||||
}
|
||||
|
||||
func process(file string) {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
check(err)
|
||||
|
||||
source := string(data)
|
||||
@ -113,7 +112,7 @@ func process(file string) {
|
||||
// end up generating an `import _ "."`, the following replace removes it.
|
||||
source = strings.Replace(source, `_ "."`, "", -1)
|
||||
|
||||
err = ioutil.WriteFile(file, []byte(source), 0644)
|
||||
err = os.WriteFile(file, []byte(source), 0644)
|
||||
check(err)
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ package metainfo_test
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
@ -196,7 +196,7 @@ func TestQueryAttribution(t *testing.T) {
|
||||
download, err := project.DownloadObject(ctx, bucketName, objectKey, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ioutil.ReadAll(download)
|
||||
_, err = io.ReadAll(download)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = download.Close()
|
||||
|
@ -4,7 +4,7 @@
|
||||
package metainfo_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/spacemonkeygo/monkit/v3"
|
||||
@ -58,7 +58,7 @@ func TestUserAgentTransferStats(t *testing.T) {
|
||||
download, err := project.DownloadObject(ctx, "testbucket", name, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ioutil.ReadAll(download)
|
||||
_, err = io.ReadAll(download)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, download.Close())
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -73,7 +72,7 @@ func send(t *testing.T, body io.Reader, response interface{}, status int, parts
|
||||
require.Equal(t, status, resp.StatusCode)
|
||||
|
||||
if response != nil {
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = json.Unmarshal(data, response)
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"errors"
|
||||
"hash"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"sort"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -288,12 +287,12 @@ func (ec *ECRepairer) downloadAndVerifyPiece(ctx context.Context, limit *pb.Addr
|
||||
var downloadedPieceSize int64
|
||||
|
||||
if ec.inmemory {
|
||||
pieceBytes, err := ioutil.ReadAll(downloadReader)
|
||||
pieceBytes, err := io.ReadAll(downloadReader)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
downloadedPieceSize = int64(len(pieceBytes))
|
||||
pieceReadCloser = ioutil.NopCloser(bytes.NewReader(pieceBytes))
|
||||
pieceReadCloser = io.NopCloser(bytes.NewReader(pieceBytes))
|
||||
} else {
|
||||
tempfile, err := tmpfile.New(tmpDir, "satellite-repair-*")
|
||||
if err != nil {
|
||||
@ -388,7 +387,7 @@ func (ec *ECRepairer) Repair(ctx context.Context, limits []*pb.AddressedOrderLim
|
||||
return nil, nil, Error.New("duplicated nodes are not allowed")
|
||||
}
|
||||
|
||||
readers, err := eestream.EncodeReader2(ctx, ioutil.NopCloser(data), rs)
|
||||
readers, err := eestream.EncodeReader2(ctx, io.NopCloser(data), rs)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@ -508,7 +507,7 @@ func (ec *ECRepairer) putPiece(ctx, parent context.Context, limit *pb.AddressedO
|
||||
defer func() { err = errs.Combine(err, data.Close()) }()
|
||||
|
||||
if limit == nil {
|
||||
_, _ = io.Copy(ioutil.Discard, data)
|
||||
_, _ = io.Copy(io.Discard, data)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/format"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@ -37,7 +36,7 @@ func main() {
|
||||
panic("invalid version " + lastScriptFile)
|
||||
}
|
||||
|
||||
scriptData, err := ioutil.ReadFile(lastScriptFile)
|
||||
scriptData, err := os.ReadFile(lastScriptFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -54,7 +53,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile("migratez.go", formatted, 0755)
|
||||
err = os.WriteFile("migratez.go", formatted, 0755)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
@ -74,7 +74,7 @@ func loadSnapshots(ctx context.Context, connstr, dbxscript string, maxSnapshots
|
||||
return errs.New("invalid testdata file %q: %v", match, err)
|
||||
}
|
||||
|
||||
scriptData, err := ioutil.ReadFile(match)
|
||||
scriptData, err := os.ReadFile(match)
|
||||
if err != nil {
|
||||
return errs.New("could not read testdata file for version %d: %v", version, err)
|
||||
}
|
||||
|
@ -17,7 +17,8 @@ import (
|
||||
// to a compatible plaintext sql backup that only has SQL statements compatible with CockroachDB.
|
||||
//
|
||||
// Usage:
|
||||
// cat postgres_backup.sql | go run pg-to-crdb.go > cockroach_backup.sql
|
||||
//
|
||||
// cat postgres_backup.sql | go run pg-to-crdb.go > cockroach_backup.sql
|
||||
func main() {
|
||||
print := false
|
||||
printOnce := false
|
||||
|
@ -115,7 +115,7 @@ func (dir *Dir) CreateVerificationFile(ctx context.Context, id storj.NodeID) err
|
||||
// Verify verifies that the storage directory is correct by checking for the existence and validity
|
||||
// of the verification file.
|
||||
func (dir *Dir) Verify(ctx context.Context, id storj.NodeID) error {
|
||||
content, err := ioutil.ReadFile(filepath.Join(dir.path, verificationFileName))
|
||||
content, err := os.ReadFile(filepath.Join(dir.path, verificationFileName))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -210,7 +209,7 @@ func TestDeleteWhileReading(t *testing.T) {
|
||||
require.Error(t, err, "opening deleted file should fail")
|
||||
|
||||
// read all content
|
||||
result, err := ioutil.ReadAll(reader)
|
||||
result, err := io.ReadAll(reader)
|
||||
require.NoError(t, err, "read all content")
|
||||
|
||||
// finally close reader
|
||||
@ -819,7 +818,7 @@ func requireFileMatches(ctx context.Context, t *testing.T, store storage.Blobs,
|
||||
r, err := store.OpenWithStorageFormat(ctx, ref, formatVer)
|
||||
require.NoError(t, err)
|
||||
|
||||
buf, err := ioutil.ReadAll(r)
|
||||
buf, err := io.ReadAll(r)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, buf, data)
|
||||
@ -863,7 +862,7 @@ func TestBlobMemoryBuffer(t *testing.T) {
|
||||
reader, err := store.Open(ctx, ref)
|
||||
require.NoError(t, err)
|
||||
|
||||
buf, err := ioutil.ReadAll(reader)
|
||||
buf, err := io.ReadAll(reader)
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := range buf {
|
||||
|
@ -6,7 +6,7 @@ package consoleapi_test
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@ -70,7 +70,7 @@ func TestNotificationsApi(t *testing.T) {
|
||||
err = res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "{\"page\":{\"notifications\":"+string(expected)+",\"offset\":0,\"limit\":3,\"currentPage\":1,\"pageCount\":1},\"unreadCount\":2,\"totalCount\":2}"+"\n", string(body))
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
@ -84,7 +83,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected)+"\n", string(body))
|
||||
@ -100,7 +99,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res2.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body2, err := ioutil.ReadAll(res2.Body)
|
||||
body2, err := io.ReadAll(res2.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
expected = []byte("null\n")
|
||||
@ -162,7 +161,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected)+"\n", string(body))
|
||||
@ -178,7 +177,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res2.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body2, err := ioutil.ReadAll(res2.Body)
|
||||
body2, err := io.ReadAll(res2.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "null\n", string(body2))
|
||||
@ -228,7 +227,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected)+"\n", string(body))
|
||||
@ -246,7 +245,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res2.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body2, err := ioutil.ReadAll(res2.Body)
|
||||
body2, err := io.ReadAll(res2.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected)+"\n", string(body2))
|
||||
@ -264,7 +263,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res3.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body3, err := ioutil.ReadAll(res3.Body)
|
||||
body3, err := io.ReadAll(res3.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected)+"\n", string(body3))
|
||||
@ -293,7 +292,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
body5, err := ioutil.ReadAll(res5.Body)
|
||||
body5, err := io.ReadAll(res5.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "{\"error\":\"consoleapi payouts: wrong period format: period has wrong format\"}\n", string(body5))
|
||||
@ -314,7 +313,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected)+"\n", string(body))
|
||||
@ -332,7 +331,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res2.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body2, err := ioutil.ReadAll(res2.Body)
|
||||
body2, err := io.ReadAll(res2.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected)+"\n", string(body2))
|
||||
@ -349,7 +348,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
body5, err := ioutil.ReadAll(res5.Body)
|
||||
body5, err := io.ReadAll(res5.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, "{\"error\":\"consoleapi payouts: wrong period format: period has wrong format\"}\n", string(body5))
|
||||
@ -394,7 +393,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, string(expected)+"\n", string(body))
|
||||
})
|
||||
@ -416,7 +415,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected)+"\n", string(body))
|
||||
@ -438,7 +437,7 @@ func TestHeldAmountApi(t *testing.T) {
|
||||
err = res2.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body2, err := ioutil.ReadAll(res2.Body)
|
||||
body2, err := io.ReadAll(res2.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, string(expected2)+"\n", string(body2))
|
||||
|
@ -6,7 +6,7 @@ package consoleapi_test
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
@ -119,7 +119,7 @@ func TestStorageNodeApi(t *testing.T) {
|
||||
err = res.Body.Close()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, body)
|
||||
|
||||
|
@ -9,7 +9,6 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -104,7 +103,7 @@ func main() {
|
||||
}
|
||||
|
||||
func process(file string) {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
check(err)
|
||||
|
||||
source := string(data)
|
||||
@ -113,7 +112,7 @@ func process(file string) {
|
||||
// end up generating an `import _ "."`, the following replace removes it.
|
||||
source = strings.Replace(source, `_ "."`, "", -1)
|
||||
|
||||
err = ioutil.WriteFile(file, []byte(source), 0644)
|
||||
err = os.WriteFile(file, []byte(source), 0644)
|
||||
check(err)
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
@ -493,7 +492,7 @@ func verifyPieceData(ctx context.Context, t testing.TB, store *pieces.Store, sat
|
||||
require.NoError(t, signing.VerifyUplinkPieceHashSignature(ctx, publicKey, pieceHash))
|
||||
|
||||
// Require piece data to match expected
|
||||
buf, err := ioutil.ReadAll(r)
|
||||
buf, err := io.ReadAll(r)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, r.Close())
|
||||
assert.True(t, bytes.Equal(buf, expected))
|
||||
@ -789,7 +788,7 @@ func TestOverwriteV0WithV1(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, int64(len(v0Data)), reader.Size())
|
||||
assert.Equal(t, filestore.FormatV0, reader.StorageFormatVersion())
|
||||
gotData, err := ioutil.ReadAll(reader)
|
||||
gotData, err := io.ReadAll(reader)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, v0Data, gotData)
|
||||
require.NoError(t, reader.Close())
|
||||
@ -821,7 +820,7 @@ func TestOverwriteV0WithV1(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, int64(len(v1Data)), reader.Size())
|
||||
assert.Equal(t, filestore.FormatV1, reader.StorageFormatVersion())
|
||||
gotData, err := ioutil.ReadAll(reader)
|
||||
gotData, err := io.ReadAll(reader)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, v1Data, gotData)
|
||||
require.NoError(t, reader.Close())
|
||||
|
@ -6,7 +6,7 @@ package piecestore_test
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -256,7 +256,7 @@ func TestOrderLimitGetValidation(t *testing.T) {
|
||||
downloader, err := client.Download(ctx, orderLimit, piecePrivateKey, 0, tt.limit)
|
||||
require.NoError(t, err)
|
||||
|
||||
buffer, readErr := ioutil.ReadAll(downloader)
|
||||
buffer, readErr := io.ReadAll(downloader)
|
||||
closeErr := downloader.Close()
|
||||
err = errs.Combine(readErr, closeErr)
|
||||
if tt.err != "" {
|
||||
|
@ -6,7 +6,6 @@ package trust
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -86,7 +85,7 @@ func NewCacheData() *CacheData {
|
||||
|
||||
// LoadCacheData loads the cache data from the given path.
|
||||
func LoadCacheData(path string) (*CacheData, error) {
|
||||
dataBytes, err := ioutil.ReadFile(path)
|
||||
dataBytes, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, Error.Wrap(err)
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ package trust_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@ -46,7 +45,7 @@ func TestCacheLoadFailure(t *testing.T) {
|
||||
assert.Error(t, err)
|
||||
|
||||
// Load malformed JSON
|
||||
require.NoError(t, ioutil.WriteFile(cachePath, []byte("BAD"), 0644))
|
||||
require.NoError(t, os.WriteFile(cachePath, []byte("BAD"), 0644))
|
||||
_, err = trust.LoadCache(cachePath)
|
||||
assert.EqualError(t, err, "trust: malformed cache: invalid character 'B' looking for beginning of value")
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ package trust_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -40,11 +40,11 @@ func TestFileSourceFetchEntries(t *testing.T) {
|
||||
%s
|
||||
`, url1.String(), url2.String())
|
||||
goodPath := ctx.File("good.txt")
|
||||
require.NoError(t, ioutil.WriteFile(goodPath, []byte(goodData), 0644))
|
||||
require.NoError(t, os.WriteFile(goodPath, []byte(goodData), 0644))
|
||||
|
||||
badData := `BAD`
|
||||
badPath := ctx.File("bad.txt")
|
||||
require.NoError(t, ioutil.WriteFile(badPath, []byte(badData), 0644))
|
||||
require.NoError(t, os.WriteFile(badPath, []byte(badData), 0644))
|
||||
|
||||
missingPath := ctx.File("missing.txt")
|
||||
|
||||
|
@ -6,7 +6,7 @@ package versioncontrol_test
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"reflect"
|
||||
@ -205,7 +205,7 @@ func TestPeerEndpoint(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, b)
|
||||
require.NoError(t, resp.Body.Close())
|
||||
|
Loading…
Reference in New Issue
Block a user