1
0
Fork 0
master
Philip O'Toole 2 years ago
parent ff31decd79
commit 27839b53f7

@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"log"
"net"
"net/http"
@ -148,7 +148,7 @@ func (j *Joiner) join(joinAddr, id, addr string, voter bool) (string, error) {
}
defer resp.Body.Close()
b, err = ioutil.ReadAll(resp.Body)
b, err = io.ReadAll(resp.Body)
if err != nil {
return "", err
}

@ -4,7 +4,7 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
@ -28,7 +28,7 @@ func Test_SingleJoinOK(t *testing.T) {
t.Fatalf("incorrect Content-Type set")
}
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
@ -74,7 +74,7 @@ func Test_SingleJoinHTTPSOK(t *testing.T) {
t.Fatalf("incorrect Content-Type set")
}
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
@ -130,7 +130,7 @@ func Test_SingleJoinOKBasicAuth(t *testing.T) {
t.Fatalf("bad Basic Auth credentials received (%s, %s", username, password)
}
b, err := ioutil.ReadAll(r.Body)
b, err := io.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return

@ -263,9 +263,7 @@ func (s *Service) handleConn(conn net.Conn) {
resp.Error = err.Error()
} else {
resp.Results = make([]*command.ExecuteResult, len(res))
for i := range res {
resp.Results[i] = res[i]
}
copy(resp.Results, res)
}
}
@ -291,9 +289,7 @@ func (s *Service) handleConn(conn net.Conn) {
resp.Error = err.Error()
} else {
resp.Rows = make([]*command.QueryRows, len(res))
for i := range res {
resp.Rows[i] = res[i]
}
copy(resp.Rows, res)
}
}

@ -296,7 +296,7 @@ func Test_ServiceBackup(t *testing.T) {
t.Fatalf("failed to backup database: %s", err.Error())
}
if bytes.Compare(buf.Bytes(), testData) != 0 {
if !bytes.Equal(buf.Bytes(), testData) {
t.Fatalf("backup data is not as expected, exp: %s, got: %s", testData, buf.Bytes())
}
@ -332,7 +332,7 @@ func Test_ServiceLoad(t *testing.T) {
testData := []byte("this is SQLite data")
db.loadFn = func(lr *command.LoadRequest) error {
called = true
if bytes.Compare(lr.Data, testData) != 0 {
if !bytes.Equal(lr.Data, testData) {
t.Fatalf("load data is not as expected, exp: %s, got: %s", testData, lr.Data)
}
return nil
@ -458,13 +458,6 @@ func queryRequestFromStrings(s []string) *command.QueryRequest {
}
}
func backupRequestSQL(leader bool) *command.BackupRequest {
return &command.BackupRequest{
Format: command.BackupRequest_BACKUP_REQUEST_FORMAT_SQL,
Leader: leader,
}
}
func backupRequestBinary(leader bool) *command.BackupRequest {
return &command.BackupRequest{
Format: command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY,

@ -29,7 +29,7 @@ func CreateConfig(certFile, keyFile, caCertFile string, noverify, tls1011 bool)
// load the CA certificate file, if provided, as the root CA and client CA
if caCertFile != "" {
asn1Data, err := ioutil.ReadFile(caCertFile)
asn1Data, err := os.ReadFile(caCertFile)
if err != nil {
return nil, err
}
@ -69,7 +69,7 @@ func CreateClientConfig(certFile, keyFile, caCertFile string, noverify, tls1011
}
}
if caCertFile != "" {
asn1Data, err := ioutil.ReadFile(caCertFile)
asn1Data, err := os.ReadFile(caCertFile)
if err != nil {
return nil, err
}
@ -99,7 +99,7 @@ func CreateServerConfig(certFile, keyFile, caCertFile string, noverify, tls1011
return nil, err
}
if caCertFile != "" {
asn1Data, err := ioutil.ReadFile(caCertFile)
asn1Data, err := os.ReadFile(caCertFile)
if err != nil {
return nil, err
}

@ -121,7 +121,7 @@ func (e *echoServer) Start(t *testing.T) {
// Successful testing can cause this.
return
}
t.Fatalf("failed to accept a connection: %s", err.Error())
t.Logf("failed to accept a connection: %s", err.Error())
}
go func(c net.Conn) {
buf := make([]byte, 1)

@ -4,7 +4,6 @@ import (
"bytes"
"crypto/tls"
"io"
"io/ioutil"
"log"
"net"
"os"
@ -41,7 +40,7 @@ func TestMux(t *testing.T) {
}
mux.Timeout = 200 * time.Millisecond
if !testing.Verbose() {
mux.Logger = log.New(ioutil.Discard, "", 0)
mux.Logger = log.New(io.Discard, "", 0)
}
for i := uint8(0); i < n; i++ {
ln := mux.Listen(i)
@ -140,7 +139,7 @@ func TestMux_Advertise(t *testing.T) {
}
mux.Timeout = 200 * time.Millisecond
if !testing.Verbose() {
mux.Logger = log.New(ioutil.Discard, "", 0)
mux.Logger = log.New(io.Discard, "", 0)
}
layer := mux.Listen(1)

Loading…
Cancel
Save