Skip to content

Commit fb88f4b

Browse files
committed
add tests
Signed-off-by: idohu <[email protected]>
1 parent e12b3d6 commit fb88f4b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

servicehandler/servicediscovery_test.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package servicehandler
22

33
import (
4+
"reflect"
45
"testing"
56

67
v1 "k8s.io/api/core/v1"
8+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
79
)
810

911
var TestAuthentications = ServiceAuthentication{
@@ -43,12 +45,16 @@ var TestAuthentications = ServiceAuthentication{
4345
}
4446

4547
func TestUnstructured(t *testing.T) {
46-
obj, err := TestAuthentications.Unstructured()
47-
if err == nil {
48+
unstructuredObject, err := TestAuthentications.Unstructured()
49+
if err != nil {
4850
t.Errorf("Unstructured() got an error: %v", err)
4951
}
50-
if obj == nil {
51-
t.Errorf("Unstructured() returned nil")
52+
objType := reflect.TypeOf(unstructuredObject)
53+
if unstructuredType := reflect.TypeOf(&unstructured.Unstructured{}); objType != unstructuredType {
54+
t.Errorf("Unstructured() returned an object of unexpected type")
55+
}
56+
if unstructuredObject.Object == nil {
57+
t.Errorf("Unstructured() returned an object with nil value")
5258
}
5359
}
5460

0 commit comments

Comments
 (0)