diff --git a/engine/libcdre_it_test.go b/engine/libcdre_it_test.go
new file mode 100644
index 000000000..e7f557477
--- /dev/null
+++ b/engine/libcdre_it_test.go
@@ -0,0 +1,56 @@
+// +build integration
+
+/*
+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
+*/
+
+package engine
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/cgrates/cgrates/config"
+)
+
+func TestWriteFailedPosts(t *testing.T) {
+ // can't convert
+ var notanExportEvent string
+ writeFailedPosts("somestring", notanExportEvent)
+ // can convert & write
+ dir := "/tmp/engine/libcdre_test/"
+ exportEvent := &ExportEvents{
+ module: "module",
+ }
+ if err := os.RemoveAll(dir); err != nil {
+ t.Fatal("Error removing folder: ", dir, err)
+ }
+ if err := os.MkdirAll(dir, 0755); err != nil {
+ t.Fatal("Error creating folder: ", dir, err)
+ }
+ config.CgrConfig().GeneralCfg().FailedPostsDir = dir
+ writeFailedPosts("itmID", exportEvent)
+
+ if filename, err := filepath.Glob(filepath.Join(dir, "*.gob")); err != nil {
+ t.Error(err)
+ } else if len(filename) == 0 {
+ t.Error("Expecting one file")
+ } else if len(filename) > 1 {
+ t.Error("Expecting only one file")
+ }
+}
diff --git a/sessions/sessions_test.go b/sessions/sessions_test.go
index 82766a8d7..6663dcb43 100644
--- a/sessions/sessions_test.go
+++ b/sessions/sessions_test.go
@@ -55,6 +55,35 @@ var attrs = &engine.AttrSProcessEventReply{
},
}
+func TestIsIndexed(t *testing.T) {
+ sS := &SessionS{}
+ if sS.isIndexed(&Session{CGRID: "test"}, true) {
+ t.Error("Expecting: false, received: true")
+ }
+ if sS.isIndexed(&Session{CGRID: "test"}, false) {
+ t.Error("Expecting: false, received: true")
+ }
+ sS = &SessionS{
+ aSessions: map[string]*Session{"test": &Session{CGRID: "test"}},
+ }
+ if !sS.isIndexed(&Session{CGRID: "test"}, false) {
+ t.Error("Expecting: true, received: false")
+ }
+ if sS.isIndexed(&Session{CGRID: "test"}, true) {
+ t.Error("Expecting: true, received: false")
+ }
+
+ sS = &SessionS{
+ pSessions: map[string]*Session{"test": &Session{CGRID: "test"}},
+ }
+ if !sS.isIndexed(&Session{CGRID: "test"}, true) {
+ t.Error("Expecting: false, received: true")
+ }
+ if sS.isIndexed(&Session{CGRID: "test"}, false) {
+ t.Error("Expecting: false, received: true")
+ }
+}
+
func TestSessionSIndexAndUnindexSessions(t *testing.T) {
sSCfg, _ := config.NewDefaultCGRConfig()
sSCfg.SessionSCfg().SessionIndexes = utils.StringMap{
diff --git a/utils/set_test.go b/utils/set_test.go
new file mode 100644
index 000000000..c1e45476f
--- /dev/null
+++ b/utils/set_test.go
@@ -0,0 +1,84 @@
+/*
+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
+*/
+
+package utils
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestNewStringSet(t *testing.T) {
+ input := []string{}
+ exp := &StringSet{data: make(map[string]struct{})}
+ if rcv := NewStringSet(input); !reflect.DeepEqual(rcv, exp) {
+ t.Errorf("Expected: %+v, received: %+v", exp, rcv)
+ }
+ input = []string{"test"}
+ exp.AddSlice(input)
+ if rcv := NewStringSet(input); !reflect.DeepEqual(rcv, exp) {
+ t.Errorf("Expected: %+v, received: %+v", exp, rcv)
+ }
+ input = []string{"test1", "test2", "test3"}
+ exp = &StringSet{data: make(map[string]struct{})}
+ exp.AddSlice(input)
+ if rcv := NewStringSet(input); !reflect.DeepEqual(rcv, exp) {
+ t.Errorf("Expected: %+v, received: %+v", exp, rcv)
+ }
+}
+
+func TestAdd(t *testing.T){
+ s := &StringSet{data: map[string]struct{}{}}
+ eOut := &StringSet{data: map[string]struct{}{
+ "test" : struct{}{},
+ }}
+ if reflect.DeepEqual(eOut,s){
+ t.Errorf("Expecting: %+v, received: %+v",eOut,s)
+ }
+ s.Add("test")
+ if !reflect.DeepEqual(eOut,s){
+ t.Errorf("Expecting: %+v, received: %+v",eOut,s)
+ }
+}
+
+func TestRemove(t *testing.T){
+ eOut := &StringSet{data: map[string]struct{}{}}
+ s := &StringSet{data: map[string]struct{}{
+ "test" : struct{}{},
+ }}
+ if reflect.DeepEqual(eOut,s){
+ t.Errorf("Expecting: %+v, received: %+v",eOut,s)
+ }
+ s.Remove("test")
+ if !reflect.DeepEqual(eOut,s){
+ t.Errorf("Expecting: %+v, received: %+v",eOut,s)
+ }
+}
+
+func TestHas(t *testing.T){
+ s := &StringSet{}
+ if s.Has("test"){
+ t.Error("Expecting: false, received: true")
+ }
+ s = &StringSet{data: map[string]struct{}{
+ "test" : struct{}{},
+ }}
+ if !s.Has("test"){
+ t.Error("Expecting: true, received: false")
+ }
+}
\ No newline at end of file