diff options
author | Lvbo163 <lv.bo163@zte.com.cn> | 2018-03-06 09:10:51 +0800 |
---|---|---|
committer | Lvbo163 <lv.bo163@zte.com.cn> | 2018-03-06 09:10:51 +0800 |
commit | 817d8346892314a97ab0110df83cf0b066c85e17 (patch) | |
tree | 8d4adb597d09ff245ef4359ec5cbd098df35b540 | |
parent | a44a986e78cd1b73a1fda61a2568f4bc4001a42c (diff) |
add ut for MergeIP
Issue-ID: MSB-177
Change-Id: I057566b6fb83d8d4c06c3e64be603d24cc9fe92f
Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
-rw-r--r-- | src/kube2msb/msb_work_test.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/kube2msb/msb_work_test.go b/src/kube2msb/msb_work_test.go new file mode 100644 index 0000000..e271d22 --- /dev/null +++ b/src/kube2msb/msb_work_test.go @@ -0,0 +1,37 @@ +/* +Copyright 2018 ZTE, Inc. and others. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package main + +import ( + "testing" +) + +func TestMergeIP(t *testing.T) { + cases := []struct{ ip, sInfo, want string }{ + {"127.0.0.1", "{}", "{\"ip\":\"127.0.0.1\",}"}, + {"127.0.0.1", "[{}]", "[{\"ip\":\"127.0.0.1\",}]"}, + {"127.0.0.1", "{\"name\":\"msb\"}", "{\"ip\":\"127.0.0.1\",\"name\":\"msb\"}"}, + {"127.0.0.1", "{\"name\":\"msb\", \"child\":{\"name\":\"childname\"}}", + "{\"ip\":\"127.0.0.1\",\"name\":\"msb\", \"child\":{\"ip\":\"127.0.0.1\",\"name\":\"childname\"}}"}, + } + + for _, c := range cases { + got := mergeIP(c.ip, c.sInfo) + if got != c.want { + t.Errorf("mergeIP(%ip, %sInfo) == %got, want %want", c.ip, c.sInfo, got, c.want) + } + } +} |