github.com/zooyer/miskit@v1.0.71/sdk/etc/main_test.go (about) 1 package etc 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 8 "github.com/zooyer/jsons" 9 ) 10 11 func init() { 12 var err error 13 if err = Init("./test"); err != nil { 14 panic(err) 15 } 16 } 17 18 func TestGetConfig(t *testing.T) { 19 var err error 20 var raw jsons.Raw 21 if err = GetConfig("test", "test", &raw); err != nil { 22 t.Fatal(err) 23 } 24 25 t.Log(string(raw)) 26 27 for i := 0; i < 60; i++ { 28 var raw []byte 29 if raw, err = GetData("test", "abc"); err != nil { 30 t.Fatal(err) 31 } 32 fmt.Println(string(raw)) 33 time.Sleep(time.Second) 34 } 35 } 36 37 func TestNotify(t *testing.T) { 38 var err error 39 fn := func() { 40 data, err := GetData("test", "def") 41 if err != nil { 42 fmt.Println(err.Error()) 43 } 44 fmt.Println(string(data)) 45 } 46 if err = Notify("test", "def", fn); err != nil { 47 t.Fatal(err) 48 } 49 }