mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Added tests in utils
This commit is contained in:
committed by
Dan Christian Bogos
parent
318145d7c5
commit
56f9d16cc0
@@ -1514,13 +1514,6 @@ func TestIsURL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeHashError(t *testing.T) {
|
||||
_, err := ComputeHash("test1;test2;test3")
|
||||
if err != nil {
|
||||
t.Errorf("Expecting: <nil>, received: %+v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeHashMatch(t *testing.T) {
|
||||
lns, _ := ComputeHash("test1;test2;test3")
|
||||
if err := VerifyHash(lns, "test1;test2;test3"); err != true {
|
||||
@@ -1585,3 +1578,10 @@ func TestAESEncryptDecrypt(t *testing.T) {
|
||||
t.Errorf("Expecting: <exampleText>, received: <%+v>", dString)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBoolGenerator(t *testing.T) {
|
||||
boolTest := BoolGenerator().RandomBool()
|
||||
if boolTest != true && boolTest != false {
|
||||
t.Errorf("Needs to be bool")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,3 +748,32 @@ func TestMapStorageCloneNil(t *testing.T) {
|
||||
t.Errorf("Expecting: <nil>, received: %+v", test.Clone())
|
||||
}
|
||||
}
|
||||
|
||||
func TestNavMapGetFieldAsMapStringInterfaceError(t *testing.T) {
|
||||
nM := MapStorage{
|
||||
"AnotherFirstLevel": "ValAnotherFirstLevel",
|
||||
"Slice": &[]struct{}{{}},
|
||||
"SliceString": []string{"1", "2"},
|
||||
"SliceInterface": map[string]interface{}{},
|
||||
}
|
||||
path := []string{"SliceInterface[4]"}
|
||||
_, err := nM.FieldAsInterface(path)
|
||||
if err == nil || err.Error() != "NOT_FOUND" {
|
||||
t.Errorf("Expecting: <NOT_FOUND>, received: %+v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestNavMapGetFieldAsMapStringInterface(t *testing.T) {
|
||||
nM := MapStorage{
|
||||
"FIELD": map[string]interface{}{
|
||||
"Field1": "Val1",
|
||||
"Field2": "Val2"},
|
||||
}
|
||||
path := []string{"FIELD[Field2]"}
|
||||
result, _ := nM.FieldAsInterface(path)
|
||||
if reflect.DeepEqual(result, "val2") {
|
||||
t.Errorf("Expecting: <val2>, received: %+v", result)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user