Make go vet pass

The rpcclient constructor could not see the centralized
Encoding flag because it didn't have the necessary build
constraints. Added the constraints in lib_test.go files
where it wasn't alone. In all the other cases, it was
moved to the first file where it was needed.
This commit is contained in:
ionutboangiu
2024-04-05 21:16:00 +03:00
committed by Dan Christian Bogos
parent 821b5d05cc
commit 3062113a61
22 changed files with 150 additions and 294 deletions

View File

@@ -21,13 +21,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package ers
import (
"errors"
"os"
"path"
"testing"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/birpc/jsonrpc"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
@@ -167,3 +168,14 @@ func testReloadITKillEngine(t *testing.T) {
t.Error(err)
}
}
func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) {
switch *utils.Encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return birpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}

View File

@@ -19,27 +19,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package ers
import (
"errors"
"os"
"testing"
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/jsonrpc"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/utils"
)
func newRPCClient(cfg *config.ListenCfg) (c *birpc.Client, err error) {
switch *utils.Encoding {
case utils.MetaJSON:
return jsonrpc.Dial(utils.TCP, cfg.RPCJSONListen)
case utils.MetaGOB:
return birpc.Dial(utils.TCP, cfg.RPCGOBListen)
default:
return nil, errors.New("UNSUPPORTED_RPC")
}
}
func testCreateDirs(t *testing.T) {
for _, dir := range []string{"/tmp/ers/in", "/tmp/ers/out",
"/tmp/ers2/in", "/tmp/ers2/out",