mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added Unit Tests in config
This commit is contained in:
committed by
Dan Christian Bogos
parent
64692891bb
commit
0e4ab4f322
@@ -18,7 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestLoadFromJSONCfgNil(t *testing.T) {
|
||||
var jc JanusConn
|
||||
@@ -28,3 +33,19 @@ func TestLoadFromJSONCfgNil(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestJanusConnAsMapInterface(t *testing.T) {
|
||||
js := &JanusConn{
|
||||
Address: "127.001",
|
||||
Type: "ws",
|
||||
}
|
||||
exp := map[string]any{
|
||||
utils.AddressCfg: "127.001",
|
||||
utils.TypeCfg: "ws",
|
||||
}
|
||||
val := js.AsMapInterface()
|
||||
if !reflect.DeepEqual(val, exp) {
|
||||
t.Errorf("expected %+v received %+v", exp, val)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,15 @@ func TestRadiusAgentCfgloadFromJsonCfgCase1(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
ClientDaAddresses: map[string]DAClientOptsJson{
|
||||
|
||||
"fsfdsz": {
|
||||
Transport: utils.StringPointer("http"),
|
||||
Host: utils.StringPointer("localhost"),
|
||||
Port: utils.IntPointer(6768),
|
||||
Flags: []string{"*sessions", "*routes"},
|
||||
},
|
||||
},
|
||||
}
|
||||
expected := &RadiusAgentCfg{
|
||||
Enabled: true,
|
||||
@@ -74,6 +83,17 @@ func TestRadiusAgentCfgloadFromJsonCfgCase1(t *testing.T) {
|
||||
SessionSConns: []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaSessionS)},
|
||||
DMRTemplate: "*dmr",
|
||||
CoATemplate: "*coa",
|
||||
ClientDaAddresses: map[string]DAClientOpts{
|
||||
"fsfdsz": {
|
||||
Transport: "http",
|
||||
Host: "localhost",
|
||||
Port: 6768,
|
||||
Flags: utils.FlagsWithParams{
|
||||
utils.MetaSessionS: utils.FlagParams{},
|
||||
utils.MetaRoutes: utils.FlagParams{},
|
||||
},
|
||||
},
|
||||
},
|
||||
RequestProcessors: []*RequestProcessor{
|
||||
{
|
||||
ID: "OutboundAUTHDryRun",
|
||||
@@ -313,3 +333,30 @@ func TestRadiusAgentCfgClone(t *testing.T) {
|
||||
t.Errorf("Expected clone to not modify the cloned")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAsMapInterface01(t *testing.T) {
|
||||
|
||||
expectedMap := map[string]any{
|
||||
utils.TransportCfg: "http",
|
||||
utils.HostCfg: "localhost",
|
||||
utils.PortCfg: 6768,
|
||||
utils.FlagsCfg: []string{utils.MetaSessionS,
|
||||
utils.MetaRoutes},
|
||||
}
|
||||
|
||||
opts := &DAClientOpts{
|
||||
Transport: "http",
|
||||
Host: "localhost",
|
||||
Port: 6768,
|
||||
Flags: utils.FlagsWithParams{
|
||||
utils.MetaSessionS: utils.FlagParams{},
|
||||
utils.MetaRoutes: utils.FlagParams{},
|
||||
},
|
||||
}
|
||||
|
||||
actualMap := opts.AsMapInterface()
|
||||
|
||||
if !reflect.DeepEqual(expectedMap, actualMap) {
|
||||
t.Errorf("Expected map: %v, Actual map: %v", expectedMap, actualMap)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user