mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fix actions cloning due to bug in gob
This commit is contained in:
@@ -761,5 +761,15 @@ func (apl Actions) Clone() (interface{}, error) {
|
||||
if err := utils.Clone(apl, &cln); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for i, act := range apl { // Fix issues with gob cloning nil pointer towards false value
|
||||
if act.Balance != nil {
|
||||
if act.Balance.Disabled != nil && !*act.Balance.Disabled {
|
||||
cln[i].Balance.Disabled = utils.BoolPointer(*act.Balance.Disabled)
|
||||
}
|
||||
if act.Balance.Blocker != nil && !*act.Balance.Blocker {
|
||||
cln[i].Balance.Blocker = utils.BoolPointer(*act.Balance.Blocker)
|
||||
}
|
||||
}
|
||||
}
|
||||
return cln, nil
|
||||
}
|
||||
|
||||
@@ -2387,14 +2387,23 @@ func TestCacheGetClonedActions(t *testing.T) {
|
||||
Weight: float64(30),
|
||||
},
|
||||
&Action{
|
||||
Id: "RECUR_FOR_V3HSILLMILLD5G",
|
||||
ActionType: DEBIT,
|
||||
Id: "REACT_FOR_V3HSILLMILL",
|
||||
ActionType: SET_BALANCE,
|
||||
Balance: &BalanceFilter{
|
||||
ID: utils.StringPointer("*default"),
|
||||
Value: &utils.ValueFormula{Static: 2},
|
||||
Type: utils.StringPointer(utils.MONETARY),
|
||||
ID: utils.StringPointer("for_v3hsillmill_sms_ill"),
|
||||
Type: utils.StringPointer(utils.SMS),
|
||||
Value: &utils.ValueFormula{Static: 20000},
|
||||
DestinationIDs: &utils.StringMap{
|
||||
"FRANCE_NATIONAL": true,
|
||||
"FRANCE_NATIONAL_FREE": false,
|
||||
"ZONE1": false},
|
||||
Categories: &utils.StringMap{
|
||||
"sms_eurotarif": true,
|
||||
"sms_france": true},
|
||||
Disabled: utils.BoolPointer(false),
|
||||
Blocker: utils.BoolPointer(false),
|
||||
},
|
||||
Weight: float64(20),
|
||||
Weight: float64(10),
|
||||
},
|
||||
}
|
||||
cache.Set("MYTEST", actions, true, "")
|
||||
@@ -2404,7 +2413,7 @@ func TestCacheGetClonedActions(t *testing.T) {
|
||||
}
|
||||
aCloned := clned.(Actions)
|
||||
if !reflect.DeepEqual(actions, aCloned) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", actions, aCloned)
|
||||
t.Errorf("Expecting: %+v, received: %+v", actions[1].Balance, aCloned[1].Balance)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user