mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 12:49:54 +05:00
Add new unit tests on agents
This commit is contained in:
committed by
Dan Christian Bogos
parent
fd5be71657
commit
a263e25858
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/sessions"
|
||||
"github.com/cgrates/kamevapi"
|
||||
)
|
||||
@@ -79,3 +80,30 @@ func TestKAShutdown(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestNewKamailioAgent(t *testing.T) {
|
||||
kaCfg := &config.KamAgentCfg{}
|
||||
connMgr := &engine.ConnManager{}
|
||||
timezone := "UTC"
|
||||
ka := NewKamailioAgent(kaCfg, connMgr, timezone)
|
||||
|
||||
if ka.cfg != kaCfg {
|
||||
t.Errorf("Expected cfg = %v, got %v", kaCfg, ka.cfg)
|
||||
}
|
||||
|
||||
if ka.connMgr != connMgr {
|
||||
t.Errorf("Expected connMgr = %v, got %v", connMgr, ka.connMgr)
|
||||
}
|
||||
|
||||
if ka.timezone != timezone {
|
||||
t.Errorf("Expected timezone = %v, got %v", timezone, ka.timezone)
|
||||
}
|
||||
|
||||
if len(ka.conns) != len(kaCfg.EvapiConns) {
|
||||
t.Errorf("Expected conns length = %d, got %d", len(kaCfg.EvapiConns), len(ka.conns))
|
||||
}
|
||||
|
||||
if ka.activeSessionIDs == nil {
|
||||
t.Errorf("Expected activeSessionIDs to be initialized, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ package agents
|
||||
|
||||
import (
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -1205,3 +1207,21 @@ func TestHeaderLenDiam(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
func TestLoadDictionaries(t *testing.T) {
|
||||
tempDir, err := os.MkdirTemp("", "testdicts")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
xmlFilePath := filepath.Join(tempDir, "test.xml")
|
||||
xmlContent := `<diameter>`
|
||||
err = os.WriteFile(xmlFilePath, []byte(xmlContent), 0644)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
componentID := "testComponent"
|
||||
err = loadDictionaries(tempDir, componentID)
|
||||
if err == nil {
|
||||
t.Errorf("loadDictionaries() error = %v, wantErr %v", err, false)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user