summaryrefslogtreecommitdiff
path: root/edgemesh
diff options
context:
space:
mode:
authorchlins <chlins.zhang@gmail.com>2019-08-16 10:49:44 +0800
committerchlins <chlins.zhang@gmail.com>2019-08-16 10:49:44 +0800
commit20853f40b02563bc361261c6579fa9f484d1678f (patch)
treeec790f25d0f343dbb6fe840972d7fce77a53f465 /edgemesh
parentMerge pull request #1022 from ethan-daocloud/patch-3 (diff)
downloadkubeedge-20853f40b02563bc361261c6579fa9f484d1678f.tar.gz
add unit tests
Diffstat (limited to 'edgemesh')
-rw-r--r--edgemesh/pkg/common/utils_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/edgemesh/pkg/common/utils_test.go b/edgemesh/pkg/common/utils_test.go
new file mode 100644
index 000000000..4c371e352
--- /dev/null
+++ b/edgemesh/pkg/common/utils_test.go
@@ -0,0 +1,29 @@
+package common
+
+import "testing"
+
+func TestSplitServiceKey(t *testing.T) {
+ type args struct {
+ key string
+ }
+ tests := []struct {
+ name string
+ args args
+ wantName string
+ wantNamespace string
+ }{
+ {"normal serviceKey", args{"foo.bar"}, "foo", "bar"},
+ {"default namespace", args{"foo"}, "foo", "default"},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ gotName, gotNamespace := SplitServiceKey(tt.args.key)
+ if gotName != tt.wantName {
+ t.Errorf("SplitServiceKey() gotName = %v, want %v", gotName, tt.wantName)
+ }
+ if gotNamespace != tt.wantNamespace {
+ t.Errorf("SplitServiceKey() gotNamespace = %v, want %v", gotNamespace, tt.wantNamespace)
+ }
+ })
+ }
+}