mirror of
https://github.com/InazumaV/Ratte.git
synced 2026-02-04 04:30:09 +00:00
Initial commit
This commit is contained in:
50
conf/conf_test.go
Normal file
50
conf/conf_test.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestConf_Load_Local(t *testing.T) {
|
||||
c := New("./config.json5")
|
||||
err := c.Load(nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
t.Log(c)
|
||||
}
|
||||
|
||||
func TestConf_Load_Remote(t *testing.T) {
|
||||
c := New("http://127.0.0.1:9000/config.json5")
|
||||
err := c.Load(nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConf_Watch(t *testing.T) {
|
||||
c := New("./config.json5")
|
||||
err := c.Load(nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
t.Log(c)
|
||||
c.SetEventHandler(func(event uint, target ...string) {
|
||||
switch event {
|
||||
case ConfigFileChangedEvent:
|
||||
t.Log("Event:", "ConfigFileChangedEvent", "target:", target)
|
||||
case CoreDataPathChangedEvent:
|
||||
t.Log("Event:", "CoreDataPathChangedEvent", "target:", target)
|
||||
}
|
||||
})
|
||||
c.SetErrorHandler(func(err error) {
|
||||
t.Error(err)
|
||||
})
|
||||
err = c.Watch()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
t.Log("press any key to done.")
|
||||
fmt.Scan()
|
||||
}
|
||||
Reference in New Issue
Block a user