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

@ -6,7 +6,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"log" "log"
"net" "net"
"net/http" "net/http"
@ -148,7 +148,7 @@ func (j *Joiner) join(joinAddr, id, addr string, voter bool) (string, error) {
} }
defer resp.Body.Close() defer 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
} }

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

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

@ -296,7 +296,7 @@ func Test_ServiceBackup(t *testing.T) {
t.Fatalf("failed to backup database: %s", err.Error()) 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()) 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") testData := []byte("this is SQLite data")
db.loadFn = func(lr *command.LoadRequest) error { db.loadFn = func(lr *command.LoadRequest) error {
called = true 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) t.Fatalf("load data is not as expected, exp: %s, got: %s", testData, lr.Data)
} }
return nil 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 { func backupRequestBinary(leader bool) *command.BackupRequest {
return &command.BackupRequest{ return &command.BackupRequest{
Format: command.BackupRequest_BACKUP_REQUEST_FORMAT_BINARY, 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 // load the CA certificate file, if provided, as the root CA and client CA
if caCertFile != "" { if caCertFile != "" {
asn1Data, err := ioutil.ReadFile(caCertFile) asn1Data, err := os.ReadFile(caCertFile)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -69,7 +69,7 @@ func CreateClientConfig(certFile, keyFile, caCertFile string, noverify, tls1011
} }
} }
if caCertFile != "" { if caCertFile != "" {
asn1Data, err := ioutil.ReadFile(caCertFile) asn1Data, err := os.ReadFile(caCertFile)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -99,7 +99,7 @@ func CreateServerConfig(certFile, keyFile, caCertFile string, noverify, tls1011
return nil, err return nil, err
} }
if caCertFile != "" { if caCertFile != "" {
asn1Data, err := ioutil.ReadFile(caCertFile) asn1Data, err := os.ReadFile(caCertFile)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -121,7 +121,7 @@ func (e *echoServer) Start(t *testing.T) {
// Successful testing can cause this. // Successful testing can cause this.
return 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) { go func(c net.Conn) {
buf := make([]byte, 1) buf := make([]byte, 1)

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

Loading…
Cancel
Save