mirror of
https://github.com/InazumaV/Ratte.git
synced 2026-02-04 12:40:12 +00:00
51 lines
897 B
Go
51 lines
897 B
Go
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()
|
|
}
|