mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 15:48:44 +05:00
Small bug fixup in action_timings possible reaching nil pointer error, adding charging_tests folder to improve testing mechanisms
This commit is contained in:
@@ -235,7 +235,10 @@ func (at *ActionTiming) Execute() (err error) {
|
||||
for _, ubId := range at.AccountIds {
|
||||
_, err := AccLock.Guard(ubId, func() (float64, error) {
|
||||
ub, err := accountingStorage.GetAccount(ubId)
|
||||
if ub.Disabled {
|
||||
if err != nil {
|
||||
Logger.Warning(fmt.Sprintf("Could not get user balances for this id: %s. Skipping!", ubId))
|
||||
return 0, err
|
||||
} else if ub.Disabled {
|
||||
return 0, fmt.Errorf("User %s is disabled", ubId)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -41,6 +41,10 @@ func NewMapStorage() (*MapStorage, error) {
|
||||
return &MapStorage{dict: make(map[string][]byte), ms: NewCodecMsgpackMarshaler()}, nil
|
||||
}
|
||||
|
||||
func NewMapStorageJson() (*MapStorage, error) {
|
||||
return &MapStorage{dict: make(map[string][]byte), ms: new(JSONBufMarshaler)}, nil
|
||||
}
|
||||
|
||||
func (ms *MapStorage) Close() {}
|
||||
|
||||
func (ms *MapStorage) Flush() error {
|
||||
@@ -173,8 +177,9 @@ func (ms *MapStorage) SetRatingPlan(rp *RatingPlan) (err error) {
|
||||
w.Close()
|
||||
ms.dict[RATING_PLAN_PREFIX+rp.Id] = b.Bytes()
|
||||
response := 0
|
||||
|
||||
go historyScribe.Record(rp.GetHistoryRecord(), &response)
|
||||
if historyScribe != nil {
|
||||
go historyScribe.Record(rp.GetHistoryRecord(), &response)
|
||||
}
|
||||
//cache2go.Cache(RATING_PLAN_PREFIX+rp.Id, rp)
|
||||
return
|
||||
}
|
||||
@@ -202,7 +207,9 @@ func (ms *MapStorage) SetRatingProfile(rpf *RatingProfile) (err error) {
|
||||
result, err := ms.ms.Marshal(rpf)
|
||||
ms.dict[RATING_PROFILE_PREFIX+rpf.Id] = result
|
||||
response := 0
|
||||
go historyScribe.Record(rpf.GetHistoryRecord(), &response)
|
||||
if historyScribe != nil {
|
||||
go historyScribe.Record(rpf.GetHistoryRecord(), &response)
|
||||
}
|
||||
//cache2go.Cache(RATING_PROFILE_PREFIX+rpf.Id, rpf)
|
||||
return
|
||||
}
|
||||
@@ -309,7 +316,9 @@ func (ms *MapStorage) SetDestination(dest *Destination) (err error) {
|
||||
w.Close()
|
||||
ms.dict[DESTINATION_PREFIX+dest.Id] = b.Bytes()
|
||||
response := 0
|
||||
go historyScribe.Record(dest.GetHistoryRecord(), &response)
|
||||
if historyScribe != nil {
|
||||
go historyScribe.Record(dest.GetHistoryRecord(), &response)
|
||||
}
|
||||
//cache2go.Cache(DESTINATION_PREFIX+dest.Id, dest)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user