mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Add more backend unit tests
This commit is contained in:
33
backend/internal/util/interfaces_test.go
Normal file
33
backend/internal/util/interfaces_test.go
Normal file
@ -0,0 +1,33 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestFindItemInInterface(t *testing.T) {
|
||||
obj := map[string]interface{}{
|
||||
"key1": "value1",
|
||||
"key2": 10,
|
||||
"key3": map[string]interface{}{
|
||||
"nestedKey": "nestedValue",
|
||||
},
|
||||
"key4": []interface{}{"item1", "item2"},
|
||||
}
|
||||
|
||||
// Test case 1: Key exists at the top level
|
||||
result, found := FindItemInInterface("key1", obj)
|
||||
assert.Equal(t, true, found)
|
||||
assert.Equal(t, "value1", result)
|
||||
|
||||
// Test case 2: Key exists at a nested level
|
||||
result, found = FindItemInInterface("nestedKey", obj)
|
||||
assert.Equal(t, true, found)
|
||||
assert.Equal(t, "nestedValue", result)
|
||||
|
||||
// Test case 3: Key does not exist
|
||||
result, found = FindItemInInterface("nonExistentKey", obj)
|
||||
assert.Equal(t, false, found)
|
||||
assert.Equal(t, nil, result)
|
||||
}
|
Reference in New Issue
Block a user