Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
JameKeal committed Mar 31, 2023
1 parent d9dcae9 commit 090631e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/controller/poolcoordinator/cert/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
kerrors "k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"

"github.com/openyurtio/openyurt/pkg/util/ip"
)

const (
Expand Down Expand Up @@ -111,3 +113,27 @@ func TestGetAPIServerSVCURL(t *testing.T) {
assert.Equal(t, nil, err)
assert.Equal(t, "https://xxxx:644", url)
}

func TestWaitUntilSVCReady(t *testing.T) {
stop := make(chan struct{})
defer close(stop)

normalClient := fake.NewSimpleClientset(&corev1.Service{
ObjectMeta: v1.ObjectMeta{
Namespace: PoolcoordinatorNS,
Name: PoolcoordinatorAPIServerSVC,
},
Spec: corev1.ServiceSpec{
ClusterIP: "xxxx",
Ports: []corev1.ServicePort{
{
Port: 644,
},
},
},
})
ips, _, err := waitUntilSVCReady(normalClient, PoolcoordinatorAPIServerSVC, stop)
assert.Equal(t, nil, err)
expectIPS := ip.ParseIPList([]string{"xxxx"})
assert.Equal(t, expectIPS, ips)
}

0 comments on commit 090631e

Please sign in to comment.