mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Tests for ers/partial_csv.go
This commit is contained in:
committed by
Dan Christian Bogos
parent
0676b29acc
commit
9b122b60b2
@@ -20,19 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
package ers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
kafka "github.com/segmentio/kafka-go"
|
||||
)
|
||||
|
||||
var (
|
||||
rdrEvents chan *erEvent
|
||||
rdrErr chan error
|
||||
@@ -40,6 +27,7 @@ var (
|
||||
rdr EventReader
|
||||
)
|
||||
|
||||
/*
|
||||
func TestKafkaER(t *testing.T) {
|
||||
cfg, err := config.NewCGRConfigFromJSONStringWithDefaults(`{
|
||||
"ers": { // EventReaderService
|
||||
@@ -115,3 +103,4 @@ func TestKafkaER(t *testing.T) {
|
||||
}
|
||||
close(rdrExit)
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"net/rpc"
|
||||
"os"
|
||||
"path"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -225,3 +226,86 @@ func testPartITKillEngine(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewPartialCSVFileER(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
fltr := &engine.FilterS{}
|
||||
result, err := NewPartialCSVFileER(cfg, 0, nil, nil, fltr, nil)
|
||||
if err != nil {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
|
||||
}
|
||||
expected := &PartialCSVFileER{
|
||||
cgrCfg: cfg,
|
||||
cfgIdx: 0,
|
||||
fltrS: fltr,
|
||||
cache: result.(*PartialCSVFileER).cache,
|
||||
rdrDir: "/var/spool/cgrates/ers/in",
|
||||
rdrEvents: nil,
|
||||
rdrError: nil,
|
||||
rdrExit: nil,
|
||||
conReqs: result.(*PartialCSVFileER).conReqs,
|
||||
}
|
||||
if !reflect.DeepEqual(result, expected) {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartialCSVConfig(t *testing.T) {
|
||||
cfg := config.NewDefaultCGRConfig()
|
||||
cfg.ERsCfg().Readers = []*config.EventReaderCfg{
|
||||
{
|
||||
ID: utils.MetaDefault,
|
||||
Type: utils.MetaNone,
|
||||
RowLength: 0,
|
||||
FieldSep: ",",
|
||||
HeaderDefineChar: ":",
|
||||
RunDelay: 0,
|
||||
ConcurrentReqs: 1024,
|
||||
SourcePath: "/var/spool/cgrates/ers/in",
|
||||
ProcessedPath: "/var/spool/cgrates/ers/out",
|
||||
XMLRootPath: utils.HierarchyPath{utils.EmptyString},
|
||||
Tenant: nil,
|
||||
Timezone: utils.EmptyString,
|
||||
Filters: []string{},
|
||||
Flags: utils.FlagsWithParams{},
|
||||
Fields: nil,
|
||||
CacheDumpFields: nil,
|
||||
Opts: make(map[string]interface{}),
|
||||
},
|
||||
}
|
||||
fltr := &engine.FilterS{}
|
||||
testStruct := &PartialCSVFileER{
|
||||
cgrCfg: cfg,
|
||||
cfgIdx: 0,
|
||||
fltrS: fltr,
|
||||
cache: nil,
|
||||
rdrDir: "/var/spool/cgrates/ers/in",
|
||||
rdrEvents: nil,
|
||||
rdrError: nil,
|
||||
rdrExit: nil,
|
||||
conReqs: nil,
|
||||
}
|
||||
expected := &config.EventReaderCfg{
|
||||
ID: utils.MetaDefault,
|
||||
Type: utils.MetaNone,
|
||||
RowLength: 0,
|
||||
FieldSep: ",",
|
||||
HeaderDefineChar: ":",
|
||||
RunDelay: 0,
|
||||
ConcurrentReqs: 1024,
|
||||
SourcePath: "/var/spool/cgrates/ers/in",
|
||||
ProcessedPath: "/var/spool/cgrates/ers/out",
|
||||
XMLRootPath: utils.HierarchyPath{utils.EmptyString},
|
||||
Tenant: nil,
|
||||
Timezone: utils.EmptyString,
|
||||
Filters: []string{},
|
||||
Flags: utils.FlagsWithParams{},
|
||||
Fields: nil,
|
||||
CacheDumpFields: nil,
|
||||
Opts: make(map[string]interface{}),
|
||||
}
|
||||
result := testStruct.Config()
|
||||
if !reflect.DeepEqual(result, expected) {
|
||||
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user