-
Notifications
You must be signed in to change notification settings - Fork 2
/
client_service_test.go
76 lines (70 loc) · 1.61 KB
/
client_service_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package nacos
import (
"fmt"
"testing"
"time"
)
func TestNewServiceClient(t *testing.T) {
a, err := NewServiceClient("http://nacos:[email protected]:8848/nacos", LogLevel("info"))
if err != nil {
t.Error(err)
return
}
err = a.RegisterInstance("127.0.0.1", 8000, "my_test_service")
if err != nil {
t.Error(err)
return
}
<-time.After(17 * time.Second)
t.Log("fin")
}
func TestNewServiceClientGet(t *testing.T) {
a, err := NewServiceClient("http://nacos:[email protected]:8848/nacos", LogLevel("debug"))
if err != nil {
t.Error(err)
return
}
s, err := a.GetService("my_test_service", false, ParamClusters([]string{}))
if err != nil {
t.Error(err)
return
}
fmt.Println("clusters", s.Clusters, "lenhosts", len(s.Instances))
<-time.After(2 * time.Second)
}
func TestNewServiceClientPublish(t *testing.T) {
a, err := NewServiceClient("http://nacos:[email protected]:8848/nacos", LogLevel("debug"))
if err != nil {
t.Error(err)
return
}
err = a.PublishConfig("testDataId", "group", "111113")
if err != nil {
t.Error(err)
return
}
}
func TestNewServiceClientGetConfig(t *testing.T) {
a, err := NewServiceClient("http://nacos:[email protected]:8848/nacos", LogLevel("debug"))
if err != nil {
t.Error(err)
return
}
k, err := a.GetConfig("testDataId", "group")
if err != nil {
t.Error(err)
return
}
t.Log(k)
}
func TestNewServiceClientRemove(t *testing.T) {
a, err := NewServiceClient("http://nacos:[email protected]:8848/nacos", LogLevel("debug"))
if err != nil {
t.Error(err)
return
}
a.ListenConfig("testDataId", "group", func(s string) {
t.Log("v", s)
})
<-time.After(4 * time.Second)
}