mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 06:38:45 +05:00
Added tests in ers for sqs.go
This commit is contained in:
committed by
Dan Christian Bogos
parent
e00db28b60
commit
54959def06
@@ -128,39 +128,3 @@ func TestSQSER(t *testing.T) {
|
||||
}
|
||||
close(rdrExit)
|
||||
}
|
||||
|
||||
func TestNewSQSER(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
expected := &SQSER{
|
||||
cgrCfg: cfg,
|
||||
cfgIdx: 0,
|
||||
cap: nil,
|
||||
queueID: "cgrates_cdrs",
|
||||
}
|
||||
cfg.ERsCfg().Readers = []*config.EventReaderCfg{
|
||||
{
|
||||
ID: utils.MetaDefault,
|
||||
Type: utils.MetaNone,
|
||||
RowLength: 0,
|
||||
FieldSep: ",",
|
||||
HeaderDefineChar: ":",
|
||||
RunDelay: 0,
|
||||
ConcurrentReqs: 1,
|
||||
SourcePath: "/var/spool/cgrates/ers/in",
|
||||
ProcessedPath: "/var/spool/cgrates/ers/out",
|
||||
Filters: []string{},
|
||||
Opts: make(map[string]interface{}),
|
||||
},
|
||||
}
|
||||
|
||||
rdr, err := NewSQSER(cfg, 0, nil,
|
||||
nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expected.cap = rdr.(*SQSER).cap
|
||||
expected.session = rdr.(*SQSER).session
|
||||
if !reflect.DeepEqual(rdr, expected) {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, rdr)
|
||||
}
|
||||
}
|
||||
|
||||
122
ers/sqs_test.go
122
ers/sqs_test.go
@@ -1 +1,123 @@
|
||||
/*
|
||||
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 ers
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
func TestNewSQSER(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
expected := &SQSER{
|
||||
cgrCfg: cfg,
|
||||
cfgIdx: 0,
|
||||
cap: nil,
|
||||
queueID: "cgrates_cdrs",
|
||||
}
|
||||
cfg.ERsCfg().Readers = []*config.EventReaderCfg{
|
||||
{
|
||||
ID: utils.MetaDefault,
|
||||
Type: utils.MetaNone,
|
||||
RowLength: 0,
|
||||
FieldSep: ",",
|
||||
HeaderDefineChar: ":",
|
||||
RunDelay: 0,
|
||||
ConcurrentReqs: 1,
|
||||
SourcePath: "/var/spool/cgrates/ers/in",
|
||||
ProcessedPath: "/var/spool/cgrates/ers/out",
|
||||
Filters: []string{},
|
||||
Opts: make(map[string]interface{}),
|
||||
},
|
||||
}
|
||||
rdr, err := NewSQSER(cfg, 0, nil,
|
||||
nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expected.cap = rdr.(*SQSER).cap
|
||||
expected.session = rdr.(*SQSER).session
|
||||
|
||||
rdr.(*SQSER).poster = nil
|
||||
if !reflect.DeepEqual(rdr, expected) {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, rdr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSQSERServeRunDelay0(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
cfg.ERsCfg().Readers = []*config.EventReaderCfg{
|
||||
{
|
||||
ID: utils.MetaDefault,
|
||||
Type: utils.MetaNone,
|
||||
RowLength: 0,
|
||||
FieldSep: ",",
|
||||
HeaderDefineChar: ":",
|
||||
RunDelay: 0,
|
||||
ConcurrentReqs: 1,
|
||||
SourcePath: "/var/spool/cgrates/ers/in",
|
||||
ProcessedPath: "/var/spool/cgrates/ers/out",
|
||||
Filters: []string{},
|
||||
Opts: make(map[string]interface{}),
|
||||
},
|
||||
}
|
||||
rdr, err := NewSQSER(cfg, 0, nil,
|
||||
nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rdr.Config().RunDelay = time.Duration(0)
|
||||
result := rdr.Serve()
|
||||
if result != nil {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSQSERServe(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
cfg.ERsCfg().Readers = []*config.EventReaderCfg{
|
||||
{
|
||||
ID: utils.MetaDefault,
|
||||
Type: utils.MetaNone,
|
||||
RowLength: 0,
|
||||
FieldSep: ",",
|
||||
HeaderDefineChar: ":",
|
||||
RunDelay: 0,
|
||||
ConcurrentReqs: 1,
|
||||
SourcePath: "/var/spool/cgrates/ers/in",
|
||||
ProcessedPath: "/var/spool/cgrates/ers/out",
|
||||
Filters: []string{},
|
||||
Opts: make(map[string]interface{}),
|
||||
},
|
||||
}
|
||||
rdr, err := NewSQSER(cfg, 0, nil,
|
||||
nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rdr.Config().RunDelay = time.Duration(1)
|
||||
result := rdr.Serve()
|
||||
if result != nil {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user