Testing V1ProcessEvent API

This commit is contained in:
nickolasdaniel
2021-09-10 17:08:35 +03:00
committed by Dan Christian Bogos
parent 0c51a3ee32
commit aca89ee8a9

70
apis/ees_test.go Normal file
View File

@@ -0,0 +1,70 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package apis
import (
"fmt"
"testing"
"time"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/ees"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
func TestEeSProcessEvent(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
filterS := new(engine.FilterS)
connMgr := engine.NewConnManager(cfg, nil)
eeS := ees.NewEventExporterS(cfg, filterS, connMgr)
cS := NewEeSv1(eeS)
///create logger and see the event in log
//define non default cgrconfig, define exporters
cgrEv := &utils.CGREventWithEeIDs{
EeIDs: []string{"*default"},
CGREvent: &utils.CGREvent{
Tenant: "cgrates.org",
ID: "voiceEvent",
Event: map[string]interface{}{
utils.CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()),
utils.ToR: utils.MetaVoice,
utils.OriginID: "dsafdsaf",
utils.OriginHost: "192.168.1.1",
utils.RequestType: utils.MetaRated,
utils.Tenant: "cgrates.org",
utils.Category: "call",
utils.AccountField: "1001",
utils.Subject: "1001",
utils.Destination: "1002",
utils.SetupTime: time.Unix(1383813745, 0).UTC(),
utils.AnswerTime: time.Unix(1383813746, 0).UTC(),
utils.Usage: 10 * time.Second,
utils.RunID: utils.MetaDefault,
utils.Cost: 1.01,
"ExtraFields": map[string]string{"extra1": "val_extra1",
"extra2": "val_extra2", "extra3": "val_extra3"},
},
},
}
var reply map[string]map[string]interface{}
if err := cS.ProcessEvent(context.Background(), cgrEv, &reply); err != nil {
t.Error(err)
}
fmt.Println(utils.IfaceAsString(reply))
}