Tests for ers/partial_csv.go

This commit is contained in:
andronache
2021-03-03 14:29:58 +02:00
committed by Dan Christian Bogos
parent 296ce67fa6
commit 097ac9a893
2 changed files with 54 additions and 2 deletions

View File

@@ -20,6 +20,19 @@ 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
@@ -27,7 +40,6 @@ var (
rdr EventReader
)
/*
func TestKafkaER(t *testing.T) {
cfg, err := config.NewCGRConfigFromJSONStringWithDefaults(`{
"ers": { // EventReaderService
@@ -103,4 +115,3 @@ func TestKafkaER(t *testing.T) {
}
close(rdrExit)
}
*/

View File

@@ -474,3 +474,44 @@ func TestPartialCSVServe4(t *testing.T) {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", nil, err)
}
}
func TestPartialCSVProcessFile(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
fltr := &engine.FilterS{}
testStruct := &PartialCSVFileER{
cgrCfg: cfg,
cfgIdx: 0,
fltrS: fltr,
cache: nil,
rdrDir: "/var/spool/cgrates/ers/in",
rdrEvents: nil,
rdrError: nil,
rdrExit: make(chan struct{}, 1),
conReqs: nil,
}
err := testStruct.processFile("", "")
if err == nil || err.Error() != "open : no such file or directory" {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "open : no such file or directory", err)
}
}
func TestPartialCSVProcessFile2(t *testing.T) {
cfg := config.NewDefaultCGRConfig()
fltr := &engine.FilterS{}
testStruct := &PartialCSVFileER{
cgrCfg: cfg,
cfgIdx: 0,
fltrS: fltr,
cache: nil,
rdrDir: "/var/spool/cgrates/ers/in",
rdrEvents: nil,
rdrError: nil,
rdrExit: make(chan struct{}, 1),
conReqs: make(chan struct{}, 1),
}
testStruct.conReqs <- struct{}{}
err := testStruct.processFile("", "")
if err == nil || err.Error() != "open : no such file or directory" {
t.Errorf("\nExpected <%+v>, \nReceived <%+v>", "open : no such file or directory", err)
}
}