diff options
author | Lvbo163 <lv.bo163@zte.com.cn> | 2018-03-07 16:52:05 +0800 |
---|---|---|
committer | Lvbo163 <lv.bo163@zte.com.cn> | 2018-03-07 16:52:05 +0800 |
commit | 750f9b934e29ea6c4a7a976890f04650b91b7c9a (patch) | |
tree | 3b0c0881e20241804b50d508dd0068ee35104cf9 | |
parent | 3aaf336fe722034b287dcbfc9fdf5bfb2ca23366 (diff) |
add ut for SendServiceWork
Issue-ID: MSB-165
Change-Id: I61d11fdf1b4cc9da023b4a0aea23ae098231e289
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
-rw-r--r-- | src/kube2msb/kube2msb_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
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) + } + } +} |