From e634d968df7997b73e1f582c2e91e097a0be5d8c Mon Sep 17 00:00:00 2001 From: DanB Date: Fri, 6 Jul 2018 14:49:34 +0200 Subject: [PATCH] Updating AgentRequest tests with []*NMItems as value --- agents/agentreq_test.go | 24 ++++++++++++++++++------ engine/navigablemap_test.go | 3 +-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/agents/agentreq_test.go b/agents/agentreq_test.go index 13c60b871..4aeed82c6 100644 --- a/agents/agentreq_test.go +++ b/agents/agentreq_test.go @@ -99,12 +99,24 @@ func TestAgReqAsNavigableMap(t *testing.T) { "*cgrReply.Error", utils.INFIELD_SEP)}, } eMp := engine.NewNavigableMap(nil) - eMp.Set([]string{utils.Tenant}, "cgrates.org", true) - eMp.Set([]string{utils.Account}, "1001", true) - eMp.Set([]string{utils.Destination}, "1002", true) - eMp.Set([]string{"RequestedUsage"}, "180", true) - eMp.Set([]string{"PaypalAccount"}, "cgrates@paypal.com", true) - eMp.Set([]string{"MaxUsage"}, "120", true) + eMp.Set([]string{utils.Tenant}, []*engine.NMItem{ + &engine.NMItem{Data: "cgrates.org", Path: []string{utils.Tenant}, + Config: tplFlds[0]}}, true) + eMp.Set([]string{utils.Account}, []*engine.NMItem{ + &engine.NMItem{Data: "1001", Path: []string{utils.Account}, + Config: tplFlds[1]}}, true) + eMp.Set([]string{utils.Destination}, []*engine.NMItem{ + &engine.NMItem{Data: "1002", Path: []string{utils.Destination}, + Config: tplFlds[2]}}, true) + eMp.Set([]string{"RequestedUsage"}, []*engine.NMItem{ + &engine.NMItem{Data: "180", Path: []string{"RequestedUsage"}, + Config: tplFlds[3]}}, true) + eMp.Set([]string{"PaypalAccount"}, []*engine.NMItem{ + &engine.NMItem{Data: "cgrates@paypal.com", Path: []string{"PaypalAccount"}, + Config: tplFlds[6]}}, true) + eMp.Set([]string{"MaxUsage"}, []*engine.NMItem{ + &engine.NMItem{Data: "120", Path: []string{"MaxUsage"}, + Config: tplFlds[7]}}, true) if mpOut, err := agReq.AsNavigableMap(tplFlds); err != nil { t.Error(err) } else if !reflect.DeepEqual(eMp, mpOut) { diff --git a/engine/navigablemap_test.go b/engine/navigablemap_test.go index 117a3b293..05b00e0cb 100644 --- a/engine/navigablemap_test.go +++ b/engine/navigablemap_test.go @@ -19,7 +19,6 @@ package engine import ( "encoding/xml" - "errors" "reflect" "strings" "testing" @@ -57,7 +56,7 @@ func TestNavMapGetFieldAsString(t *testing.T) { } fPath := "NonExisting>AnotherFirstLevel" if _, err := nM.FieldAsString(strings.Split(fPath, ">")); err.Error() != - errors.New("no map at path: ").Error() { + utils.ErrNotFound.Error() { t.Error(err) } }