Added *tenant case for FieldAsInterface and tested it as well

This commit is contained in:
nickolasdaniel
2021-07-07 12:06:41 +03:00
committed by Dan Christian Bogos
parent 18783cec46
commit cc915d693c
2 changed files with 10 additions and 0 deletions

View File

@@ -164,6 +164,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

View File

@@ -990,6 +990,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()
} else if !reflect.DeepEqual(rply, expVal) {
t.Errorf("Expected %v , received: %v", utils.ToJSON(expVal), utils.ToJSON(rply))
}
}
func TestAgReqFieldAsInterfaceForOneFldPathCgrReq(t *testing.T) {