MCPcopy
hub / github.com/hwholiday/learning_tools / TestNewEtcdConfig

Function TestNewEtcdConfig

hconfig/apollo/config_test.go:7–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5)
6
7func TestNewEtcdConfig(t *testing.T) {
8 c, err := NewApolloConfig(
9 WithAppid("test"),
10 WithNamespace("test.yaml"),
11 WithAddr("http://127.0.0.1:32001"),
12 WithCluster("dev"),
13 )
14 if err != nil {
15 t.Error(err)
16 return
17 }
18 loadData, err := c.Load()
19 if err != nil {
20 t.Error(err)
21 return
22 }
23 for _, v := range loadData {
24 t.Logf("Load key %s val %s \n", v.Key, string(v.Val))
25 }
26 w, err := c.Watch()
27 defer w.Close()
28 if err != nil {
29 t.Error(err)
30 return
31 }
32 go func() {
33 for {
34 kvs, err := w.Change()
35 if err != nil {
36 return
37 }
38 for _, v := range kvs {
39 t.Logf("Change key %s val %s \n", v.Key, string(v.Val))
40 }
41 }
42 }()
43 select {}
44}

Callers

nothing calls this directly

Calls 10

NewApolloConfigFunction · 0.85
WithAppidFunction · 0.85
WithAddrFunction · 0.85
WithClusterFunction · 0.85
WithNamespaceFunction · 0.70
ErrorMethod · 0.65
LoadMethod · 0.65
WatchMethod · 0.65
CloseMethod · 0.65
ChangeMethod · 0.65

Tested by

no test coverage detected