From dcd645bbe57bf5c71f34d46bdb015eaa843bd98d Mon Sep 17 00:00:00 2001 From: Trial97 Date: Mon, 25 Feb 2019 09:54:54 +0200 Subject: [PATCH] Fixes panic for AttributeSv1.ProcessEvent with no attribute profile to match --- apier/v1/attributes_it_test.go | 12 ++++++------ engine/attributes.go | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apier/v1/attributes_it_test.go b/apier/v1/attributes_it_test.go index ea68df680..8d9f5af7c 100644 --- a/apier/v1/attributes_it_test.go +++ b/apier/v1/attributes_it_test.go @@ -238,7 +238,7 @@ func testAttributeSGetAttributeForEventNotFound(t *testing.T) { var reply *engine.AttributeProfile if err := attrSRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_3"}, &reply); err != nil { - t.Error(err) + t.Fatal(err) } reply.Compile() if !reflect.DeepEqual(eAttrPrf2, reply) { @@ -290,7 +290,7 @@ func testAttributeSGetAttributeForEventWithMetaAnyContext(t *testing.T) { var reply *engine.AttributeProfile if err := attrSRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ATTR_2"}, &reply); err != nil { - t.Error(err) + t.Fatal(err) } reply.Compile() if !reflect.DeepEqual(eAttrPrf2, reply) { @@ -299,7 +299,7 @@ func testAttributeSGetAttributeForEventWithMetaAnyContext(t *testing.T) { var attrReply *engine.AttributeProfile if err := attrSRPC.Call(utils.AttributeSv1GetAttributeForEvent, ev, &attrReply); err != nil { - t.Error(err) + t.Fatal(err) } attrReply.Compile() if !reflect.DeepEqual(eAttrPrf2, attrReply) { @@ -692,7 +692,7 @@ func testAttributeSSetAlsPrf(t *testing.T) { var reply *engine.AttributeProfile if err := attrSRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err != nil { - t.Error(err) + t.Fatal(err) } reply.Compile() if !reflect.DeepEqual(alsPrf, reply) { @@ -725,7 +725,7 @@ func testAttributeSUpdateAlsPrf(t *testing.T) { var reply *engine.AttributeProfile if err := attrSRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "cgrates.org", ID: "ApierTest"}, &reply); err != nil { - t.Error(err) + t.Fatal(err) } reply.Compile() if !reflect.DeepEqual(alsPrf, reply) { @@ -791,7 +791,7 @@ func testAttributeSSetAlsPrf2(t *testing.T) { var reply *engine.AttributeProfile if err := attrSRPC.Call("ApierV1.GetAttributeProfile", &utils.TenantID{Tenant: "golant", ID: "ATTR_972587832508_SESSIONAUTH"}, &reply); err != nil { - t.Error(err) + t.Fatal(err) } reply.Compile() if !reflect.DeepEqual(alsPrf, reply) { diff --git a/engine/attributes.go b/engine/attributes.go index 74a43d00f..085436c09 100644 --- a/engine/attributes.go +++ b/engine/attributes.go @@ -215,7 +215,8 @@ func (alS *AttributeService) V1ProcessEvent(args *AttrArgsProcessEvent, } var apiRply *AttrSProcessEventReply // aggregate response here for i := 0; i < *args.ProcessRuns; i++ { - evRply, err := alS.processEvent(args) + var evRply *AttrSProcessEventReply + evRply, err = alS.processEvent(args) if err != nil { if err != utils.ErrNotFound { err = utils.NewErrServerError(err)