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