diff --git a/agents/httpagent_it_test.go b/agents/httpagent_it_test.go index 6aa0e5daf..ee174fe1d 100644 --- a/agents/httpagent_it_test.go +++ b/agents/httpagent_it_test.go @@ -25,9 +25,10 @@ import ( "crypto/tls" "crypto/x509" "fmt" - "io/ioutil" + "io" "net/http" "net/rpc" + "os" "path" "reflect" "testing" @@ -129,7 +130,7 @@ func testHAitHttp(t *testing.T) { t.Error(err) } // Load CA cert - caCert, err := ioutil.ReadFile(haCfg.TLSCfg().CaCertificate) + caCert, err := os.ReadFile(haCfg.TLSCfg().CaCertificate) if err != nil { t.Error(err) } @@ -206,7 +207,7 @@ func testHAitAuthDryRun(t *testing.T) { 234/Val1 1200 `) - if body, err := ioutil.ReadAll(rply.Body); err != nil { + if body, err := io.ReadAll(rply.Body); err != nil { t.Error(err) } else if !reflect.DeepEqual(eXml, body) { t.Errorf("expecting: <%s>, received: <%s>", string(eXml), string(body)) @@ -255,7 +256,7 @@ func testHAitAuth1001(t *testing.T) { 1 %v `, maxDuration)) - if body, err := ioutil.ReadAll(rply.Body); err != nil { + if body, err := io.ReadAll(rply.Body); err != nil { t.Error(err) } else if !reflect.DeepEqual(eXml, body) { t.Errorf("expecting: %s, received: %s", string(eXml), string(body)) @@ -282,7 +283,7 @@ func testHAitCDRmtcall(t *testing.T) { 123456 1 `) - if body, err := ioutil.ReadAll(rply.Body); err != nil { + if body, err := io.ReadAll(rply.Body); err != nil { t.Error(err) } else if !reflect.DeepEqual(eXml, body) { t.Errorf("expecting: <%s>, received: <%s>", string(eXml), string(body)) @@ -362,7 +363,7 @@ ComposedVar=TestComposed Item1.1=Val2 Item1.1=Val1 `) - if body, err := ioutil.ReadAll(rply.Body); err != nil { + if body, err := io.ReadAll(rply.Body); err != nil { t.Error(err) } else if !reflect.DeepEqual(len(response), len(body)) { t.Errorf("expecting: \n<%s>\n, received: \n<%s>\n", string(response), string(body)) diff --git a/agents/libhttpagent.go b/agents/libhttpagent.go index 18af2e458..fc06412ea 100644 --- a/agents/libhttpagent.go +++ b/agents/libhttpagent.go @@ -21,7 +21,7 @@ package agents import ( "encoding/xml" "fmt" - "io/ioutil" + "io" "net" "net/http" "net/http/httputil" @@ -100,7 +100,7 @@ func (hU *httpUrlDP) RemoteHost() net.Addr { } func newHTTPXmlDP(req *http.Request) (dP utils.DataProvider, err error) { - byteData, err := ioutil.ReadAll(req.Body) + byteData, err := io.ReadAll(req.Body) if err != nil { return nil, err } diff --git a/apier/v1/apier.go b/apier/v1/apier.go index e1ee328ea..a0bdcfdd3 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -22,7 +22,6 @@ import ( "encoding/csv" "errors" "fmt" - "io/ioutil" "os" "path" "strconv" @@ -1385,7 +1384,7 @@ func (apierSv1 *APIerSv1) ReplayFailedPosts(args *ArgsReplyFailedPosts, reply *s if args.FailedRequestsOutDir != nil && *args.FailedRequestsOutDir != "" { failedReqsOutDir = *args.FailedRequestsOutDir } - filesInDir, _ := ioutil.ReadDir(failedReqsInDir) + filesInDir, _ := os.ReadDir(failedReqsInDir) if len(filesInDir) == 0 { return utils.ErrNotFound } diff --git a/apier/v1/caps_it_test.go b/apier/v1/caps_it_test.go index fbf011551..75a64beec 100644 --- a/apier/v1/caps_it_test.go +++ b/apier/v1/caps_it_test.go @@ -23,7 +23,7 @@ package v1 import ( "bytes" "fmt" - "io/ioutil" + "io" "net/http" "net/rpc" "path" @@ -175,7 +175,7 @@ func testCapsOnHTTPBusy(t *testing.T) { t.Error(err) return } - contents, err := ioutil.ReadAll(resp.Body) + contents, err := io.ReadAll(resp.Body) if err != nil { wg.Done() t.Error(err) diff --git a/apier/v1/ees_it_test.go b/apier/v1/ees_it_test.go index 49ab0a90a..93b0a739e 100644 --- a/apier/v1/ees_it_test.go +++ b/apier/v1/ees_it_test.go @@ -18,7 +18,6 @@ along with this program. If not, see package v1 import ( - "io/ioutil" "net/rpc" "os" "path" @@ -236,7 +235,7 @@ func testEEsVerifyExports(t *testing.T) { "Cdr2,*raw,*voice,OriginCDR2,*none,cgrates.org,call,1001,1001,+4986517174963,2018-10-04T15:03:10Z,2018-10-04T15:03:10Z,5,1.01\n" + "Cdr3,*raw,*voice,OriginCDR3,*none,cgrates.org,call,1001,1001,+4986517174963,2018-10-04T15:03:10Z,2018-10-04T15:03:10Z,30,1.01\n" + "Cdr4,*raw,*voice,OriginCDR4,*none,cgrates.org,call,1001,1001,+4986517174963,2018-10-04T15:03:10Z,2018-10-04T15:03:10Z,0,1.01\n" - if outContent1, err := ioutil.ReadFile(files[0]); err != nil { + if outContent1, err := os.ReadFile(files[0]); err != nil { t.Error(err) } else if len(eCnt) != len(string(outContent1)) { t.Errorf("Expecting: \n<%+v>, \nreceived: \n<%+v>", len(eCnt), len(string(outContent1))) @@ -302,7 +301,7 @@ func testEEsVerifyExportsMultipleExporters(t *testing.T) { "Cdr2,*raw,*voice,OriginCDR2,*none,cgrates.org,call,1001,1001,+4986517174963,2018-10-04T15:03:10Z,2018-10-04T15:03:10Z,5,1.01\n" + "Cdr3,*raw,*voice,OriginCDR3,*none,cgrates.org,call,1001,1001,+4986517174963,2018-10-04T15:03:10Z,2018-10-04T15:03:10Z,30,1.01\n" + "Cdr4,*raw,*voice,OriginCDR4,*none,cgrates.org,call,1001,1001,+4986517174963,2018-10-04T15:03:10Z,2018-10-04T15:03:10Z,0,1.01\n" - if outContent1, err := ioutil.ReadFile(files[0]); err != nil { + if outContent1, err := os.ReadFile(files[0]); err != nil { t.Error(err) } else if len(eCnt) != len(string(outContent1)) { t.Errorf("Expecting: \n<%q>, \nreceived: \n<%q>", eCnt, string(outContent1)) diff --git a/apier/v1/preload_it_test.go b/apier/v1/preload_it_test.go index 2a2ee2dc1..fbc917e74 100644 --- a/apier/v1/preload_it_test.go +++ b/apier/v1/preload_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package v1 import ( - "io/ioutil" "net/rpc" "net/rpc/jsonrpc" "os" @@ -73,7 +72,7 @@ func testCreateDirs(t *testing.T) { t.Fatal("Error creating folder: ", dir, err) } } - if err := ioutil.WriteFile(path.Join("/tmp/In", utils.AttributesCsv), []byte(engine.AttributesCSVContent), 0644); err != nil { + if err := os.WriteFile(path.Join("/tmp/In", utils.AttributesCsv), []byte(engine.AttributesCSVContent), 0644); err != nil { t.Fatal(err.Error()) } } diff --git a/apier/v1/tp.go b/apier/v1/tp.go index 61bfeb057..160ce9a49 100644 --- a/apier/v1/tp.go +++ b/apier/v1/tp.go @@ -22,7 +22,6 @@ package v1 import ( "encoding/base64" - "io/ioutil" "os" "path/filepath" @@ -51,13 +50,13 @@ type AttrImportTPZipFile struct { } func (apierSv1 *APIerSv1) ImportTPZipFile(attrs *AttrImportTPZipFile, reply *string) error { - tmpDir, err := ioutil.TempDir("/tmp", "cgr_") + tmpDir, err := os.MkdirTemp("/tmp", "cgr_") if err != nil { *reply = "ERROR: creating temp directory!" return err } zipFile := filepath.Join(tmpDir, "/file.zip") - if err = ioutil.WriteFile(zipFile, attrs.File, os.ModePerm); err != nil { + if err = os.WriteFile(zipFile, attrs.File, os.ModePerm); err != nil { *reply = "ERROR: writing zip file!" return err } diff --git a/cmd/cgr-tester/filereader.go b/cmd/cgr-tester/filereader.go index 1e01a9c8c..36db75718 100644 --- a/cmd/cgr-tester/filereader.go +++ b/cmd/cgr-tester/filereader.go @@ -22,7 +22,6 @@ import ( "bufio" "bytes" "io" - "io/ioutil" "log" "math/rand" "net" @@ -63,14 +62,14 @@ func (frt *FileReaderTester) connSendReq(req []byte) (err error) { if _, err = frt.conn.Write(req); err != nil { return } - ioutil.ReadAll(frt.conn) + io.ReadAll(frt.conn) return } // Test reads from rdr, split the content based on lineSep and sends individual lines to remote func (frt *FileReaderTester) Test() (err error) { var fContent []byte - if fContent, err = ioutil.ReadAll(frt.rdr); err != nil { + if fContent, err = io.ReadAll(frt.rdr); err != nil { return } reqs := bytes.Split(fContent, frt.reqSep) diff --git a/cmd/cgr-tester/parallel/parallel.go b/cmd/cgr-tester/parallel/parallel.go index b5c08416d..feb059992 100644 --- a/cmd/cgr-tester/parallel/parallel.go +++ b/cmd/cgr-tester/parallel/parallel.go @@ -21,7 +21,7 @@ package main import ( "bytes" "fmt" - "io/ioutil" + "io" "log" "net/http" "sync" @@ -39,7 +39,7 @@ func main() { if err != nil { log.Print("Post error: ", err) } - contents, err := ioutil.ReadAll(resp.Body) + contents, err := io.ReadAll(resp.Body) if err != nil { log.Print("Body error: ", err) } @@ -53,7 +53,7 @@ func main() { if err != nil { log.Print("Post error: ", err) } - contents, err := ioutil.ReadAll(resp.Body) + contents, err := io.ReadAll(resp.Body) if err != nil { log.Print("Body error: ", err) } diff --git a/config/config_it_test.go b/config/config_it_test.go index beb0958bd..66c273751 100644 --- a/config/config_it_test.go +++ b/config/config_it_test.go @@ -21,7 +21,7 @@ package config import ( "fmt" - "io/ioutil" + "io" "net" "net/http" "net/http/httptest" @@ -1024,7 +1024,7 @@ func testHttpHandlerConfigSForNotExistFile(t *testing.T) { HandlerConfigS(w, req) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if resp.Status != "404 Not Found" { t.Errorf("Expected %+v , received: %+v ", "200 OK", resp.Status) @@ -1041,7 +1041,7 @@ func testHandleConfigSFolderError(t *testing.T) { handleConfigSFolder(flPath, w) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) expected := "path:\"/usr/share/cgrates/conf/samples/NotExists/cgrates.json\" is not reachable" if expected != string(body) { @@ -1056,7 +1056,7 @@ func testHttpHandlerConfigSInvalidPath(t *testing.T) { HandlerConfigS(w, req) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if resp.Status != "500 Internal Server Error" { t.Errorf("Expected:%+v, received:%+v", "200 OK", resp.Status) @@ -1074,12 +1074,12 @@ func testHttpHandlerConfigSForFile(t *testing.T) { HandlerConfigS(w, req) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if resp.Status != "200 OK" { t.Errorf("Expected %+v , received: %+v ", "200 OK", resp.Status) } - if dat, err := ioutil.ReadFile("/usr/share/cgrates/conf/samples/tutmysql/cgrates.json"); err != nil { + if dat, err := os.ReadFile("/usr/share/cgrates/conf/samples/tutmysql/cgrates.json"); err != nil { t.Error(err) } else if string(dat) != string(body) { t.Errorf("Expected %s , received: %s ", string(dat), string(body)) @@ -1093,7 +1093,7 @@ func testHttpHandlerConfigSForNotExistFolder(t *testing.T) { HandlerConfigS(w, req) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if resp.Status != "404 Not Found" { t.Errorf("Expected %+v , received: %+v ", "200 OK", resp.Status) @@ -1111,7 +1111,7 @@ func testHttpHandlerConfigSForFolder(t *testing.T) { HandlerConfigS(w, req) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) if resp.Status != "200 OK" { t.Errorf("Expected %+v , received: %+v ", "200 OK", resp.Status) @@ -1228,7 +1228,7 @@ func testHandleConfigSFilesError(t *testing.T) { handleConfigSFile(flPath, w) resp := w.Result() - body, _ := ioutil.ReadAll(resp.Body) + body, _ := io.ReadAll(resp.Body) expected := "open /usr/share/cgrates/conf/samples/NotExists/cgrates.json: no such file or directory" if expected != string(body) { diff --git a/config/configs.go b/config/configs.go index 10a3a7bdf..18a5b9fe0 100644 --- a/config/configs.go +++ b/config/configs.go @@ -17,7 +17,6 @@ package config import ( "fmt" - "io/ioutil" "net/http" "os" "path" @@ -95,7 +94,7 @@ func handleConfigSFolder(path string, w http.ResponseWriter) { func handleConfigSFile(path string, w http.ResponseWriter) { // if the config is a file read the file and send it directly - dat, err := ioutil.ReadFile(path) + dat, err := os.ReadFile(path) if err != nil { w.WriteHeader(500) fmt.Fprintf(w, err.Error()) diff --git a/config/rjreader.go b/config/rjreader.go index d5e7e95f5..ad3dcba01 100644 --- a/config/rjreader.go +++ b/config/rjreader.go @@ -23,7 +23,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "strings" @@ -33,7 +32,7 @@ import ( // NewRjReader creates a new rjReader from a io.Reader func NewRjReader(rdr io.Reader) (r *RjReader, err error) { var b []byte - b, err = ioutil.ReadAll(rdr) + b, err = io.ReadAll(rdr) if err != nil { return } diff --git a/cores/gob_codec_test.go b/cores/gob_codec_test.go index e02df42d8..66defc4e5 100644 --- a/cores/gob_codec_test.go +++ b/cores/gob_codec_test.go @@ -21,7 +21,7 @@ package cores import ( "bufio" "encoding/gob" - "io/ioutil" + "io" "log" "net/rpc" "testing" @@ -53,7 +53,7 @@ func (mk *mockReadWriteCloserErrorNilInterface) Write(p []byte) (n int, err erro } func TestWriteResponseInterface(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) resp := &rpc.Response{ ServiceMethod: utils.APIerSv1Ping, Seq: 123, @@ -75,7 +75,7 @@ func (mk *mockReadWriteCloserErrorNilResponse) Write(p []byte) (n int, err error } func TestWriteResponseResponse(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) resp := &rpc.Response{ ServiceMethod: utils.APIerSv1Ping, Seq: 123, diff --git a/cores/server.go b/cores/server.go index f22d6213c..986e77e40 100644 --- a/cores/server.go +++ b/cores/server.go @@ -25,12 +25,12 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "net" "net/http" "net/http/pprof" "net/rpc" + "os" "strings" "sync" "time" @@ -373,7 +373,7 @@ func loadTLSConfig(serverCrt, serverKey, caCert string, serverPolicy int, } if caCert != "" { - ca, err := ioutil.ReadFile(caCert) + ca, err := os.ReadFile(caCert) if err != nil { utils.Logger.Crit(fmt.Sprintf("Error: %s when read CA", err)) return config, err diff --git a/cores/server_it_test.go b/cores/server_it_test.go index 40c213ff9..1e0706ac4 100644 --- a/cores/server_it_test.go +++ b/cores/server_it_test.go @@ -24,7 +24,7 @@ import ( "bytes" "errors" "fmt" - "io/ioutil" + "io" "log" "net" "net/http" @@ -92,7 +92,7 @@ var ( func TestServerIT(t *testing.T) { utils.Logger.SetLogLevel(7) for _, test := range sTestsServer { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) t.Run("Running IT serve tests", test) } } diff --git a/cores/server_test.go b/cores/server_test.go index 34230c5d9..fdca3b089 100644 --- a/cores/server_test.go +++ b/cores/server_test.go @@ -19,7 +19,7 @@ along with this program. If not, see package cores import ( - "io/ioutil" + "io" "log" "net/http" "os" @@ -62,7 +62,7 @@ func TestNewServer(t *testing.T) { } func TestRegisterHttpFunc(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfgDflt := config.NewDefaultCGRConfig() cfgDflt.CoreSCfg().CapsStatsInterval = 1 caps := engine.NewCaps(0, utils.MetaBusy) diff --git a/docs/installation.rst b/docs/installation.rst index ca9616c7d..fed54b631 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -123,14 +123,14 @@ Install GO Lang First we have to setup the GO Lang to our OS. Feel free to download the latest GO binary release from https://golang.org/dl/ -In this Tutorial we are going to install Go 1.15 +In this Tutorial we are going to install Go 1.16 :: sudo rm -rf /usr/local/go cd /tmp - wget https://golang.org/dl/go1.15.linux-amd64.tar.gz - sudo tar -xvf go1.15.linux-amd64.tar.gz -C /usr/local/ + wget https://golang.org/dl/go1.16.linux-amd64.tar.gz + sudo tar -xvf go1.16.linux-amd64.tar.gz -C /usr/local/ export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin diff --git a/ees/filecsv_it_test.go b/ees/filecsv_it_test.go index 4f6386590..af79d34e4 100644 --- a/ees/filecsv_it_test.go +++ b/ees/filecsv_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package ees import ( - "io/ioutil" "net/rpc" "os" "path" @@ -216,7 +215,7 @@ func testCsvVerifyExports(t *testing.T) { "\n" + "2478e9f18ebcd3c684f3c14596b8bfeab2b0d6d4,192.168.1.1,*default,*sms,sdfwer,*rated,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,1,0.15" + "\n" - if outContent1, err := ioutil.ReadFile(files[0]); err != nil { + if outContent1, err := os.ReadFile(files[0]); err != nil { t.Error(err) } else if len(eCnt) != len(string(outContent1)) { t.Errorf("Expecting: \n<%+v>, \nreceived: \n<%+v>", len(eCnt), len(string(outContent1))) @@ -310,7 +309,7 @@ func testCsvVerifyComposedExports(t *testing.T) { "1,dbafe9c8614c785a65aabd116dd3959c3c56f7f6,*default,*voice,dsafdsaf,*rated,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,10000000000,1.0164" + "\n" + "2,2478e9f18ebcd3c684f3c14596b8bfeab2b0d6d4,*default,*sms,sdfwer,*rated,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,1,0.1555" + "\n" + "2,10s,1ns,1.1718" + "\n" - if outContent1, err := ioutil.ReadFile(files[0]); err != nil { + if outContent1, err := os.ReadFile(files[0]); err != nil { t.Error(err) } else if eCnt != string(outContent1) { t.Errorf("Expecting: \n<%q>, \nreceived: \n<%q>", eCnt, string(outContent1)) @@ -374,7 +373,7 @@ func testCsvVerifyMaskedDestination(t *testing.T) { t.Errorf("Expected %+v, received: %+v", 1, len(files)) } eCnt := "dbafe9c8614c785a65aabd116dd3959c3c56f7f6,*default,*voice,dsafdsaf,*rated,cgrates.org,call,1001,1001,+4986517174***,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,10000000000,1.01\n" - if outContent1, err := ioutil.ReadFile(files[0]); err != nil { + if outContent1, err := os.ReadFile(files[0]); err != nil { t.Error(err) } else if eCnt != string(outContent1) { t.Errorf("Expecting: \n<%q>, \nreceived: \n<%q>", eCnt, string(outContent1)) @@ -498,7 +497,7 @@ func testCsvVerifyExportsWithInflateTemplate(t *testing.T) { "\n" + "2478e9f18ebcd3c684f3c14596b8bfeab2b0d6d4,*default,*sms,sdfwer,*rated,cgrates.org,call,1001,1001,1002,2013-11-07T08:42:25Z,2013-11-07T08:42:26Z,1,0.15" + "\n" - if outContent1, err := ioutil.ReadFile(files[0]); err != nil { + if outContent1, err := os.ReadFile(files[0]); err != nil { t.Error(err) } else if eCnt != string(outContent1) { t.Errorf("Expecting: \n<%q>, \nreceived: \n<%q>", eCnt, string(outContent1)) diff --git a/ees/filefwv_it_test.go b/ees/filefwv_it_test.go index 33854c357..eed8e37a0 100644 --- a/ees/filefwv_it_test.go +++ b/ees/filefwv_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package ees import ( - "io/ioutil" "net/rpc" "os" "path" @@ -148,7 +147,7 @@ func testFwvVerifyExports(t *testing.T) { eHdr := "10 VOI02062016520001 \n" eCnt := "201001 1001 cli 1002 0211 071113084200100000 1op3dsafdsaf 002.34567\n" eTrl := "90 VOI0000010000010s071113084200 \n" - if outContent1, err := ioutil.ReadFile(files[0]); err != nil { + if outContent1, err := os.ReadFile(files[0]); err != nil { t.Error(err) } else if len(eHdr+eTrl+eCnt) != len(outContent1) { t.Errorf("Expecting: <%+v>, received: <%+v>", len(eHdr+eTrl+eCnt), len(outContent1)) diff --git a/ees/httppost_it_test.go b/ees/httppost_it_test.go index d5a9e6c80..3e617a017 100644 --- a/ees/httppost_it_test.go +++ b/ees/httppost_it_test.go @@ -21,7 +21,7 @@ along with this program. If not, see package ees import ( - "io/ioutil" + "io" "net/http" "net/rpc" "net/url" @@ -99,7 +99,7 @@ func testHTTPPostRPCConn(t *testing.T) { func testHTTPStartHTTPServer(t *testing.T) { http.HandleFunc("/event_http", func(writer http.ResponseWriter, r *http.Request) { - b, err := ioutil.ReadAll(r.Body) + b, err := io.ReadAll(r.Body) r.Body.Close() if err != nil { t.Error(err) diff --git a/ees/virtual_ee_it_test.go b/ees/virtual_ee_it_test.go index 3f075b0f0..9366e5c4c 100644 --- a/ees/virtual_ee_it_test.go +++ b/ees/virtual_ee_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package ees import ( - "io/ioutil" "net/rpc" "os" "path" @@ -180,7 +179,7 @@ func testVirtVerifyExports(t *testing.T) { t.Errorf("Expected %+v, received: %+v", 1, len(files)) } eCnt := "dbafe9c8614c785a65aabd116dd3959c3c56f7f6,SupplierRun,dsafdsaf,cgrates.org,1001,1.01,CustomValue,1.23,SupplierRun\n" - if outContent1, err := ioutil.ReadFile(files[0]); err != nil { + if outContent1, err := os.ReadFile(files[0]); err != nil { t.Error(err) } else if eCnt != string(outContent1) { t.Errorf("Expecting: \n<%q>, \nreceived: \n<%q>", eCnt, string(outContent1)) diff --git a/engine/actions_test.go b/engine/actions_test.go index 64509fa16..2a2144a77 100644 --- a/engine/actions_test.go +++ b/engine/actions_test.go @@ -19,7 +19,7 @@ package engine import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "reflect" @@ -2750,7 +2750,7 @@ func TestRemoteSetAccountAction(t *testing.T) { } ts = httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { accStr := utils.ToJSON(acc) + "\n" - val, err := ioutil.ReadAll(r.Body) + val, err := io.ReadAll(r.Body) r.Body.Close() if err != nil { t.Error(err) diff --git a/engine/libcdre.go b/engine/libcdre.go index b182baa18..02f21c7ba 100644 --- a/engine/libcdre.go +++ b/engine/libcdre.go @@ -22,7 +22,6 @@ import ( "bytes" "encoding/gob" "fmt" - "io/ioutil" "os" "path" "sync" @@ -88,7 +87,7 @@ func AddFailedPost(expPath, format, module string, ev interface{}, opts map[stri func NewExportEventsFromFile(filePath string) (expEv *ExportEvents, err error) { var fileContent []byte _, err = guardian.Guardian.Guard(func() (interface{}, error) { - if fileContent, err = ioutil.ReadFile(filePath); err != nil { + if fileContent, err = os.ReadFile(filePath); err != nil { return 0, err } return 0, os.Remove(filePath) diff --git a/engine/pstr_http.go b/engine/pstr_http.go index 1644c6def..831d7a889 100644 --- a/engine/pstr_http.go +++ b/engine/pstr_http.go @@ -22,7 +22,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -43,7 +42,7 @@ func HTTPPostJSON(url string, content []byte) (respBody []byte, err error) { if resp, err = client.Post(url, "application/json", bytes.NewBuffer(content)); err != nil { return } - respBody, err = ioutil.ReadAll(resp.Body) + respBody, err = io.ReadAll(resp.Body) resp.Body.Close() if err != nil { return @@ -108,7 +107,7 @@ func (pstr *HTTPPoster) do(req *http.Request) (respBody []byte, err error) { utils.Logger.Warning(fmt.Sprintf(" Posting to : <%s>, error: <%s>", pstr.addr, err.Error())) return } - respBody, err = ioutil.ReadAll(resp.Body) + respBody, err = io.ReadAll(resp.Body) resp.Body.Close() if err != nil { utils.Logger.Warning(fmt.Sprintf(" Posting to : <%s>, error: <%s>", pstr.addr, err.Error())) diff --git a/engine/storage_csv.go b/engine/storage_csv.go index 8dbfe0420..021e5089c 100644 --- a/engine/storage_csv.go +++ b/engine/storage_csv.go @@ -23,7 +23,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "log" "net/http" "net/url" @@ -850,7 +849,7 @@ func getCfgJSONData(raw json.RawMessage) (data []byte, err error) { if !strings.HasSuffix(dataPath, utils.JSNSuffix) { dataPath = path.Join(dataPath, utils.GoogleCredentialsFileName) } - return ioutil.ReadFile(dataPath) + return os.ReadFile(dataPath) } func newSheet() (sht *sheets.Service, err error) { //*google_api diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index c375ff511..1d166f511 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -23,7 +23,7 @@ import ( "compress/zlib" "context" "fmt" - "io/ioutil" + "io" "reflect" "strings" "sync" @@ -758,7 +758,7 @@ func (ms *MongoStorage) GetRatingPlanDrv(key string) (rp *RatingPlan, err error) if err != nil { return nil, err } - out, err := ioutil.ReadAll(r) + out, err := io.ReadAll(r) if err != nil { return nil, err } @@ -858,7 +858,7 @@ func (ms *MongoStorage) GetDestinationDrv(key, transactionID string) (result *De if err != nil { return nil, err } - out, err := ioutil.ReadAll(r) + out, err := io.ReadAll(r) if err != nil { return nil, err } @@ -1266,7 +1266,7 @@ func (ms *MongoStorage) GetActionPlanDrv(key string, skipCache bool, if err != nil { return nil, err } - out, err := ioutil.ReadAll(r) + out, err := io.ReadAll(r) if err != nil { return nil, err } diff --git a/engine/storage_mongo_stordb.go b/engine/storage_mongo_stordb.go index 3f6e54bb3..b6b6965aa 100644 --- a/engine/storage_mongo_stordb.go +++ b/engine/storage_mongo_stordb.go @@ -1021,7 +1021,7 @@ func (ms *MongoStorage) GetCDRs(qryFltr *utils.CDRsFilter, remove bool) ([]*CDR, //CostDetailsLow + "." + AccountLow: bson.M{"$in": qryFltr.RatedAccounts, "$nin": qryFltr.NotRatedAccounts}, //CostDetailsLow + "." + SubjectLow: bson.M{"$in": qryFltr.RatedSubjects, "$nin": qryFltr.NotRatedSubjects}, } - //file, _ := ioutil.TempFile(os.TempDir(), "debug") + //file, _ := os.TempFile(os.TempDir(), "debug") //file.WriteString(fmt.Sprintf("FILTER: %v\n", utils.ToIJSON(qryFltr))) //file.WriteString(fmt.Sprintf("BEFORE: %v\n", utils.ToIJSON(filters))) ms.cleanEmptyFilters(filters) diff --git a/engine/storage_redis.go b/engine/storage_redis.go index f396f722c..09c1631a9 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -25,7 +25,7 @@ import ( "crypto/x509" "errors" "io" - "io/ioutil" + "os" "strconv" "time" @@ -106,7 +106,7 @@ func NewRedisStorage(address string, db int, user, pass, mrshlerStr string, } if tlsCACert != "" { var ca []byte - if ca, err = ioutil.ReadFile(tlsCACert); err != nil { + if ca, err = os.ReadFile(tlsCACert); err != nil { return } @@ -292,7 +292,7 @@ func (rs *RedisStorage) GetRatingPlanDrv(key string) (rp *RatingPlan, err error) return } var out []byte - if out, err = ioutil.ReadAll(r); err != nil { + if out, err = io.ReadAll(r); err != nil { return } r.Close() @@ -374,7 +374,7 @@ func (rs *RedisStorage) GetDestinationDrv(key, transactionID string) (dest *Dest return } var out []byte - if out, err = ioutil.ReadAll(r); err != nil { + if out, err = io.ReadAll(r); err != nil { return } r.Close() @@ -652,7 +652,7 @@ func (rs *RedisStorage) GetActionPlanDrv(key string, skipCache bool, return } var out []byte - if out, err = ioutil.ReadAll(r); err != nil { + if out, err = io.ReadAll(r); err != nil { return } r.Close() diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 5b5962fb4..859229a6b 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -23,7 +23,7 @@ import ( "database/sql" "encoding/json" "fmt" - "io/ioutil" + "os" "path" "strings" "time" @@ -80,7 +80,7 @@ func (SQLStorage) RemoveKeysForPrefix(string) error { } func (sqls *SQLStorage) CreateTablesFromScript(scriptPath string) error { - fileContent, err := ioutil.ReadFile(scriptPath) + fileContent, err := os.ReadFile(scriptPath) if err != nil { return err } diff --git a/engine/suretax.go b/engine/suretax.go index afc857308..f86a95183 100644 --- a/engine/suretax.go +++ b/engine/suretax.go @@ -23,7 +23,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "strconv" "strings" @@ -198,7 +198,7 @@ func SureTaxProcessCdr(cdr *CDR) error { return err } defer resp.Body.Close() - respBody, err := ioutil.ReadAll(resp.Body) + respBody, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/engine/tpimporter_csv.go b/engine/tpimporter_csv.go index cb8dfca09..d8d2ac2ee 100644 --- a/engine/tpimporter_csv.go +++ b/engine/tpimporter_csv.go @@ -20,8 +20,8 @@ package engine import ( "fmt" - "io/ioutil" "log" + "os" "github.com/cgrates/cgrates/utils" ) @@ -67,7 +67,7 @@ var fileHandlers = map[string]func(*TPCSVImporter, string) error{ func (self *TPCSVImporter) Run() error { self.csvr = NewFileCSVStorage(self.Sep, self.DirPath) - files, _ := ioutil.ReadDir(self.DirPath) + files, _ := os.ReadDir(self.DirPath) var withErrors bool for _, f := range files { fHandler, hasName := fileHandlers[f.Name()] diff --git a/engine/z_actions_it_test.go b/engine/z_actions_it_test.go index 348a677ad..8e5e302f4 100644 --- a/engine/z_actions_it_test.go +++ b/engine/z_actions_it_test.go @@ -20,7 +20,7 @@ along with this program. If not, see package engine import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "net/rpc" @@ -940,7 +940,7 @@ func testActionsitremoteSetAccount(t *testing.T) { } ts := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { accStr := utils.ToJSON(acc) + "\n" - val, err := ioutil.ReadAll(r.Body) + val, err := io.ReadAll(r.Body) r.Body.Close() if err != nil { t.Error(err) diff --git a/ers/filecsv.go b/ers/filecsv.go index 09f9a23ac..9b43d0da1 100644 --- a/ers/filecsv.go +++ b/ers/filecsv.go @@ -23,7 +23,6 @@ import ( "encoding/csv" "fmt" "io" - "io/ioutil" "os" "path" "strings" @@ -97,7 +96,7 @@ func (rdr *CSVFileER) Serve() (err error) { return case <-tm.C: } - filesInDir, _ := ioutil.ReadDir(rdr.rdrDir) + filesInDir, _ := os.ReadDir(rdr.rdrDir) for _, file := range filesInDir { if !strings.HasSuffix(file.Name(), utils.CSVSuffix) { // hardcoded file extension for csv event reader continue // used in order to filter the files from directory diff --git a/ers/filecsv_it_test.go b/ers/filecsv_it_test.go index b87da70f9..109307dcc 100644 --- a/ers/filecsv_it_test.go +++ b/ers/filecsv_it_test.go @@ -20,7 +20,6 @@ along with this program. If not, see package ers import ( - "io/ioutil" "net/rpc" "os" "path" @@ -152,7 +151,7 @@ func testCsvITLoadTPFromFolder(t *testing.T) { func testCsvITHandleCdr1File(t *testing.T) { fileName := "file1.csv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(fileContent1), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(fileContent1), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/ers/in", fileName)); err != nil { @@ -164,7 +163,7 @@ func testCsvITHandleCdr1File(t *testing.T) { func testCsvITHandleCdr2File(t *testing.T) { fileName := "file2.csv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(fileContent2), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(fileContent2), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/ers2/in", fileName)); err != nil { @@ -190,7 +189,7 @@ func testCsvITHandleSessionFile(t *testing.T) { } fileName := "file3.csv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(fileContent3), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(fileContent3), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/init_session/in", fileName)); err != nil { @@ -279,7 +278,7 @@ func testCsvITAnalyseCDRs(t *testing.T) { func testCsvITProcessFilteredCDR(t *testing.T) { fileName := "file1.csv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(fileContentForFilter), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(fileContentForFilter), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/ers_with_filters/in", fileName)); err != nil { @@ -310,22 +309,22 @@ func testCsvITAnalyzeFilteredCDR(t *testing.T) { func testCsvITProcessedFiles(t *testing.T) { time.Sleep(500 * time.Millisecond) - if outContent1, err := ioutil.ReadFile("/tmp/ers/out/file1.csv"); err != nil { + if outContent1, err := os.ReadFile("/tmp/ers/out/file1.csv"); err != nil { t.Error(err) } else if fileContent1 != string(outContent1) { t.Errorf("Expecting: %q, received: %q", fileContent1, string(outContent1)) } - if outContent2, err := ioutil.ReadFile("/tmp/ers2/out/file2.csv"); err != nil { + if outContent2, err := os.ReadFile("/tmp/ers2/out/file2.csv"); err != nil { t.Error(err) } else if fileContent2 != string(outContent2) { t.Errorf("Expecting: %q, received: %q", fileContent2, string(outContent2)) } - if outContent3, err := ioutil.ReadFile("/tmp/cdrs/out/file3.csv"); err != nil { + if outContent3, err := os.ReadFile("/tmp/cdrs/out/file3.csv"); err != nil { t.Error(err) } else if fileContent3 != string(outContent3) { t.Errorf("Expecting: %q, received: %q", fileContent3, string(outContent3)) } - if outContent4, err := ioutil.ReadFile("/tmp/ers_with_filters/out/file1.csv"); err != nil { + if outContent4, err := os.ReadFile("/tmp/ers_with_filters/out/file1.csv"); err != nil { t.Error(err) } else if fileContentForFilter != string(outContent4) { t.Errorf("Expecting: %q, received: %q", fileContentForFilter, string(outContent4)) @@ -335,7 +334,7 @@ func testCsvITProcessedFiles(t *testing.T) { func testCsvITReaderWithFilter(t *testing.T) { fileName := "file1.csv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(fileContent1), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(fileContent1), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/readerWithTemplate/in", fileName)); err != nil { diff --git a/ers/filefwv.go b/ers/filefwv.go index 8f15b3238..7b561ac59 100644 --- a/ers/filefwv.go +++ b/ers/filefwv.go @@ -22,7 +22,6 @@ import ( "bufio" "fmt" "io" - "io/ioutil" "os" "path" "strings" @@ -103,7 +102,7 @@ func (rdr *FWVFileER) Serve() (err error) { return case <-tm.C: } - filesInDir, _ := ioutil.ReadDir(rdr.rdrDir) + filesInDir, _ := os.ReadDir(rdr.rdrDir) for _, file := range filesInDir { if !strings.HasSuffix(file.Name(), utils.FWVSuffix) { // hardcoded file extension for xml event reader continue // used in order to filter the files from directory diff --git a/ers/filefwv_it_test.go b/ers/filefwv_it_test.go index dbf41db27..f4ac94263 100644 --- a/ers/filefwv_it_test.go +++ b/ers/filefwv_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package ers import ( - "io/ioutil" "net/rpc" "os" "path" @@ -172,7 +171,7 @@ TRL0001DDB ABC Some Connect A.B. func testFWVITHandleCdr1File(t *testing.T) { fileName := "file1.fwv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(fwvContent), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(fwvContent), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/fwvErs/in", fileName)); err != nil { diff --git a/ers/filejson.go b/ers/filejson.go index 4ecafdc6b..2e4891b98 100644 --- a/ers/filejson.go +++ b/ers/filejson.go @@ -21,7 +21,7 @@ package ers import ( "encoding/json" "fmt" - "io/ioutil" + "io" "os" "path" "strings" @@ -96,7 +96,7 @@ func (rdr *JSONFileER) Serve() (err error) { return case <-tm.C: } - filesInDir, _ := ioutil.ReadDir(rdr.rdrDir) + filesInDir, _ := os.ReadDir(rdr.rdrDir) for _, file := range filesInDir { if !strings.HasSuffix(file.Name(), utils.JSNSuffix) { // hardcoded file extension for json event reader continue // used in order to filter the files from directory @@ -132,7 +132,7 @@ func (rdr *JSONFileER) processFile(fPath, fName string) (err error) { defer file.Close() timeStart := time.Now() var byteValue []byte - if byteValue, err = ioutil.ReadAll(file); err != nil { + if byteValue, err = io.ReadAll(file); err != nil { return } diff --git a/ers/filejson_it_test.go b/ers/filejson_it_test.go index 608903415..68858329a 100644 --- a/ers/filejson_it_test.go +++ b/ers/filejson_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package ers import ( - "io/ioutil" "net/rpc" "os" "path" @@ -186,7 +185,7 @@ func testJSONAddData(t *testing.T) { func testJSONHandleFile(t *testing.T) { fileName := "file1.json" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(fileContent), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(fileContent), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/ErsJSON/in", fileName)); err != nil { diff --git a/ers/filexml.go b/ers/filexml.go index 81be93136..7893e9312 100644 --- a/ers/filexml.go +++ b/ers/filexml.go @@ -20,7 +20,6 @@ package ers import ( "fmt" - "io/ioutil" "os" "path" "strings" @@ -97,7 +96,7 @@ func (rdr *XMLFileER) Serve() (err error) { return case <-tm.C: } - filesInDir, _ := ioutil.ReadDir(rdr.rdrDir) + filesInDir, _ := os.ReadDir(rdr.rdrDir) for _, file := range filesInDir { if !strings.HasSuffix(file.Name(), utils.XMLSuffix) { // hardcoded file extension for xml event reader continue // used in order to filter the files from directory diff --git a/ers/filexml_it_test.go b/ers/filexml_it_test.go index 5b5553885..d4342033a 100644 --- a/ers/filexml_it_test.go +++ b/ers/filexml_it_test.go @@ -20,7 +20,6 @@ along with this program. If not, see package ers import ( - "io/ioutil" "net/rpc" "os" "path" @@ -257,7 +256,7 @@ var cdrXmlBroadsoft = ` func testXMLITHandleCdr1File(t *testing.T) { fileName := "file1.xml" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(cdrXmlBroadsoft), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(cdrXmlBroadsoft), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/xmlErs/in", fileName)); err != nil { diff --git a/ers/flatstore.go b/ers/flatstore.go index ce0b6696c..d81f85886 100644 --- a/ers/flatstore.go +++ b/ers/flatstore.go @@ -24,7 +24,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "path" "strconv" @@ -104,7 +103,7 @@ func (rdr *FlatstoreER) Serve() (err error) { return case <-tm.C: } - filesInDir, _ := ioutil.ReadDir(rdr.rdrDir) + filesInDir, _ := os.ReadDir(rdr.rdrDir) for _, file := range filesInDir { if !strings.HasSuffix(file.Name(), utils.CSVSuffix) { // hardcoded file extension for csv event reader continue // used in order to filter the files from directory diff --git a/ers/flatstore_it_test.go b/ers/flatstore_it_test.go index b62affd2f..40e6d7545 100644 --- a/ers/flatstore_it_test.go +++ b/ers/flatstore_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package ers import ( - "io/ioutil" "net/rpc" "os" "path" @@ -151,16 +150,16 @@ func testFlatstoreITLoadTPFromFolder(t *testing.T) { // The default scenario, out of ers defined in .cfg file func testFlatstoreITHandleCdr1File(t *testing.T) { - if err := ioutil.WriteFile(path.Join("/tmp", "acc_1.log"), []byte(fullSuccessfull), 0644); err != nil { + if err := os.WriteFile(path.Join("/tmp", "acc_1.log"), []byte(fullSuccessfull), 0644); err != nil { t.Fatal(err.Error()) } - if err := ioutil.WriteFile(path.Join("/tmp", "missed_calls_1.log"), []byte(fullMissed), 0644); err != nil { + if err := os.WriteFile(path.Join("/tmp", "missed_calls_1.log"), []byte(fullMissed), 0644); err != nil { t.Fatal(err.Error()) } - if err := ioutil.WriteFile(path.Join("/tmp", "acc_2.log"), []byte(part1), 0644); err != nil { + if err := os.WriteFile(path.Join("/tmp", "acc_2.log"), []byte(part1), 0644); err != nil { t.Fatal(err.Error()) } - if err := ioutil.WriteFile(path.Join("/tmp", "acc_3.log"), []byte(part2), 0644); err != nil { + if err := os.WriteFile(path.Join("/tmp", "acc_3.log"), []byte(part2), 0644); err != nil { t.Fatal(err.Error()) } //Rename(oldpath, newpath string) @@ -171,11 +170,11 @@ func testFlatstoreITHandleCdr1File(t *testing.T) { } time.Sleep(time.Second) // check the files to be processed - filesInDir, _ := ioutil.ReadDir("/tmp/flatstoreErs/in") + filesInDir, _ := os.ReadDir("/tmp/flatstoreErs/in") if len(filesInDir) != 0 { t.Errorf("Files in ersInDir: %+v", filesInDir) } - filesOutDir, _ := ioutil.ReadDir("/tmp/flatstoreErs/out") + filesOutDir, _ := os.ReadDir("/tmp/flatstoreErs/out") if len(filesOutDir) != 5 { ids := []string{} for _, fD := range filesOutDir { @@ -184,7 +183,7 @@ func testFlatstoreITHandleCdr1File(t *testing.T) { t.Errorf("Unexpected number of files in output directory: %+v, %q", len(filesOutDir), ids) } ePartContent := "INVITE|2daec40c|548625ac|dd0c4c617a9919d29a6175cdff223a9p@0:0:0:0:0:0:0:0|200|OK|1436454408|*prepaid|1001|1002||3401:2069362475\n" - if partContent, err := ioutil.ReadFile(path.Join("/tmp/flatstoreErs/out", "acc_3.log.tmp")); err != nil { + if partContent, err := os.ReadFile(path.Join("/tmp/flatstoreErs/out", "acc_3.log.tmp")); err != nil { t.Error(err) } else if (ePartContent) != (string(partContent)) { t.Errorf("Expecting:\n%s\nReceived:\n%s", ePartContent, string(partContent)) diff --git a/ers/partial_csv.go b/ers/partial_csv.go index f7879dccd..730b738ce 100644 --- a/ers/partial_csv.go +++ b/ers/partial_csv.go @@ -23,7 +23,6 @@ import ( "encoding/csv" "fmt" "io" - "io/ioutil" "os" "path" "sort" @@ -111,7 +110,7 @@ func (rdr *PartialCSVFileER) Serve() (err error) { return case <-tm.C: } - filesInDir, _ := ioutil.ReadDir(rdr.rdrDir) + filesInDir, _ := os.ReadDir(rdr.rdrDir) for _, file := range filesInDir { if !strings.HasSuffix(file.Name(), utils.CSVSuffix) { // hardcoded file extension for csv event reader continue // used in order to filter the files from directory diff --git a/ers/partial_csv_it_test.go b/ers/partial_csv_it_test.go index a7b52b78c..b0f2f81bd 100644 --- a/ers/partial_csv_it_test.go +++ b/ers/partial_csv_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package ers import ( - "io/ioutil" "net/rpc" "os" "path" @@ -150,7 +149,7 @@ func testPartITLoadTPFromFolder(t *testing.T) { func testPartITHandleCdr1File(t *testing.T) { fileName := "file1.csv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(partCsvFileContent1), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(partCsvFileContent1), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/partErs1/in", fileName)); err != nil { @@ -162,7 +161,7 @@ func testPartITHandleCdr1File(t *testing.T) { func testPartITHandleCdr2File(t *testing.T) { fileName := "file2.csv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(partCsvFileContent2), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(partCsvFileContent2), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/partErs1/in", fileName)); err != nil { @@ -174,7 +173,7 @@ func testPartITHandleCdr2File(t *testing.T) { func testPartITHandleCdr3File(t *testing.T) { fileName := "file3.csv" tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(partCsvFileContent3), 0644); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(partCsvFileContent3), 0644); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/partErs2/in", fileName)); err != nil { @@ -184,7 +183,7 @@ func testPartITHandleCdr3File(t *testing.T) { } func testPartITVerifyFiles(t *testing.T) { - filesInDir, _ := ioutil.ReadDir("/tmp/partErs1/out/") + filesInDir, _ := os.ReadDir("/tmp/partErs1/out/") if len(filesInDir) == 0 { t.Errorf("No files found in folder: <%s>", "/tmp/partErs1/out") } @@ -195,7 +194,7 @@ func testPartITVerifyFiles(t *testing.T) { break } } - if contentCacheDump, err := ioutil.ReadFile(path.Join("/tmp/partErs1/out", fileName)); err != nil { + if contentCacheDump, err := os.ReadFile(path.Join("/tmp/partErs1/out", fileName)); err != nil { t.Error(err) } else if len(eCacheDumpFile1) != len(string(contentCacheDump)) { t.Errorf("Expecting: %q, \n received: %q", eCacheDumpFile1, string(contentCacheDump)) diff --git a/ers/s3.go b/ers/s3.go index 22f04651b..91095f21d 100644 --- a/ers/s3.go +++ b/ers/s3.go @@ -21,7 +21,7 @@ package ers import ( "encoding/json" "fmt" - "io/ioutil" + "io" "time" "github.com/aws/aws-sdk-go/aws" @@ -214,7 +214,7 @@ func (rdr *S3ER) readMsg(scv *s3.S3, key string) (err error) { return } var msg []byte - if msg, err = ioutil.ReadAll(obj.Body); err != nil { + if msg, err = io.ReadAll(obj.Body); err != nil { utils.Logger.Warning( fmt.Sprintf("<%s> decoding message %s error: %s", utils.ERs, key, err.Error())) diff --git a/general_tests/cdrs_exp_it_test.go b/general_tests/cdrs_exp_it_test.go index f2f91a776..a0338e733 100644 --- a/general_tests/cdrs_exp_it_test.go +++ b/general_tests/cdrs_exp_it_test.go @@ -25,7 +25,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/http" "net/rpc" "net/url" @@ -253,7 +252,7 @@ func testCDRsExpExportEvent(t *testing.T) { t.Error("Unexpected error: ", err) } time.Sleep(100 * time.Millisecond) - filesInDir, _ := ioutil.ReadDir(cdrsExpCfg.GeneralCfg().FailedPostsDir) + filesInDir, _ := os.ReadDir(cdrsExpCfg.GeneralCfg().FailedPostsDir) if len(filesInDir) != 0 { t.Fatalf("Should be no files in directory: %s", cdrsExpCfg.GeneralCfg().FailedPostsDir) } @@ -358,7 +357,7 @@ func checkContent(ev *engine.ExportEvents, content []interface{}) error { } func testCDRsExpFileFailover(t *testing.T) { time.Sleep(time.Second) - filesInDir, _ := ioutil.ReadDir(cdrsExpCfg.GeneralCfg().FailedPostsDir) + filesInDir, _ := os.ReadDir(cdrsExpCfg.GeneralCfg().FailedPostsDir) if len(filesInDir) == 0 { t.Fatalf("No files in directory: %s", cdrsExpCfg.GeneralCfg().FailedPostsDir) } diff --git a/general_tests/cdrs_onlexp_it_test.go b/general_tests/cdrs_onlexp_it_test.go index c65518f24..e517d8d58 100644 --- a/general_tests/cdrs_onlexp_it_test.go +++ b/general_tests/cdrs_onlexp_it_test.go @@ -24,7 +24,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/http" "net/url" "os" @@ -244,7 +243,7 @@ func testCDRsOnExpDisableOnlineExport(t *testing.T) { t.Error("Unexpected reply received: ", reply) } time.Sleep(time.Duration(*waitRater) * time.Millisecond) - filesInDir, _ := ioutil.ReadDir(cdrsMasterCfg.GeneralCfg().FailedPostsDir) + filesInDir, _ := os.ReadDir(cdrsMasterCfg.GeneralCfg().FailedPostsDir) if len(filesInDir) != 0 { t.Fatalf("Should be no files in directory: %s", cdrsMasterCfg.GeneralCfg().FailedPostsDir) } @@ -455,7 +454,7 @@ func testCDRsOnExpFileFailover(t *testing.T) { v2.Set("OriginID", "amqpreconnect") httpContent := []interface{}{&engine.HTTPPosterRequest{Body: v1, Header: http.Header{"Content-Type": []string{"application/x-www-form-urlencoded"}}}, &engine.HTTPPosterRequest{Body: v2, Header: http.Header{"Content-Type": []string{"application/x-www-form-urlencoded"}}}} - filesInDir, _ := ioutil.ReadDir(cdrsMasterCfg.GeneralCfg().FailedPostsDir) + filesInDir, _ := os.ReadDir(cdrsMasterCfg.GeneralCfg().FailedPostsDir) if len(filesInDir) == 0 { t.Fatalf("No files in directory: %s", cdrsMasterCfg.GeneralCfg().FailedPostsDir) } diff --git a/general_tests/cdrs_post_failover_it_test.go b/general_tests/cdrs_post_failover_it_test.go index 74dfad0ac..f50d7b038 100644 --- a/general_tests/cdrs_post_failover_it_test.go +++ b/general_tests/cdrs_post_failover_it_test.go @@ -21,7 +21,6 @@ along with this program. If not, see package general_tests import ( - "io/ioutil" "net/rpc" "os" "path" @@ -185,7 +184,7 @@ func testCDRsPostFailoverProcessCDR(t *testing.T) { func testCDRsPostFailoverToFile(t *testing.T) { time.Sleep(2 * time.Second) - filesInDir, _ := ioutil.ReadDir(cdrsPostFailCfg.GeneralCfg().FailedPostsDir) + filesInDir, _ := os.ReadDir(cdrsPostFailCfg.GeneralCfg().FailedPostsDir) if len(filesInDir) == 0 { t.Fatalf("No files in directory: %s", cdrsPostFailCfg.GeneralCfg().FailedPostsDir) } diff --git a/general_tests/cdrs_processevent_it_test.go b/general_tests/cdrs_processevent_it_test.go index 85503627e..0e466944b 100644 --- a/general_tests/cdrs_processevent_it_test.go +++ b/general_tests/cdrs_processevent_it_test.go @@ -21,8 +21,8 @@ package general_tests import ( "fmt" - "io/ioutil" "net/rpc" + "os" "path" "reflect" "sort" @@ -570,7 +570,7 @@ func testV1CDRsProcessEventExport(t *testing.T) { } func testV1CDRsProcessEventExportCheck(t *testing.T) { failoverContent := []byte(fmt.Sprintf(`{"CGRID":"%s"}`, utils.Sha1("test7_processEvent", "OriginHost7"))) - filesInDir, _ := ioutil.ReadDir(pecdrsCfg.GeneralCfg().FailedPostsDir) + filesInDir, _ := os.ReadDir(pecdrsCfg.GeneralCfg().FailedPostsDir) if len(filesInDir) == 0 { t.Fatalf("No files in directory: %s", pecdrsCfg.GeneralCfg().FailedPostsDir) } diff --git a/general_tests/oldtutorial_it_test.go b/general_tests/oldtutorial_it_test.go index 31ba665cf..410f87ee4 100644 --- a/general_tests/oldtutorial_it_test.go +++ b/general_tests/oldtutorial_it_test.go @@ -21,7 +21,6 @@ package general_tests // import ( -// "io/ioutil" // "net/rpc" // "net/rpc/jsonrpc" // "os" @@ -1448,7 +1447,7 @@ package general_tests // f0a92222a7d21b4d9f72744aabe82daef52e20d8,*default,testexportcdr1,*rated,cgrates.org,call,1001,1003,2016-11-30T18:06:04+01:00,98,1.33340,RETA // ` // expFilePath := path.Join(*exportArgs.ExportPath, *exportArgs.ExportFileName) -// if expContent, err := ioutil.ReadFile(expFilePath); err != nil { +// if expContent, err := os.ReadFile(expFilePath); err != nil { // t.Error(err) // } else if eExportContent != string(expContent) && eExportContent2 != string(expContent) { // CDRs are showing up randomly so we cannot predict order of export // t.Errorf("Expecting: <%q> or <%q> received: <%q>", eExportContent, eExportContent2, string(expContent)) diff --git a/general_tests/poster_it_test.go b/general_tests/poster_it_test.go index fff691085..05713b02a 100644 --- a/general_tests/poster_it_test.go +++ b/general_tests/poster_it_test.go @@ -22,8 +22,8 @@ package general_tests import ( "encoding/json" "fmt" - "io/ioutil" "net/rpc" + "os" "path" "testing" "time" @@ -112,7 +112,7 @@ func testPosterITRpcConn(t *testing.T) { } func testPosterReadFolder(format string) (expEv *engine.ExportEvents, err error) { - filesInDir, _ := ioutil.ReadDir(pstrCfg.GeneralCfg().FailedPostsDir) + filesInDir, _ := os.ReadDir(pstrCfg.GeneralCfg().FailedPostsDir) if len(filesInDir) == 0 { err = fmt.Errorf("No files in directory: %s", pstrCfg.GeneralCfg().FailedPostsDir) return diff --git a/go.mod b/go.mod index c01bc044b..df84211f8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cgrates/cgrates -go 1.15 +go 1.16 // replace github.com/cgrates/radigo => ../radigo diff --git a/loaders/lib_test.go b/loaders/lib_test.go index 4a15612b6..fb6bf2bf7 100644 --- a/loaders/lib_test.go +++ b/loaders/lib_test.go @@ -22,7 +22,7 @@ import ( "encoding/csv" "errors" "flag" - "io/ioutil" + "io" "net/rpc" "net/rpc/jsonrpc" "strings" @@ -126,7 +126,7 @@ func TestProcessContentCallsLoadCache(t *testing.T) { #Tenant[0],ID[1],Weight[2] cgrates.org,MOCK_RELOAD_ID,20 ` - rdr := ioutil.NopCloser(strings.NewReader(ratePrfCsv)) + rdr := io.NopCloser(strings.NewReader(ratePrfCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -144,7 +144,7 @@ cgrates.org,MOCK_RELOAD_ID,20 // Calling the method again while cacheConnsID is not valid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(ratePrfCsv)) + rdr = io.NopCloser(strings.NewReader(ratePrfCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -224,7 +224,7 @@ func TestProcessContentCallsReloadCache(t *testing.T) { #Tenant[0],ID[1],Weight[2] cgrates.org,MOCK_RELOAD_ID,20 ` - rdr := ioutil.NopCloser(strings.NewReader(ratePrfCsv)) + rdr := io.NopCloser(strings.NewReader(ratePrfCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -242,7 +242,7 @@ cgrates.org,MOCK_RELOAD_ID,20 // Calling the method again while cacheConnsID is not valid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(ratePrfCsv)) + rdr = io.NopCloser(strings.NewReader(ratePrfCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -318,7 +318,7 @@ func TestProcessContentCallsRemoveItems(t *testing.T) { #Tenant[0],ID[1] cgrates.org,MOCK_RELOAD_ID ` - rdr := ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr := io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -336,7 +336,7 @@ cgrates.org,MOCK_RELOAD_ID // Calling the method again while cacheConnsID is not valid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -355,7 +355,7 @@ cgrates.org,MOCK_RELOAD_ID // Calling the method again while caching method is invalid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -422,7 +422,7 @@ func TestProcessContentCallsClear(t *testing.T) { #Tenant[0],ID[1] cgrates.org,MOCK_RELOAD_ID ` - rdr := ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr := io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -439,7 +439,7 @@ cgrates.org,MOCK_RELOAD_ID } //inexisting method(*none) of cache and reinitialized the reader will do nothing - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -457,7 +457,7 @@ cgrates.org,MOCK_RELOAD_ID // Calling the method again while cacheConnsID is not valid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -533,7 +533,7 @@ func TestRemoveContentCallsReload(t *testing.T) { #Tenant[0],ID[1] cgrates.org,MOCK_RELOAD_2 ` - rdr := ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr := io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -558,7 +558,7 @@ cgrates.org,MOCK_RELOAD_2 //Calling the method again while cacheConnsID is not valid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -639,7 +639,7 @@ func TestRemoveContentCallsLoad(t *testing.T) { #Tenant[0],ID[1] cgrates.org,MOCK_RELOAD_3 ` - rdr := ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr := io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -664,7 +664,7 @@ cgrates.org,MOCK_RELOAD_3 //Calling the method again while cacheConnsID is not valid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -745,7 +745,7 @@ func TestRemoveContentCallsRemove(t *testing.T) { #Tenant[0],ID[1] cgrates.org,MOCK_RELOAD_4 ` - rdr := ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr := io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -770,7 +770,7 @@ cgrates.org,MOCK_RELOAD_4 //Calling the method again while cacheConnsID is not valid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -793,7 +793,7 @@ cgrates.org,MOCK_RELOAD_4 } //inexisting method(*none) of cache and reinitialized the reader will do nothing - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -862,7 +862,7 @@ func TestRemoveContentCallsClear(t *testing.T) { #Tenant[0],ID[1] cgrates.org,MOCK_RELOAD_3 ` - rdr := ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr := io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -887,7 +887,7 @@ cgrates.org,MOCK_RELOAD_3 //Calling the method again while cacheConnsID is not valid ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -910,7 +910,7 @@ cgrates.org,MOCK_RELOAD_3 } // Calling the method again while caching method is invalid - rdr = ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr = io.NopCloser(strings.NewReader(attributeCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ diff --git a/loaders/loader.go b/loaders/loader.go index 286caf59d..64345f5f9 100644 --- a/loaders/loader.go +++ b/loaders/loader.go @@ -22,7 +22,6 @@ import ( "encoding/csv" "fmt" "io" - "io/ioutil" "os" "path" "strings" @@ -165,7 +164,7 @@ func (ldr *Loader) moveFiles() (err error) { if ldr.tpOutDir == utils.EmptyString { return } - filesInDir, _ := ioutil.ReadDir(ldr.tpInDir) + filesInDir, _ := os.ReadDir(ldr.tpInDir) for _, file := range filesInDir { fName := file.Name() if fName == ldr.lockFilename { diff --git a/loaders/loader_it_test.go b/loaders/loader_it_test.go index 8624d4526..d9871f82e 100644 --- a/loaders/loader_it_test.go +++ b/loaders/loader_it_test.go @@ -22,7 +22,7 @@ package loaders import ( "encoding/csv" "fmt" - "io/ioutil" + "io" "net/rpc" "os" "path" @@ -164,7 +164,7 @@ func testLoaderRPCConn(t *testing.T) { func testLoaderPopulateData(t *testing.T) { fileName := utils.AttributesCsv tmpFilePath := path.Join("/tmp", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/In", fileName)); err != nil { @@ -182,7 +182,7 @@ func testLoaderLoadAttributes(t *testing.T) { func testLoaderVerifyOutDir(t *testing.T) { time.Sleep(100 * time.Millisecond) - if outContent1, err := ioutil.ReadFile(path.Join("/tmp/Out", utils.AttributesCsv)); err != nil { + if outContent1, err := os.ReadFile(path.Join("/tmp/Out", utils.AttributesCsv)); err != nil { t.Error(err) } else if engine.AttributesCSVContent != string(outContent1) { t.Errorf("Expecting: %q, received: %q", engine.AttributesCSVContent, string(outContent1)) @@ -235,7 +235,7 @@ func testLoaderCheckAttributes(t *testing.T) { func testLoaderPopulateDataWithoutMoving(t *testing.T) { fileName := utils.AttributesCsv tmpFilePath := path.Join("/tmp/", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { t.Fatal(err.Error()) } if err := os.Rename(tmpFilePath, path.Join("/tmp/LoaderIn", fileName)); err != nil { @@ -254,7 +254,7 @@ func testLoaderLoadAttributesWithoutMoving(t *testing.T) { func testLoaderVerifyOutDirWithoutMoving(t *testing.T) { time.Sleep(100 * time.Millisecond) // we expect that after the LoaderS process the file leave in in the input folder - if outContent1, err := ioutil.ReadFile(path.Join("/tmp/LoaderIn", utils.AttributesCsv)); err != nil { + if outContent1, err := os.ReadFile(path.Join("/tmp/LoaderIn", utils.AttributesCsv)); err != nil { t.Error(err) } else if engine.AttributesCSVContent != string(outContent1) { t.Errorf("Expecting: %q, received: %q", engine.AttributesCSVContent, string(outContent1)) @@ -264,7 +264,7 @@ func testLoaderVerifyOutDirWithoutMoving(t *testing.T) { func testLoaderPopulateDataWithSubpath(t *testing.T) { fileName := utils.AttributesCsv tmpFilePath := path.Join("/tmp/", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { t.Fatal(err.Error()) } if err := os.MkdirAll("/tmp/SubpathWithoutMove/folder1", 0755); err != nil { @@ -286,7 +286,7 @@ func testLoaderLoadAttributesWithSubpath(t *testing.T) { func testLoaderVerifyOutDirWithSubpath(t *testing.T) { time.Sleep(100 * time.Millisecond) // we expect that after the LoaderS process the file leave in in the input folder - if outContent1, err := ioutil.ReadFile(path.Join("/tmp/SubpathWithoutMove/folder1", utils.AttributesCsv)); err != nil { + if outContent1, err := os.ReadFile(path.Join("/tmp/SubpathWithoutMove/folder1", utils.AttributesCsv)); err != nil { t.Error(err) } else if engine.AttributesCSVContent != string(outContent1) { t.Errorf("Expecting: %q, received: %q", engine.AttributesCSVContent, string(outContent1)) @@ -296,7 +296,7 @@ func testLoaderVerifyOutDirWithSubpath(t *testing.T) { func testLoaderPopulateDataWithSubpathWithMove(t *testing.T) { fileName := utils.AttributesCsv tmpFilePath := path.Join("/tmp/", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { t.Fatal(err.Error()) } if err := os.MkdirAll("/tmp/SubpathLoaderWithMove/folder1", 0755); err != nil { @@ -317,7 +317,7 @@ func testLoaderLoadAttributesWithoutSubpathWithMove(t *testing.T) { func testLoaderVerifyOutDirWithSubpathWithMove(t *testing.T) { time.Sleep(100 * time.Millisecond) - if outContent1, err := ioutil.ReadFile(path.Join("/tmp/SubpathOut/folder1", utils.AttributesCsv)); err != nil { + if outContent1, err := os.ReadFile(path.Join("/tmp/SubpathOut/folder1", utils.AttributesCsv)); err != nil { t.Error(err) } else if engine.AttributesCSVContent != string(outContent1) { t.Errorf("Expecting: %q, received: %q", engine.AttributesCSVContent, string(outContent1)) @@ -327,7 +327,7 @@ func testLoaderVerifyOutDirWithSubpathWithMove(t *testing.T) { func testLoaderPopulateDataForTemplateLoader(t *testing.T) { fileName := utils.AttributesCsv tmpFilePath := path.Join("/tmp/", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(engine.AttributesCSVContent), 0777); err != nil { t.Fatal(err.Error()) } if err := os.MkdirAll("/tmp/templateLoaderIn", 0755); err != nil { @@ -348,7 +348,7 @@ func testLoaderLoadAttributesForTemplateLoader(t *testing.T) { func testLoaderVerifyOutDirForTemplateLoader(t *testing.T) { time.Sleep(100 * time.Millisecond) - if outContent1, err := ioutil.ReadFile(path.Join("/tmp/templateLoaderOut", utils.AttributesCsv)); err != nil { + if outContent1, err := os.ReadFile(path.Join("/tmp/templateLoaderOut", utils.AttributesCsv)); err != nil { t.Error(err) } else if engine.AttributesCSVContent != string(outContent1) { t.Errorf("Expecting: %q, received: %q", engine.AttributesCSVContent, string(outContent1)) @@ -364,7 +364,7 @@ func testLoaderKillEngine(t *testing.T) { func testLoaderPopulateDataForCustomSep(t *testing.T) { fileName := utils.Attributes tmpFilePath := path.Join("/tmp/", fileName) - if err := ioutil.WriteFile(tmpFilePath, []byte(customAttributes), 0777); err != nil { + if err := os.WriteFile(tmpFilePath, []byte(customAttributes), 0777); err != nil { t.Fatal(err.Error()) } if err := os.MkdirAll("/tmp/customSepLoaderIn", 0755); err != nil { @@ -410,7 +410,7 @@ func testLoaderCheckForCustomSep(t *testing.T) { func testLoaderVerifyOutDirForCustomSep(t *testing.T) { time.Sleep(100 * time.Millisecond) - if outContent1, err := ioutil.ReadFile(path.Join("/tmp/customSepLoaderOut", utils.Attributes)); err != nil { + if outContent1, err := os.ReadFile(path.Join("/tmp/customSepLoaderOut", utils.Attributes)); err != nil { t.Error(err) } else if customAttributes != string(outContent1) { t.Errorf("Expecting: %q, received: %q", customAttributes, string(outContent1)) @@ -430,7 +430,7 @@ func testLoadFromFilesCsvActionProfile(t *testing.T) { #Tenant[0],ID[1] cgrates.org,SET_ACTPROFILE_3 `)) - content, err := ioutil.ReadFile(path.Join(flPath, "ActionProfiles.csv")) + content, err := os.ReadFile(path.Join(flPath, "ActionProfiles.csv")) if err != nil { t.Error(err) } @@ -462,7 +462,7 @@ cgrates.org,SET_ACTPROFILE_3 }, } - rdr := ioutil.NopCloser(strings.NewReader(string(content))) + rdr := io.NopCloser(strings.NewReader(string(content))) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -494,7 +494,7 @@ cgrates.org,SET_ACTPROFILE_3 //checking the error by adding a caching method ldr.connMgr = engine.NewConnManager(config.NewDefaultCGRConfig(), nil) ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(string(content))) + rdr = io.NopCloser(strings.NewReader(string(content))) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -556,7 +556,7 @@ func testProcessFolderRemoveContent(t *testing.T) { #Tenant[0],ID[1] cgrates.org,SET_ACTPROFILE_3 `)) - content, err := ioutil.ReadFile(path.Join(flPath, "ActionProfiles.csv")) + content, err := os.ReadFile(path.Join(flPath, "ActionProfiles.csv")) if err != nil { t.Error(err) } @@ -588,7 +588,7 @@ cgrates.org,SET_ACTPROFILE_3 }, } - rdr := ioutil.NopCloser(strings.NewReader(string(content))) + rdr := io.NopCloser(strings.NewReader(string(content))) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -621,7 +621,7 @@ cgrates.org,SET_ACTPROFILE_3 //checking the error by adding a caching method ldr.cacheConns = []string{utils.MetaInternal} - rdr = ioutil.NopCloser(strings.NewReader(string(content))) + rdr = io.NopCloser(strings.NewReader(string(content))) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -790,7 +790,7 @@ cgrates.org,NewRes1 #Tenant[0],ID[1] cgrates.org,NewRes1 ` - rdr := ioutil.NopCloser(strings.NewReader(resCsv)) + rdr := io.NopCloser(strings.NewReader(resCsv)) ldr.rdrs = map[string]map[string]*openedCSVFile{ utils.MetaResources: { @@ -950,7 +950,7 @@ func testProcessFileUnableToOpen(t *testing.T) { #Tenant[0],ID[1] cgrates.org,NewRes1 ` - rdr := ioutil.NopCloser(strings.NewReader(resCsv)) + rdr := io.NopCloser(strings.NewReader(resCsv)) ldr.rdrs = map[string]map[string]*openedCSVFile{ utils.MetaResources: { @@ -1007,7 +1007,7 @@ func testProcessFileRenameError(t *testing.T) { #Tenant[0],ID[1] cgrates.org,NewRes1 ` - rdr := ioutil.NopCloser(strings.NewReader(resCsv)) + rdr := io.NopCloser(strings.NewReader(resCsv)) ldr.rdrs = map[string]map[string]*openedCSVFile{ utils.MetaResources: { diff --git a/loaders/loader_test.go b/loaders/loader_test.go index 78eaca966..b402bdd0a 100644 --- a/loaders/loader_test.go +++ b/loaders/loader_test.go @@ -20,7 +20,7 @@ package loaders import ( "encoding/csv" - "io/ioutil" + "io" "reflect" "sort" "strings" @@ -91,7 +91,7 @@ func TestLoaderProcessContentSingleFile(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.AttributesCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.AttributesCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -108,7 +108,7 @@ func TestLoaderProcessContentSingleFile(t *testing.T) { //processContent successfully when dryrun is false ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(engine.AttributesCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.AttributesCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -157,7 +157,7 @@ func TestLoaderProcessContentSingleFile(t *testing.T) { //cannot set AttributeProfile when dataManager is nil ldr.dm = nil ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(engine.AttributesCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.AttributesCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -211,10 +211,10 @@ func TestLoaderProcessContentMultiFiles(t *testing.T) { Value: config.NewRSRParsersMustCompile("10", utils.InfieldSep)}, }, } - rdr1 := ioutil.NopCloser(strings.NewReader(file1CSV)) + rdr1 := io.NopCloser(strings.NewReader(file1CSV)) csvRdr1 := csv.NewReader(rdr1) csvRdr1.Comment = '#' - rdr2 := ioutil.NopCloser(strings.NewReader(file2CSV)) + rdr2 := io.NopCloser(strings.NewReader(file2CSV)) csvRdr2 := csv.NewReader(rdr2) csvRdr2.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -310,7 +310,7 @@ func TestLoaderProcessResource(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.ResourcesCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.ResourcesCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -408,7 +408,7 @@ func TestLoaderProcessFilters(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.5", utils.InfieldSep)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.FiltersCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.FiltersCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -425,7 +425,7 @@ func TestLoaderProcessFilters(t *testing.T) { //processContent when dryrun is false ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(engine.FiltersCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.FiltersCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -571,7 +571,7 @@ func TestLoaderProcessThresholds(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.ThresholdsCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.ThresholdsCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -612,7 +612,7 @@ func TestLoaderProcessThresholds(t *testing.T) { //cannot set thresholdProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.ThresholdsCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.ThresholdsCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -692,7 +692,7 @@ func TestLoaderProcessStats(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.12", utils.InfieldSep)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.StatsCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.StatsCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -748,7 +748,7 @@ func TestLoaderProcessStats(t *testing.T) { //cannot set statsProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.StatsCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.StatsCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -785,7 +785,7 @@ func TestLoaderProcessStatsWrongMetrics(t *testing.T) { #Metrics[0],Stored[1] not_a_valid_metric_type,true, ` - rdr := ioutil.NopCloser(strings.NewReader(statsCsv)) + rdr := io.NopCloser(strings.NewReader(statsCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -806,7 +806,7 @@ not_a_valid_metric_type,true, #Metrics[0],Stored[1] *sum#~*req.Value,false ` - rdr = ioutil.NopCloser(strings.NewReader(statsCsv)) + rdr = io.NopCloser(strings.NewReader(statsCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -900,7 +900,7 @@ func TestLoaderProcessRoutes(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.15", utils.InfieldSep)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.RoutesCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.RoutesCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -980,7 +980,7 @@ func TestLoaderProcessRoutes(t *testing.T) { //cannot set RoutesProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.RoutesCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.RoutesCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1019,7 +1019,7 @@ func TestLoaderProcessAccountProfiles(t *testing.T) { #Tenant[0],ID[1] cgrates.org,ACTPRF_ID1 ` - rdr := ioutil.NopCloser(strings.NewReader(actPrflCsv)) + rdr := io.NopCloser(strings.NewReader(actPrflCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1036,7 +1036,7 @@ cgrates.org,ACTPRF_ID1 //cannot set an AccountProfile while dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(actPrflCsv)) + rdr = io.NopCloser(strings.NewReader(actPrflCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1094,7 +1094,7 @@ func TestLoaderProcessChargers(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.6", utils.InfieldSep)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.ChargersCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.ChargersCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1130,7 +1130,7 @@ func TestLoaderProcessChargers(t *testing.T) { //cannot set chargerProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.ChargersCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.ChargersCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1235,7 +1235,7 @@ func TestLoaderProcessDispatches(t *testing.T) { }, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.DispatcherCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.DispatcherCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1295,7 +1295,7 @@ func TestLoaderProcessDispatches(t *testing.T) { //cannot set DispatchersProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.DispatcherCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.DispatcherCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1356,7 +1356,7 @@ func TestLoaderProcessDispatcheHosts(t *testing.T) { }, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.DispatcherHostCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.DispatcherHostCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1395,7 +1395,7 @@ func TestLoaderProcessDispatcheHosts(t *testing.T) { //cannot set DispatcherHostProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.DispatcherHostCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.DispatcherHostCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1434,7 +1434,7 @@ func TestLoaderRemoveContentSingleFile(t *testing.T) { Mandatory: true}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.AttributesCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.AttributesCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1502,7 +1502,7 @@ func TestLoaderRemoveContentSingleFile(t *testing.T) { //cannot remove when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.AttributesCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.AttributesCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1601,7 +1601,7 @@ func TestLoaderProcessRateProfile(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.17", utils.InfieldSep)}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.RateProfileCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.RateProfileCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1712,7 +1712,7 @@ func TestLoaderProcessRateProfile(t *testing.T) { //cannot set RateProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.RateProfileCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.RateProfileCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1823,7 +1823,7 @@ cgrates.org,RP1,,,,,,,RT_WEEK,,,,,1m,,0.06,1m,1s cgrates.org,RP1,,,,,,,RT_WEEKEND,,"* * * * 0,6",;10,false,0s,,0.06,1m,1s cgrates.org,RP1,,,,,,,RT_CHRISTMAS,,* * 24 12 *,;30,false,0s,,0.06,1m,1s ` - rdr1 := ioutil.NopCloser(strings.NewReader(ratePrfCnt1)) + rdr1 := io.NopCloser(strings.NewReader(ratePrfCnt1)) csvRdr1 := csv.NewReader(rdr1) csvRdr1.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -1896,7 +1896,7 @@ cgrates.org,RP1,,,,,,,RT_CHRISTMAS,,* * 24 12 *,;30,false,0s,,0.06,1m,1s t.Errorf("expecting: %+v,\n received: %+v", utils.ToJSON(eRatePrf), utils.ToJSON(rcv)) } - rdr2 := ioutil.NopCloser(strings.NewReader(ratePrfCnt2)) + rdr2 := io.NopCloser(strings.NewReader(ratePrfCnt2)) csvRdr2 := csv.NewReader(rdr2) csvRdr2.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2160,7 +2160,7 @@ cgrates.org,RP1,RT_WEEKEND cgrates.org,RP2,RT_WEEKEND;RT_CHRISTMAS cgrates.org,RP1, ` - rdr1 := ioutil.NopCloser(strings.NewReader(ratePrfCnt1)) + rdr1 := io.NopCloser(strings.NewReader(ratePrfCnt1)) csvRdr1 := csv.NewReader(rdr1) csvRdr1.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2231,7 +2231,7 @@ cgrates.org,RP1, t.Errorf("expecting: %+v,\n received: %+v", utils.ToJSON(eRatePrf), utils.ToJSON(rcv)) } - rdr2 := ioutil.NopCloser(strings.NewReader(ratePrfCnt2)) + rdr2 := io.NopCloser(strings.NewReader(ratePrfCnt2)) csvRdr2 := csv.NewReader(rdr2) csvRdr2.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2347,7 +2347,7 @@ cgrates.org,RP2 t.Error(err) } - rdr1 := ioutil.NopCloser(strings.NewReader(ratePrfCnt1)) + rdr1 := io.NopCloser(strings.NewReader(ratePrfCnt1)) csvRdr1 := csv.NewReader(rdr1) csvRdr1.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2517,7 +2517,7 @@ func TestLoaderActionProfile(t *testing.T) { Layout: time.RFC3339}, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.ActionProfileCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.ActionProfileCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2600,7 +2600,7 @@ func TestLoaderActionProfile(t *testing.T) { //cannot set ActionProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(engine.ActionProfileCSVContent)) + rdr = io.NopCloser(strings.NewReader(engine.ActionProfileCSVContent)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2713,7 +2713,7 @@ cgrates.org,ONE_TIME_ACT,,,,,,SET_BALANCE_TEST_VOICE,,false,0s,*set_balance,,*ba cgrates.org,ONE_TIME_ACT,,,,,,TOPUP_TEST_VOICE,,false,0s,*add_balance,,*balance.TestVoiceBalance.Value,15m15s ` - rdr := ioutil.NopCloser(strings.NewReader(newCSVContentMiss)) + rdr := io.NopCloser(strings.NewReader(newCSVContentMiss)) csvRdr := csv.NewReader(rdr) ldr.rdrs = map[string]map[string]*openedCSVFile{ utils.MetaActionProfiles: { @@ -2738,7 +2738,7 @@ cgrates.org,ONE_TIME_ACT,,,,,,TOPUP_TEST_DATA,,false,0s,*add_balance,,*balance.T cgrates.org,ONE_TIME_ACT,,,,,,SET_BALANCE_TEST_VOICE,,false,0s,*set_balance,,*balance.TestVoiceBalance.Type,*voice cgrates.org,ONE_TIME_ACT,,,,,,TOPUP_TEST_VOICE,,false,0s,*add_balance,,*balance.TestVoiceBalance.Value,15m15s ` - rdr = ioutil.NopCloser(strings.NewReader(newCSVContent)) + rdr = io.NopCloser(strings.NewReader(newCSVContent)) csvRdr = csv.NewReader(rdr) ldr.rdrs = map[string]map[string]*openedCSVFile{ utils.MetaActionProfiles: { @@ -2788,7 +2788,7 @@ func TestLoaderActionProfileAsStructErrType(t *testing.T) { #Tenant,ID,ActionBlocker cgrates.org,12,NOT_A_BOOLEAN ` - rdr := ioutil.NopCloser(strings.NewReader(actPrfCsv)) + rdr := io.NopCloser(strings.NewReader(actPrfCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2824,7 +2824,7 @@ func TestLoaderActionProfileAsStructErrTConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(actPrfCsv)) + rdr := io.NopCloser(strings.NewReader(actPrfCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2858,7 +2858,7 @@ func TestLoaderAttributesAsStructErrType(t *testing.T) { #Weight true ` - rdr := ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr := io.NopCloser(strings.NewReader(attributeCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2892,7 +2892,7 @@ func TestLoaderAttributesAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(attributeCsv)) + rdr := io.NopCloser(strings.NewReader(attributeCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2926,7 +2926,7 @@ func TestLoadResourcesAsStructErrType(t *testing.T) { #Blocker NOT_A_BOOLEAN ` - rdr := ioutil.NopCloser(strings.NewReader(resourcesCsv)) + rdr := io.NopCloser(strings.NewReader(resourcesCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2960,7 +2960,7 @@ func TestLoadResourcesAsStructErrConversion(t *testing.T) { #UsageTTL 12ss ` - rdr := ioutil.NopCloser(strings.NewReader(resourcesCsv)) + rdr := io.NopCloser(strings.NewReader(resourcesCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -2994,7 +2994,7 @@ func TestLoadFiltersAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(filtersCsv)) + rdr := io.NopCloser(strings.NewReader(filtersCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3032,7 +3032,7 @@ func TestLoadFiltersAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(filtersCsv)) + rdr := io.NopCloser(strings.NewReader(filtersCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3070,7 +3070,7 @@ func TestLoadStatsAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(statsCsv)) + rdr := io.NopCloser(strings.NewReader(statsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3108,7 +3108,7 @@ func TestLoadStatsAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(statsCsv)) + rdr := io.NopCloser(strings.NewReader(statsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3146,7 +3146,7 @@ func TestLoadThresholdsAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3184,7 +3184,7 @@ func TestLoadThresholdsAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3222,7 +3222,7 @@ func TestLoadRoutesAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3260,7 +3260,7 @@ func TestLoadRoutesAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3298,7 +3298,7 @@ func TestLoadChargersAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3336,7 +3336,7 @@ func TestLoadChargersAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3374,7 +3374,7 @@ func TestLoadDispatchersAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3412,7 +3412,7 @@ func TestLoadDispatcherAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3450,7 +3450,7 @@ func TestLoadDispatcherHostsAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3488,7 +3488,7 @@ func TestLoadRateProfilesAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3526,7 +3526,7 @@ func TestLoadRateProfilesAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3564,7 +3564,7 @@ func TestLoadAccountProfilesAsStructErrConversion(t *testing.T) { #ActivationInterval * * * * * * * ` - rdr := ioutil.NopCloser(strings.NewReader(actPrfCsv)) + rdr := io.NopCloser(strings.NewReader(actPrfCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3615,7 +3615,7 @@ func TestProcessContentAccountProfileAsTPError(t *testing.T) { #Tenant,ID,BalanceID,BalanceUnitFactors cgrates.org,1001,MonetaryBalance,fltr1&fltr2;100;fltr3 ` - rdr := ioutil.NopCloser(strings.NewReader(accPrfCSv)) + rdr := io.NopCloser(strings.NewReader(accPrfCSv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3653,7 +3653,7 @@ func TestLoadAccountProfilesAsStructErrType(t *testing.T) { #PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(actPrfCsv)) + rdr := io.NopCloser(strings.NewReader(actPrfCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3698,7 +3698,7 @@ func TestLoadAndRemoveResources(t *testing.T) { #Tenant[0],ID[1] cgrates.org,NewRes1 ` - rdr := ioutil.NopCloser(strings.NewReader(resourcesCSV)) + rdr := io.NopCloser(strings.NewReader(resourcesCSV)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3718,7 +3718,7 @@ cgrates.org,NewRes1 ldr.dryRun = false //reinitialized reader because after first process the reader is at the end of the file - rdr = ioutil.NopCloser(strings.NewReader(resourcesCSV)) + rdr = io.NopCloser(strings.NewReader(resourcesCSV)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3750,7 +3750,7 @@ cgrates.org,NewRes1 } //reinitialized reader because seeker it s at the end of the file - rdr = ioutil.NopCloser(strings.NewReader(resourcesCSV)) + rdr = io.NopCloser(strings.NewReader(resourcesCSV)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3767,7 +3767,7 @@ cgrates.org,NewRes1 //remove successfully when dryrun is false ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(resourcesCSV)) + rdr = io.NopCloser(strings.NewReader(resourcesCSV)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3791,7 +3791,7 @@ cgrates.org,NewRes1 //cannot set again ResourceProfile when dataManager is nil ldr.dm = nil - rdr = ioutil.NopCloser(strings.NewReader(resourcesCSV)) + rdr = io.NopCloser(strings.NewReader(resourcesCSV)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3831,7 +3831,7 @@ func TestRemoveFilterContent(t *testing.T) { #Tenant[0],ID[0] cgrates.org,FILTERS_REM_1 ` - rdr := ioutil.NopCloser(strings.NewReader(filtersCsv)) + rdr := io.NopCloser(strings.NewReader(filtersCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3861,7 +3861,7 @@ cgrates.org,FILTERS_REM_1 //cannot remove Filter when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(filtersCsv)) + rdr = io.NopCloser(strings.NewReader(filtersCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3880,7 +3880,7 @@ cgrates.org,FILTERS_REM_1 //cannot set again FiltersProfile when dataManager is nil ldr.dm = nil ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(filtersCsv)) + rdr = io.NopCloser(strings.NewReader(filtersCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3924,7 +3924,7 @@ func TestRemoveStatsContent(t *testing.T) { #Tenant[0],ProfileID[1] cgrates.org,REM_STATS_1 ` - rdr := ioutil.NopCloser(strings.NewReader(statsCsv)) + rdr := io.NopCloser(strings.NewReader(statsCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3954,7 +3954,7 @@ cgrates.org,REM_STATS_1 //cannot remove statsQueueProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(statsCsv)) + rdr = io.NopCloser(strings.NewReader(statsCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -3973,7 +3973,7 @@ cgrates.org,REM_STATS_1 //cannot set again StatsProfile when dataManager is nil ldr.dm = nil ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(statsCsv)) + rdr = io.NopCloser(strings.NewReader(statsCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4017,7 +4017,7 @@ func TestRemoveThresholdsContent(t *testing.T) { #Tenant[0],ID[1] cgrates.org,REM_THRESHOLDS_1, ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4047,7 +4047,7 @@ cgrates.org,REM_THRESHOLDS_1, //cannot remove statsQueueProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr = io.NopCloser(strings.NewReader(thresholdsCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4066,7 +4066,7 @@ cgrates.org,REM_THRESHOLDS_1, //cannot set again ThresholdsProfile when dataManager is nil ldr.dm = nil ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr = io.NopCloser(strings.NewReader(thresholdsCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4110,7 +4110,7 @@ func TestRemoveRoutesContent(t *testing.T) { #Tenant[0],ID[1] cgrates.org,ROUTES_REM_1 ` - rdr := ioutil.NopCloser(strings.NewReader(routesCsv)) + rdr := io.NopCloser(strings.NewReader(routesCsv)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4140,7 +4140,7 @@ cgrates.org,ROUTES_REM_1 //cannot remove routeProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(routesCsv)) + rdr = io.NopCloser(strings.NewReader(routesCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4159,7 +4159,7 @@ cgrates.org,ROUTES_REM_1 //cannot set again RoutesProfile when dataManager is nil ldr.dm = nil ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(routesCsv)) + rdr = io.NopCloser(strings.NewReader(routesCsv)) rdrCsv = csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4203,7 +4203,7 @@ func TestRemoveChargersContent(t *testing.T) { #Tenant[0],ID[1] cgrates.org,REM_ROUTES_1 ` - rdr := ioutil.NopCloser(strings.NewReader(routesCsv)) + rdr := io.NopCloser(strings.NewReader(routesCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4232,7 +4232,7 @@ cgrates.org,REM_ROUTES_1 //cannot remove ChargersProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(routesCsv)) + rdr = io.NopCloser(strings.NewReader(routesCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4251,8 +4251,8 @@ cgrates.org,REM_ROUTES_1 //cannot set again ChargersProfile when dataManager is nil ldr.dm = nil ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(routesCsv)) - rdr = ioutil.NopCloser(strings.NewReader(routesCsv)) + rdr = io.NopCloser(strings.NewReader(routesCsv)) + rdr = io.NopCloser(strings.NewReader(routesCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4296,7 +4296,7 @@ func TestRemoveDispatchersContent(t *testing.T) { #Tenant[0],ID[1] cgrates.org,REM_DISPATCHERS_1 ` - rdr := ioutil.NopCloser(strings.NewReader(dispatchersCsv)) + rdr := io.NopCloser(strings.NewReader(dispatchersCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4325,7 +4325,7 @@ cgrates.org,REM_DISPATCHERS_1 //cannot remove DispatchersProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(dispatchersCsv)) + rdr = io.NopCloser(strings.NewReader(dispatchersCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4344,7 +4344,7 @@ cgrates.org,REM_DISPATCHERS_1 //cannot set again DispatchersProfile when dataManager is nil ldr.dm = nil ldr.dryRun = false - rdr = ioutil.NopCloser(strings.NewReader(dispatchersCsv)) + rdr = io.NopCloser(strings.NewReader(dispatchersCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4388,7 +4388,7 @@ func TestRemoveDispatcherHostsContent(t *testing.T) { #Tenant[0],ID[1] cgrates.org,REM_DISPATCHERH_1 ` - rdr := ioutil.NopCloser(strings.NewReader(dispatchersHostsCsv)) + rdr := io.NopCloser(strings.NewReader(dispatchersHostsCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4419,7 +4419,7 @@ cgrates.org,REM_DISPATCHERH_1 //cannot remove DispatcherHosts when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(dispatchersHostsCsv)) + rdr = io.NopCloser(strings.NewReader(dispatchersHostsCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4479,7 +4479,7 @@ func TestProcessContentEmptyDataBase(t *testing.T) { }, }, } - rdr := ioutil.NopCloser(strings.NewReader(engine.DispatcherHostCSVContent)) + rdr := io.NopCloser(strings.NewReader(engine.DispatcherHostCSVContent)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4523,7 +4523,7 @@ func TestRemoveRateProfileContent(t *testing.T) { #Tenant[0],ID[1] cgrates.org,REM_RATEPROFILE_1 ` - rdr := ioutil.NopCloser(strings.NewReader(rtPrfCsv)) + rdr := io.NopCloser(strings.NewReader(rtPrfCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4552,7 +4552,7 @@ cgrates.org,REM_RATEPROFILE_1 //cannot remove DispatcherHosts when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(rtPrfCsv)) + rdr = io.NopCloser(strings.NewReader(rtPrfCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4574,7 +4574,7 @@ cgrates.org,REM_RATEPROFILE_1 utils.MetaPartial: nil, }, } - rdr = ioutil.NopCloser(strings.NewReader(rtPrfCsv)) + rdr = io.NopCloser(strings.NewReader(rtPrfCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4618,7 +4618,7 @@ cgrates.org,REM_ACTPROFILE_1 ` //cannot set ActionProfile when dataManager is nil ldr.dm = nil - rdr := ioutil.NopCloser(strings.NewReader(actPrfCsv)) + rdr := io.NopCloser(strings.NewReader(actPrfCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4654,7 +4654,7 @@ cgrates.org,REM_ACTPROFILE_1 //cannot remove DispatcherHosts when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(actPrfCsv)) + rdr = io.NopCloser(strings.NewReader(actPrfCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4697,7 +4697,7 @@ func TestRemoveAccountProfileContent(t *testing.T) { #Tenant[0],ID[1] cgrates.org,REM_ACTPROFILE_1 ` - rdr := ioutil.NopCloser(strings.NewReader(acntPrfCsv)) + rdr := io.NopCloser(strings.NewReader(acntPrfCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4733,7 +4733,7 @@ cgrates.org,REM_ACTPROFILE_1 //cannot remove AccountProfile when dryrun is true ldr.dryRun = true - rdr = ioutil.NopCloser(strings.NewReader(acntPrfCsv)) + rdr = io.NopCloser(strings.NewReader(acntPrfCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4778,7 +4778,7 @@ func TestRemoveContentError1(t *testing.T) { //Tenant[0] cgrates.org,REM_ACTPROFILE_s ` - rdr := ioutil.NopCloser(strings.NewReader(actPrfCsv)) + rdr := io.NopCloser(strings.NewReader(actPrfCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4830,7 +4830,7 @@ func TestRemoveContentError2(t *testing.T) { Tenant[0],ID[1] cgrates.org,REM_ACTPROFILE_s ` - rdr := ioutil.NopCloser(strings.NewReader(actPrfCsv)) + rdr := io.NopCloser(strings.NewReader(actPrfCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4908,7 +4908,7 @@ func TestRemoveRateProfileRatesError(t *testing.T) { #Tenant[0],ID[1],RateIDs[2] cgrates.org,REM_RATEPROFILE_1,RT_WEEKEND ` - rdr := ioutil.NopCloser(strings.NewReader(rtPrfCsv)) + rdr := io.NopCloser(strings.NewReader(rtPrfCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4931,7 +4931,7 @@ cgrates.org,REM_RATEPROFILE_1,RT_WEEKEND t.Errorf("Expected %+v, received %+v", utils.ToJSON(expected), utils.ToJSON(err)) } - rdr = ioutil.NopCloser(strings.NewReader(rtPrfCsv)) + rdr = io.NopCloser(strings.NewReader(rtPrfCsv)) csvRdr = csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -4988,7 +4988,7 @@ func TestRemoveThresholdsMockError(t *testing.T) { #Tenant[0],ID[1] cgrates.org,REM_THRESHOLDS_1, ` - rdr := ioutil.NopCloser(strings.NewReader(thresholdsCsv)) + rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -5047,7 +5047,7 @@ func TestRemoveStatQueueMockError(t *testing.T) { #Tenant[0],ProfileID[1] cgrates.org,REM_STATS_1 ` - rdr := ioutil.NopCloser(strings.NewReader(statsCsv)) + rdr := io.NopCloser(strings.NewReader(statsCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ @@ -5105,7 +5105,7 @@ func TestRemoveResourcesMockError(t *testing.T) { #Tenant[0],ID[1] cgrates.org,NewRes1 ` - rdr := ioutil.NopCloser(strings.NewReader(resourcesCSV)) + rdr := io.NopCloser(strings.NewReader(resourcesCSV)) rdrCsv := csv.NewReader(rdr) rdrCsv.Comment = '#' ldr.rdrs = map[string]map[string]*openedCSVFile{ diff --git a/loaders/loaders_it_test.go b/loaders/loaders_it_test.go index 1d75b360e..b6321f50e 100644 --- a/loaders/loaders_it_test.go +++ b/loaders/loaders_it_test.go @@ -22,7 +22,7 @@ package loaders import ( "encoding/csv" - "io/ioutil" + "io" "os" "path" "reflect" @@ -104,7 +104,7 @@ cgrates.org,NewRes1 #Tenant[0],ID[1] cgrates.org,NewRes1 ` - rdr := ioutil.NopCloser(strings.NewReader(resCsv)) + rdr := io.NopCloser(strings.NewReader(resCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldrs.ldrs["testV1LoadResource"].rdrs = map[string]map[string]*openedCSVFile{ @@ -269,7 +269,7 @@ NOT_UINT //PK NOT_UINT ` - rdr := ioutil.NopCloser(strings.NewReader(resCsv)) + rdr := io.NopCloser(strings.NewReader(resCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldrs.ldrs["testV1LoadResource"].rdrs = map[string]map[string]*openedCSVFile{ @@ -345,7 +345,7 @@ cgrates.org,NewRes1 #Tenant[0],ID[1] cgrates.org,NewRes1 ` - rdr := ioutil.NopCloser(strings.NewReader(resCsv)) + rdr := io.NopCloser(strings.NewReader(resCsv)) csvRdr := csv.NewReader(rdr) csvRdr.Comment = '#' ldrs.ldrs["testV1RemoveResource"].rdrs = map[string]map[string]*openedCSVFile{ diff --git a/registrarc/libregistrarc_test.go b/registrarc/libregistrarc_test.go index 4c3f8f15d..338ebe19a 100644 --- a/registrarc/libregistrarc_test.go +++ b/registrarc/libregistrarc_test.go @@ -22,7 +22,6 @@ import ( "bytes" "encoding/json" "io" - "io/ioutil" "net/http" "net/http/httptest" "reflect" @@ -249,18 +248,18 @@ func TestRegister(t *testing.T) { } errCfg.CacheCfg().ReplicationConns = []string{"errCon"} engine.Cache = engine.NewCacheS(errCfg, nil, nil) - req.Body = ioutil.NopCloser(bytes.NewBuffer(uargsJSON)) + req.Body = io.NopCloser(bytes.NewBuffer(uargsJSON)) if _, err := register(req); err != utils.ErrPartiallyExecuted { t.Errorf("Expected error: %s ,received: %v", utils.ErrPartiallyExecuted, err) } - req.Body = ioutil.NopCloser(bytes.NewBuffer(argsJSON)) + req.Body = io.NopCloser(bytes.NewBuffer(argsJSON)) if _, err := register(req); err != utils.ErrPartiallyExecuted { t.Errorf("Expected error: %s ,received: %v", utils.ErrPartiallyExecuted, err) } req.RemoteAddr = "127.0.0" - req.Body = ioutil.NopCloser(bytes.NewBuffer(argsJSON)) + req.Body = io.NopCloser(bytes.NewBuffer(argsJSON)) if _, err := register(req); err == nil { t.Errorf("Expected error,received: nil") } @@ -269,7 +268,7 @@ func TestRegister(t *testing.T) { if err != nil { t.Fatal(err) } - req.Body = ioutil.NopCloser(bytes.NewBuffer(args2JSON)) + req.Body = io.NopCloser(bytes.NewBuffer(args2JSON)) if _, err := register(req); err == nil { t.Errorf("Expected error,received: nil") } @@ -278,7 +277,7 @@ func TestRegister(t *testing.T) { if err != nil { t.Fatal(err) } - req.Body = ioutil.NopCloser(bytes.NewBuffer(args2JSON)) + req.Body = io.NopCloser(bytes.NewBuffer(args2JSON)) if _, err := register(req); err == nil { t.Errorf("Expected error,received: nil") } @@ -287,7 +286,7 @@ func TestRegister(t *testing.T) { if err != nil { t.Fatal(err) } - req.Body = ioutil.NopCloser(bytes.NewBuffer(args2JSON)) + req.Body = io.NopCloser(bytes.NewBuffer(args2JSON)) if _, err := register(req); err == nil { t.Errorf("Expected error,received: nil") } @@ -296,11 +295,11 @@ func TestRegister(t *testing.T) { if err != nil { t.Fatal(err) } - req.Body = ioutil.NopCloser(bytes.NewBuffer(args2JSON)) + req.Body = io.NopCloser(bytes.NewBuffer(args2JSON)) if _, err := register(req); err == nil { t.Errorf("Expected error,received: nil") } - req.Body = ioutil.NopCloser(bytes.NewBuffer(argsJSON)) + req.Body = io.NopCloser(bytes.NewBuffer(argsJSON)) if _, err := register(req); err == nil { t.Errorf("Expected error,received: nil") } @@ -309,7 +308,7 @@ func TestRegister(t *testing.T) { if err != nil { t.Fatal(err) } - req.Body = ioutil.NopCloser(bytes.NewBuffer(args2JSON)) + req.Body = io.NopCloser(bytes.NewBuffer(args2JSON)) if _, err := register(req); err == nil { t.Errorf("Expected error,received: nil") } @@ -318,7 +317,7 @@ func TestRegister(t *testing.T) { if err != nil { t.Fatal(err) } - req.Body = ioutil.NopCloser(bytes.NewBuffer(args2JSON)) + req.Body = io.NopCloser(bytes.NewBuffer(args2JSON)) if _, err := register(req); err == nil { t.Errorf("Expected error,received: nil") } diff --git a/services/loaders_it_test.go b/services/loaders_it_test.go index fafbdc8e8..090be3d03 100644 --- a/services/loaders_it_test.go +++ b/services/loaders_it_test.go @@ -20,7 +20,6 @@ along with this program. If not, see package services import ( - "io/ioutil" "os" "path" "sync" @@ -46,7 +45,7 @@ func testCreateDirs(t *testing.T) { t.Fatal("Error creating folder: ", dir, err) } } - if err := ioutil.WriteFile(path.Join("/tmp/In", utils.AttributesCsv), []byte(engine.AttributesCSVContent), 0644); err != nil { + if err := os.WriteFile(path.Join("/tmp/In", utils.AttributesCsv), []byte(engine.AttributesCSVContent), 0644); err != nil { t.Fatal(err.Error()) } } diff --git a/services/sessions_it_test.go b/services/sessions_it_test.go index 3bc00435f..c386ac4e9 100644 --- a/services/sessions_it_test.go +++ b/services/sessions_it_test.go @@ -21,7 +21,7 @@ package services import ( "fmt" - "io/ioutil" + "io" "log" "sync" "testing" @@ -36,7 +36,7 @@ import ( ) func init() { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) } type testMockClients struct { diff --git a/sessions/sessionscover_test.go b/sessions/sessionscover_test.go index 6a7cb6f64..6cc35c04a 100644 --- a/sessions/sessionscover_test.go +++ b/sessions/sessionscover_test.go @@ -21,7 +21,7 @@ package sessions import ( "bytes" "fmt" - "io/ioutil" + "io" "log" "os" "reflect" @@ -36,7 +36,7 @@ import ( ) func TestSetSTerminator(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() cfg.SessionSCfg().SessionTTL = time.Second data := engine.NewInternalDB(nil, nil, true) @@ -105,7 +105,7 @@ func TestSetSTerminator(t *testing.T) { } func TestSetSTerminatorError(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() cfg.SessionSCfg().SessionTTL = time.Second data := engine.NewInternalDB(nil, nil, true) @@ -203,7 +203,7 @@ func TestSetSTerminatorError(t *testing.T) { } func TestSetSTerminatorAutomaticTermination(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) ss := &Session{} cfg := config.NewDefaultCGRConfig() @@ -225,7 +225,7 @@ func TestSetSTerminatorAutomaticTermination(t *testing.T) { } func TestSetSTerminatorManualTermination(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) ss := &Session{} cfg := config.NewDefaultCGRConfig() @@ -242,7 +242,7 @@ func TestSetSTerminatorManualTermination(t *testing.T) { } func TestForceSTerminatorManualTermination(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) ss := &Session{ CGRID: "CGRID", Tenant: "cgrates.org", @@ -275,7 +275,7 @@ func TestForceSTerminatorManualTermination(t *testing.T) { } func TestForceSTerminatorPostCDRs(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() cfg.SessionSCfg().CDRsConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCDRs)} data := engine.NewInternalDB(nil, nil, true) @@ -312,7 +312,7 @@ func TestForceSTerminatorPostCDRs(t *testing.T) { } func TestForceSTerminatorReleaseSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() cfg.SessionSCfg().ResSConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaResources)} data := engine.NewInternalDB(nil, nil, true) @@ -358,7 +358,7 @@ func (sT *testMockClientConn) Call(method string, arg interface{}, rply interfac } func TestForceSTerminatorClientCall(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) sTestMock := &testMockClientConn{} cfg := config.NewDefaultCGRConfig() @@ -401,7 +401,7 @@ func TestForceSTerminatorClientCall(t *testing.T) { } func TestDebitSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) dm := engine.NewDataManager(data, cfg.CacheCfg(), nil) @@ -463,7 +463,7 @@ func (sT *testMockClients) Call(method string, arg interface{}, rply interface{} } func TestDebitSessionResponderMaxDebit(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -536,7 +536,7 @@ func TestDebitSessionResponderMaxDebit(t *testing.T) { } func TestDebitSessionResponderMaxDebitError(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) sMock := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -609,7 +609,7 @@ func TestDebitSessionResponderMaxDebitError(t *testing.T) { } func TestInitSessionDebitLoops(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) dm := engine.NewDataManager(data, cfg.CacheCfg(), nil) @@ -652,7 +652,7 @@ func (sT *testMockClientConnDiscSess) Call(method string, arg interface{}, rply } func TestDebitLoopSessionErrorDebiting(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() cfg.GeneralCfg().NodeID = "ClientConnIdtest" cfg.SessionSCfg().TerminateAttempts = 1 @@ -719,7 +719,7 @@ func TestDebitLoopSessionErrorDebiting(t *testing.T) { } func TestDebitLoopSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -781,7 +781,7 @@ func TestDebitLoopSession(t *testing.T) { } func TestDebitLoopSessionFrcDiscLowerDbtInterval(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -843,7 +843,7 @@ func TestDebitLoopSessionFrcDiscLowerDbtInterval(t *testing.T) { } func TestDebitLoopSessionLowBalance(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -901,7 +901,7 @@ func TestDebitLoopSessionLowBalance(t *testing.T) { } func TestDebitLoopSessionWarningSessions(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -957,7 +957,7 @@ func TestDebitLoopSessionWarningSessions(t *testing.T) { } func TestDebitLoopSessionDisconnectSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -1027,7 +1027,7 @@ func TestDebitLoopSessionDisconnectSession(t *testing.T) { } func TestStoreSCost(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -1075,7 +1075,7 @@ func TestStoreSCost(t *testing.T) { } func TestRefundSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -1187,7 +1187,7 @@ func TestRefundSession(t *testing.T) { } func TestRoundCost(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -1261,7 +1261,7 @@ func TestRoundCost(t *testing.T) { } func TestDisconnectSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) dm := engine.NewDataManager(data, cfg.CacheCfg(), nil) @@ -1299,7 +1299,7 @@ func TestDisconnectSession(t *testing.T) { } func TestReplicateSessions(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -1325,7 +1325,7 @@ func TestReplicateSessions(t *testing.T) { } func TestNewSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) testMock1 := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -1425,7 +1425,7 @@ func TestNewSession(t *testing.T) { } func TestProcessChargerS(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmpCache := engine.Cache engine.Cache.Clear(nil) @@ -1485,7 +1485,7 @@ func TestProcessChargerS(t *testing.T) { } func TestTransitSState(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) dm := engine.NewDataManager(data, cfg.CacheCfg(), nil) @@ -1513,7 +1513,7 @@ func TestTransitSState(t *testing.T) { } func TestRelocateSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) dm := engine.NewDataManager(data, cfg.CacheCfg(), nil) @@ -1568,7 +1568,7 @@ func TestRelocateSession(t *testing.T) { } func TestGetRelocateSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) dm := engine.NewDataManager(data, cfg.CacheCfg(), nil) @@ -1597,7 +1597,7 @@ func TestGetRelocateSession(t *testing.T) { } func TestLibsessionsSetMockErrors(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -1664,7 +1664,7 @@ func (sT *testMockClientSyncSessions) Call(method string, arg interface{}, rply } func TestSyncSessions(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -1728,7 +1728,7 @@ func TestSyncSessions(t *testing.T) { } func TestAuthEvent(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) sTestMock := &testMockClients{ @@ -1796,7 +1796,7 @@ func TestAuthEvent(t *testing.T) { } func TestAuthEventMockCall(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) //mocking the GetMaxSession for checking the error engine.Cache.Clear(nil) sTestMock := &testMockClients{ @@ -1868,7 +1868,7 @@ func TestAuthEventMockCall(t *testing.T) { } func TestChargeEvent(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -1962,7 +1962,7 @@ func TestChargeEvent(t *testing.T) { } func TestUpdateSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) dm := engine.NewDataManager(data, cfg.CacheCfg(), nil) @@ -2002,7 +2002,7 @@ func TestUpdateSession(t *testing.T) { } func TestEndSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) sTestMock := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -2107,7 +2107,7 @@ func TestEndSession(t *testing.T) { } func TestCallBiRPC(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) cfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) dm := engine.NewDataManager(data, cfg.CacheCfg(), nil) @@ -2136,7 +2136,7 @@ func TestCallBiRPC(t *testing.T) { } func TestBiRPCv1GetActivePassiveSessions(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) clnt := &testMockClients{} cfg := config.NewDefaultCGRConfig() @@ -2296,7 +2296,7 @@ func TestBiRPCv1GetActivePassiveSessions(t *testing.T) { } func TestBiRPCv1SetPassiveSession(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) clnt := &testMockClients{} cfg := config.NewDefaultCGRConfig() @@ -2344,7 +2344,7 @@ func TestBiRPCv1SetPassiveSession(t *testing.T) { } func TestBiRPCv1ReplicateSessions(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -2381,7 +2381,7 @@ func TestBiRPCv1ReplicateSessions(t *testing.T) { } func TestBiRPCv1AuthorizeEvent(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -2476,7 +2476,7 @@ func TestBiRPCv1AuthorizeEvent(t *testing.T) { } func TestBiRPCv1AuthorizeEvent2(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -2611,7 +2611,7 @@ func TestBiRPCv1AuthorizeEvent2(t *testing.T) { } func TestBiRPCv1AuthorizeEventWithDigest(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -2720,7 +2720,7 @@ func TestBiRPCv1AuthorizeEventWithDigest(t *testing.T) { } func TestBiRPCv1InitiateSession1(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -2870,7 +2870,7 @@ func TestBiRPCv1InitiateSession1(t *testing.T) { } func TestBiRPCv1InitiateSession2(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -2987,7 +2987,7 @@ func TestBiRPCv1InitiateSession2(t *testing.T) { } func TestBiRPCv1InitiateSessionWithDigest(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -3094,7 +3094,7 @@ func TestBiRPCv1InitiateSessionWithDigest(t *testing.T) { } func TestBiRPCv1UpdateSession1(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -3176,7 +3176,7 @@ func TestBiRPCv1UpdateSession1(t *testing.T) { } func TestBiRPCv1UpdateSession2(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -3248,7 +3248,7 @@ func TestBiRPCv1UpdateSession2(t *testing.T) { } func TestBiRPCv1TerminateSession1(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -3398,7 +3398,7 @@ func TestBiRPCv1TerminateSession1(t *testing.T) { } func TestBiRPCv1TerminateSession2(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -3459,7 +3459,7 @@ func TestBiRPCv1TerminateSession2(t *testing.T) { } func TestBiRPCv1ProcessCDR(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache cfg := config.NewDefaultCGRConfig() @@ -3498,7 +3498,7 @@ func TestBiRPCv1ProcessCDR(t *testing.T) { } func TestBiRPCv1ProcessMessage1(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -3579,7 +3579,7 @@ func TestBiRPCv1ProcessMessage1(t *testing.T) { } func TestBiRPCv1ProcessMessage2(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -3681,7 +3681,7 @@ func TestBiRPCv1ProcessMessage2(t *testing.T) { } func TestBiRPCv1ProcessEvent(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) @@ -3825,7 +3825,7 @@ func TestBiRPCv1ProcessEvent(t *testing.T) { } func TestBiRPCv1ProcessEventStats(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -3907,7 +3907,7 @@ func TestBiRPCv1ProcessEventStats(t *testing.T) { } } func TestBiRPCv1ProcessEventResources(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -4007,7 +4007,7 @@ func TestBiRPCv1ProcessEventResources(t *testing.T) { } func TestBiRPCv1ProcessEventRals1(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ calls: map[string]func(args interface{}, reply interface{}) error{ @@ -4117,7 +4117,7 @@ func TestBiRPCv1ProcessEventRals1(t *testing.T) { func TestBiRPCv1ProcessEventRals2(t *testing.T) { tmp := engine.Cache - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ @@ -4254,7 +4254,7 @@ func TestBiRPCv1ProcessEventRals2(t *testing.T) { } func TestBiRPCv1ProcessEventCDRs(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) engine.Cache.Clear(nil) clnt := &testMockClients{ @@ -4332,7 +4332,7 @@ func TestBiRPCv1ProcessEventCDRs(t *testing.T) { } func TestBiRPCv1GetCost(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) tmp := engine.Cache engine.Cache.Clear(nil) diff --git a/utils/logger_test.go b/utils/logger_test.go index 4cfeabdaf..3f72f0bda 100644 --- a/utils/logger_test.go +++ b/utils/logger_test.go @@ -20,7 +20,7 @@ package utils import ( "bytes" - "io/ioutil" + "io" "log" syslog "log/syslog" "os" @@ -287,7 +287,7 @@ func TestWriteLogger(t *testing.T) { } func TestCloseLogger(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) loggertype := MetaStdLog if _, err := Newlogger(loggertype, EmptyString); err != nil { @@ -316,7 +316,7 @@ func TestLogStackLogger(t *testing.T) { } func TestNewLoggerInvalidLoggerType(t *testing.T) { - log.SetOutput(ioutil.Discard) + log.SetOutput(io.Discard) loggertype := "Invalid_TYPE" expected := "unsuported logger: " diff --git a/utils/stir_shaken_utils.go b/utils/stir_shaken_utils.go index 4bc4f7a4b..1f6b0f1b6 100644 --- a/utils/stir_shaken_utils.go +++ b/utils/stir_shaken_utils.go @@ -23,7 +23,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "os" "time" @@ -35,7 +34,7 @@ import ( // NewECDSAPrvKeyFromReader creates a private key from io.Reader func NewECDSAPrvKeyFromReader(reader io.Reader) (prvKey *ecdsa.PrivateKey, err error) { var prvkeyBuf []byte - if prvkeyBuf, err = ioutil.ReadAll(reader); err != nil { + if prvkeyBuf, err = io.ReadAll(reader); err != nil { return } return jwt.ParseECPrivateKeyFromPEM(prvkeyBuf) @@ -44,7 +43,7 @@ func NewECDSAPrvKeyFromReader(reader io.Reader) (prvKey *ecdsa.PrivateKey, err e // NewECDSAPubKeyFromReader returns a public key from io.Reader func NewECDSAPubKeyFromReader(reader io.Reader) (pubKey *ecdsa.PublicKey, err error) { var pubkeyBuf []byte - if pubkeyBuf, err = ioutil.ReadAll(reader); err != nil { + if pubkeyBuf, err = io.ReadAll(reader); err != nil { return } return jwt.ParseECPublicKeyFromPEM(pubkeyBuf)