diff --git a/dispatchers/caches_test.go b/dispatchers/caches_test.go index 40e030227..f228bb2bc 100644 --- a/dispatchers/caches_test.go +++ b/dispatchers/caches_test.go @@ -496,6 +496,7 @@ func TestDspCacheSv1GetItemWithRemote(t *testing.T) { "Opt": "Disp", }, } + if err := dm.SetDispatcherProfile(&engine.DispatcherProfile{ Tenant: "cgrates.org", ID: "DSP_Test1", @@ -515,7 +516,46 @@ func TestDspCacheSv1GetItemWithRemote(t *testing.T) { t.Error(err) } var reply any - if err := dsp.CacheSv1GetItemWithRemote(args, &reply); err == nil { //not finished + if err := dsp.CacheSv1GetItemWithRemote(args, &reply); err == nil { t.Error(err) } } + +func TestDspCacheSv1GetItem(t *testing.T) { + cfg := config.NewDefaultCGRConfig() + dm := engine.NewDataManager(engine.NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items), cfg.CacheCfg(), nil) + dsp := NewDispatcherService(dm, cfg, engine.NewFilterS(cfg, nil, dm), nil) + args := &utils.ArgsGetCacheItemWithAPIOpts{ + Tenant: "cgrates.org", + ArgsGetCacheItem: utils.ArgsGetCacheItem{ + CacheID: utils.CacheChargerProfiles, + ItemID: "cgrates.org:DISP1 ", + }, + APIOpts: map[string]any{ + "Opt": "Disp", + }, + } + if err := dm.SetDispatcherProfile(&engine.DispatcherProfile{ + Tenant: "cgrates.org", + ID: "DSP_Test1", + FilterIDs: []string{"*string:~*opts.Opt:Disp"}, + Strategy: utils.MetaRoundRobin, + Subsystems: []string{utils.MetaAny}, + Hosts: engine.DispatcherHostProfiles{ + &engine.DispatcherHostProfile{ + ID: "ALL2", + FilterIDs: []string{}, + Weight: 20, + Params: make(map[string]any), + }, + }, + Weight: 20, + }, true); err != nil { + t.Error(err) + } + var reply any + if err := dsp.CacheSv1GetItem(args, &reply); err == nil { + t.Error(err) + } + +} diff --git a/dispatchers/responder_test.go b/dispatchers/responder_test.go index 4df471af0..6cfacf7a4 100644 --- a/dispatchers/responder_test.go +++ b/dispatchers/responder_test.go @@ -294,3 +294,92 @@ func TestDspResponderShutdownErrorNil(t *testing.T) { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result) } } + +func TestDspResponderGetCostOnRatingPlans(t *testing.T) { + cfg := config.NewDefaultCGRConfig() + dm := engine.NewDataManager(engine.NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items), cfg.CacheCfg(), nil) + dsp := NewDispatcherService(dm, cfg, nil, nil) + args := &utils.GetCostOnRatingPlansArgs{ + Account: "1002", + RatingPlanIDs: []string{ + "RP1", + "RP2", + }, + Subject: "1002", + Destination: "1001", + Usage: 2 * time.Minute, + Tenant: "cgrates.org", + } + if err := dm.SetDispatcherHost(&engine.DispatcherHost{ + Tenant: "cgrates.org", + RemoteHost: &config.RemoteHost{ + ID: "ALL2", + }, + }); err != nil { + t.Error(err) + } + if err := dm.SetDispatcherProfile(&engine.DispatcherProfile{ + Tenant: "cgrates.org", + ID: "DSP_Test1", + FilterIDs: []string{}, + Strategy: utils.MetaRoundRobin, + Subsystems: []string{utils.MetaAny}, + Hosts: engine.DispatcherHostProfiles{ + &engine.DispatcherHostProfile{ + ID: "ALL2", + FilterIDs: []string{}, + Weight: 20, + Params: make(map[string]any), + }, + }, + Weight: 20, + }, true); err != nil { + t.Error(err) + } + var reply map[string]any + if err := dsp.ResponderGetCostOnRatingPlans(args, &reply); err == nil { + t.Error(err) + } +} + +// func TestDspResponderGetMaxSessionTimeOnAccounts(t *testing.T) { +// cfg := config.NewDefaultCGRConfig() +// dm := engine.NewDataManager(engine.NewInternalDB(nil, nil, true, cfg.DataDbCfg().Items), cfg.CacheCfg(), nil) +// dsp := NewDispatcherService(dm, cfg, nil, nil) +// args := &utils.GetMaxSessionTimeOnAccountsArgs{ +// Subject: "1002", +// Destination: "1001", +// Usage: 2 * time.Minute, +// Tenant: "cgrates.org", +// } +// if err := dm.SetDispatcherHost(&engine.DispatcherHost{ +// Tenant: "cgrates.org", +// RemoteHost: &config.RemoteHost{ +// ID: "ALL2", +// }, +// }); err != nil { +// t.Error(err) +// } +// if err := dm.SetDispatcherProfile(&engine.DispatcherProfile{ +// Tenant: "cgrates.org", +// ID: "DSP_Test1", +// FilterIDs: []string{}, +// Strategy: utils.MetaRoundRobin, +// Subsystems: []string{utils.MetaAny}, +// Hosts: engine.DispatcherHostProfiles{ +// &engine.DispatcherHostProfile{ +// ID: "ALL2", +// FilterIDs: []string{}, +// Weight: 20, +// Params: make(map[string]any), +// }, +// }, +// Weight: 20, +// }, true); err != nil { +// t.Error(err) +// } +// var reply map[string]any +// if err := dsp.ResponderGetMaxSessionTimeOnAccounts(args, &reply); err == nil { +// t.Error(err) +// } +// }