Small bug fixup in action_timings possible reaching nil pointer error, adding charging_tests folder to improve testing mechanisms

This commit is contained in:
DanB
2014-04-06 19:15:31 +02:00
parent 7313e64362
commit d5a8a2c292
3 changed files with 174 additions and 5 deletions

View File

@@ -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 {

View File

@@ -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
}