From 750f9b934e29ea6c4a7a976890f04650b91b7c9a Mon Sep 17 00:00:00 2001 From: Lvbo163 Date: Wed, 7 Mar 2018 16:52:05 +0800 Subject: add ut for SendServiceWork Issue-ID: MSB-165 Change-Id: I61d11fdf1b4cc9da023b4a0aea23ae098231e289 Signed-off-by: Lvbo163 --- src/kube2msb/kube2msb_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/kube2msb/kube2msb_test.go b/src/kube2msb/kube2msb_test.go index 435fb3f..09f7a80 100644 --- a/src/kube2msb/kube2msb_test.go +++ b/src/kube2msb/kube2msb_test.go @@ -18,6 +18,8 @@ package main import ( "os" "testing" + + kapi "k8s.io/kubernetes/pkg/api" ) func urlFormateValidate(t *testing.T, method string) { @@ -66,3 +68,24 @@ func TestGetMSBUrl(t *testing.T) { func TestGetKubeMasterUrl(t *testing.T) { urlFormateValidate(t, "getKubeMasterUrl") } + +func TestSendServiceWork(t *testing.T) { + + kubeWorkQueue := make(chan KubeWork, 1) + serviceObj := kapi.Service{} + + cases := []KubeWorkAction{ + KubeWorkAddService, + KubeWorkRemoveService, + KubeWorkUpdateService, + } + + for _, c := range cases { + sendServiceWork(c, kubeWorkQueue, &serviceObj) + got := <-kubeWorkQueue + + if got.Action != c { + t.Errorf("sendServiceWork(%action, queue, service) got %gotAction", c, got.Action) + } + } +} -- cgit 1.2.3-korg