mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 08:38:45 +05:00
improving coverage at engine
This commit is contained in:
committed by
Dan Christian Bogos
parent
94adeb2352
commit
19125bf4e3
@@ -957,3 +957,55 @@ func TestGetMinutesForCredi(t *testing.T) {
|
||||
t.Errorf("expected %v,received %v", utils.ToJSON(expLog), utils.ToJSON(rcvLog))
|
||||
}
|
||||
}
|
||||
|
||||
func TestBalanceDebitUnits3(t *testing.T) {
|
||||
cc := &CallCost{
|
||||
Destination: "0723045326",
|
||||
Timespans: []*TimeSpan{
|
||||
{
|
||||
TimeStart: time.Date(2013, 9, 24, 10, 48, 0, 0, time.UTC),
|
||||
TimeEnd: time.Date(2013, 9, 24, 10, 48, 10, 0, time.UTC),
|
||||
DurationIndex: 0,
|
||||
RateInterval: &RateInterval{
|
||||
Rating: &RIRate{Rates: RateGroups{
|
||||
&RGRate{GroupIntervalStart: 0, Value: 1,
|
||||
RateIncrement: 10 * time.Second,
|
||||
RateUnit: time.Second}}}},
|
||||
},
|
||||
{
|
||||
TimeStart: time.Date(2013, 9, 24, 10, 48, 10, 0, time.UTC),
|
||||
TimeEnd: time.Date(2013, 9, 24, 10, 49, 20, 0, time.UTC),
|
||||
DurationIndex: 10 * time.Second,
|
||||
RateInterval: &RateInterval{
|
||||
Rating: &RIRate{Rates: RateGroups{
|
||||
&RGRate{GroupIntervalStart: 0,
|
||||
Value: 1,
|
||||
RateIncrement: 10 * time.Second,
|
||||
RateUnit: time.Second}}}},
|
||||
},
|
||||
},
|
||||
ToR: utils.MetaVoice,
|
||||
}
|
||||
b1 := &Balance{
|
||||
Uuid: "testb", Value: 10 * float64(time.Second), Weight: 10,
|
||||
DestinationIDs: utils.StringMap{"NAT": true},
|
||||
RatingSubject: "*zero1s"}
|
||||
cd := &CallDescriptor{
|
||||
TimeStart: cc.Timespans[0].TimeStart,
|
||||
TimeEnd: cc.Timespans[1].TimeEnd,
|
||||
Destination: cc.Destination,
|
||||
ToR: cc.ToR,
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]Balances{
|
||||
utils.MetaVoice: {b1},
|
||||
utils.MetaMonetary: {{Uuid: "moneya", Value: 110}},
|
||||
}}
|
||||
moneyBalances := Balances{
|
||||
{Uuid: "moneyc", Value: 130, SharedGroups: utils.NewStringMap("SG_TEST")},
|
||||
}
|
||||
if _, err := b1.debitUnits(cd, rifsBalance, moneyBalances, true, true, true, nil); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1436,6 +1436,66 @@ func TestDmDispatcherHost(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetDispatcherHostErr(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
tmpDm := dm
|
||||
tmp := Cache
|
||||
defer func() {
|
||||
config.SetCgrConfig(config.NewDefaultCGRConfig())
|
||||
Cache = tmp
|
||||
SetDataStorage(tmpDm)
|
||||
}()
|
||||
Cache.Clear(nil)
|
||||
cfg.DataDbCfg().RplConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.ReplicatorSv1)}
|
||||
cfg.CacheCfg().ReplicationConns = []string{utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches)}
|
||||
cfg.CacheCfg().Partitions[utils.CacheDispatcherHosts].Replicate = true
|
||||
cfg.DataDbCfg().RplFiltered = true
|
||||
cfg.DataDbCfg().Items = map[string]*config.ItemOpt{
|
||||
utils.CacheDispatcherHosts: {
|
||||
Limit: 3,
|
||||
Replicate: true,
|
||||
},
|
||||
}
|
||||
clientConn := make(chan rpcclient.ClientConnector, 1)
|
||||
clientConn <- &ccMock{
|
||||
calls: map[string]func(args interface{}, reply interface{}) error{
|
||||
utils.ReplicatorSv1GetDispatcherHost: func(args, reply interface{}) error {
|
||||
return utils.ErrDSPHostNotFound
|
||||
},
|
||||
utils.CacheSv1ReplicateSet: func(args, reply interface{}) error {
|
||||
return errors.New("Can't Replicate")
|
||||
},
|
||||
},
|
||||
}
|
||||
db := NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items)
|
||||
connMgr := NewConnManager(cfg, map[string]chan rpcclient.ClientConnector{
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.ReplicatorSv1): clientConn,
|
||||
utils.ConcatenatedKey(utils.MetaInternal, utils.MetaCaches): clientConn,
|
||||
})
|
||||
dm := NewDataManager(db, cfg.CacheCfg(), connMgr)
|
||||
config.SetCgrConfig(cfg)
|
||||
SetDataStorage(dm)
|
||||
dH := &DispatcherHost{
|
||||
Tenant: "testTenant",
|
||||
RemoteHost: &config.RemoteHost{
|
||||
ID: "testID",
|
||||
Address: rpcclient.InternalRPC,
|
||||
Transport: utils.MetaInternal,
|
||||
TLS: false,
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := dm.GetDispatcherHost(dH.Tenant, dH.ID, true, true, utils.NonTransactional); err == nil || err != utils.ErrDSPHostNotFound {
|
||||
t.Error(err)
|
||||
}
|
||||
SetConnManager(connMgr)
|
||||
Cache = NewCacheS(cfg, dm, nil)
|
||||
|
||||
if _, err := dm.GetDispatcherHost(dH.Tenant, dH.ID, true, true, utils.NonTransactional); err == nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChargerProfileRemote(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
tmpDm := dm
|
||||
|
||||
Reference in New Issue
Block a user