Add new unit tests on engine

This commit is contained in:
armirveliaj
2024-07-01 10:07:18 -04:00
committed by Dan Christian Bogos
parent fedacded6e
commit 8447bbb084
2 changed files with 26 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import (
"fmt"
"log"
"net/http"
"net/http/httptest"
"net/url"
"os"
"reflect"
@@ -2516,3 +2517,14 @@ func TestCDRSCallInvalidServiceMethod(t *testing.T) {
t.Errorf("Expected error %v, got %v", rpcclient.ErrUnsupporteServiceMethod, err)
}
}
func TestNewMapEventFromReqForm_ParseForm(t *testing.T) {
formData := url.Values{}
formData.Add("key", "value")
req := httptest.NewRequest("POST", "/", strings.NewReader(formData.Encode()))
req.Header.Add("Content-Type", "application/x-www-cgrates-urlencoded")
_, err := newMapEventFromReqForm(req)
if err != nil {
t.Fatalf("Expected no error, got %v", err)
}
}

View File

@@ -184,3 +184,17 @@ func TestSuretaxSureTaxProcessCdrPostErr(t *testing.T) {
t.Errorf("\nExpected: %q, \nReceived: %q", experr, err)
}
}
func TestFieldAsInterfaceEmptyPath(t *testing.T) {
tDP := &dynamicDP{}
val, err := tDP.FieldAsInterface([]string{})
if err != utils.ErrNotFound {
t.Errorf("Expected error utils.ErrNotFound, but got: %v", err)
}
if val != nil {
t.Errorf("Expected nil value, but got: %v", val)
}
}