Add new unit tests on engine and config

This commit is contained in:
armirveliaj
2024-09-19 10:24:40 -04:00
committed by Dan Christian Bogos
parent b523024ca2
commit 4b35d74a29
4 changed files with 129 additions and 0 deletions

View File

@@ -20,6 +20,8 @@ package engine
import (
"testing"
"github.com/cgrates/cgrates/config"
)
func TestTrendProfileTenantID(t *testing.T) {
@@ -45,3 +47,44 @@ func TestTrendTenantID(t *testing.T) {
t.Errorf("TenantID() = %v; want %v", result, expected)
}
}
func TestNewTrendS(t *testing.T) {
dm := &DataManager{}
connMgr := &ConnManager{}
filterS := &FilterS{}
cgrcfg := &config.CGRConfig{}
trendS := NewTrendS(dm, connMgr, filterS, cgrcfg)
if trendS == nil {
t.Errorf("Expected NewTrendS to return a non-nil instance")
}
if trendS.dm != dm {
t.Errorf("Expected DataManager to be set correctly, got %v, want %v", trendS.dm, dm)
}
if trendS.connMgr != connMgr {
t.Errorf("Expected ConnManager to be set correctly, got %v, want %v", trendS.connMgr, connMgr)
}
if trendS.filterS != filterS {
t.Errorf("Expected FilterS to be set correctly, got %v, want %v", trendS.filterS, filterS)
}
if trendS.cgrcfg != cgrcfg {
t.Errorf("Expected CGRConfig to be set correctly, got %v, want %v", trendS.cgrcfg, cgrcfg)
}
if trendS.loopStopped == nil {
t.Errorf("Expected loopStopped to be initialized, but got nil")
}
if trendS.crnTQsMux == nil {
t.Errorf("Expected crnTQsMux to be initialized, but got nil")
}
if trendS.crnTQs == nil {
t.Errorf("Expected crnTQs to be initialized, but got nil")
} else if len(trendS.crnTQs) != 0 {
t.Errorf("Expected crnTQs to be empty, but got length %d", len(trendS.crnTQs))
}
if trendS.crn != nil {
t.Errorf("Expected crn to be nil, but got %v", trendS.crn)
}
}