-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
35 lines (32 loc) · 890 Bytes
/
config_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
package auto_config
import (
"fmt"
"github.com/huckops/auto_config/loader"
"github.com/huckops/auto_config/source/file"
"testing"
)
func TestConfig(t *testing.T) {
var Dest map[string]interface{}
w := func() {
fmt.Println(Dest)
}
config, err := NewConfig(WithSource(file.NewSource(file.WithPath("/home/huck/桌面/auto_config/test/test.yaml"))), WithSource(file.NewSource(file.WithPath("/home/huck/桌面/auto_config/test/test2.yaml"))), WithEntity(&Dest), WithCallback(w))
if err != nil {
t.Error(err)
panic(err)
}
config.Watcher()
//select {}
}
func TestWatcher(t *testing.T) {
var i interface{}
config, _ := NewConfig(WithSource(file.NewSource(file.WithPath("/home/huck/桌面/auto_config/test/test.yaml"))), WithEntity(i))
w := config.opts.Loader.Watcher()
go func(w loader.Watcher) {
for {
t, err := w.Next()
fmt.Println(t, err)
}
}(w)
select {}
}