From 4d292cdad9aa079b2d7a0f45f9275e605d5708ab Mon Sep 17 00:00:00 2001 From: nickolasdaniel Date: Wed, 7 Jul 2021 17:30:56 +0300 Subject: [PATCH] Added *tenant case and tested it as well --- agents/agentreq.go | 2 ++ agents/agentreq_test.go | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/agents/agentreq.go b/agents/agentreq.go index f8b1f3c7f..ec031badd 100644 --- a/agents/agentreq.go +++ b/agents/agentreq.go @@ -165,6 +165,8 @@ func (ar *AgentRequest) FieldAsInterface(fldPath []string) (val interface{}, err } else { val = ar.Cfg } + case utils.MetaTenant: + return ar.Tenant, nil } if err != nil { return diff --git a/agents/agentreq_test.go b/agents/agentreq_test.go index c51e3f377..bde80194c 100644 --- a/agents/agentreq_test.go +++ b/agents/agentreq_test.go @@ -957,6 +957,7 @@ func TestAgReqFieldAsInterface(t *testing.T) { agReq.CGRRequest.Set(&utils.FullPath{Path: utils.ToR, PathSlice: []string{utils.ToR}}, &utils.DataNode{Type: utils.NMSliceType, Slice: []*utils.DataNode{{Type: utils.NMDataType, Value: &utils.DataLeaf{Data: utils.MetaVoice}}}}) agReq.CGRRequest.Set(&utils.FullPath{Path: utils.AccountField, PathSlice: []string{utils.AccountField}}, utils.NewLeafNode("1001")) agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Destination, PathSlice: []string{utils.Destination}}, utils.NewLeafNode("1002")) + agReq.CGRRequest.Set(&utils.FullPath{Path: utils.Tenant, PathSlice: []string{utils.Tenant}}, utils.NewLeafNode("cgrates.org")) path := []string{utils.MetaCgreq, utils.Usage} var expVal interface{} @@ -990,6 +991,14 @@ func TestAgReqFieldAsInterface(t *testing.T) { } else if !reflect.DeepEqual(rply, expVal) { t.Errorf("Expected %v , received: %v", utils.ToJSON(expVal), utils.ToJSON(rply)) } + + path = []string{utils.MetaTenant} + expVal = "cgrates.org" + if rply, err := agReq.FieldAsInterface(path); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(rply, expVal) { + t.Errorf("Expected %v , received: %v", utils.ToJSON(expVal), utils.ToJSON(rply)) + } } func TestAgReqFieldAsInterfaceForOneFldPathCgrReq(t *testing.T) {